Class HtpasswdFileUserAuthenticator
java.lang.Object
org.apache.drill.exec.rpc.user.security.HtpasswdFileUserAuthenticator
- All Implemented Interfaces:
Closeable
,AutoCloseable
,UserAuthenticator
Implementation of UserAuthenticator that reads passwords from an htpasswd
formatted file.
Currently supports MD5, SHA-1, and plaintext passwords.
Use the htpasswd command line tool to create and modify htpasswd files.
By default this loads the passwords from /opt/drill/conf/htpasswd
. Users can change the path by
putting the absolute file path as drill.exec.security.user.auth.htpasswd.path
in
drill-override.conf
.
This is intended for situations where the list of users is relatively static, and you are running drill in a container so using pam is not convenient.
-
Field Summary
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionvoid
authenticate
(String username, String password) Validate the given username and password against the password filevoid
close()
Free resources associated with this authenticatorstatic boolean
isPasswordValid
(String password, String hash) Check password against hash read from the fileprotected void
read()
Read the password file into the map, if the file has changed since we last read itvoid
setup
(DrillConfig drillConfig) Setup for authenticating user credentials.
-
Field Details
-
DEFAULT_HTPASSWD_AUTHENTICATOR_PATH
- See Also:
-
-
Constructor Details
-
HtpasswdFileUserAuthenticator
public HtpasswdFileUserAuthenticator()
-
-
Method Details
-
setup
Description copied from interface:UserAuthenticator
Setup for authenticating user credentials.- Specified by:
setup
in interfaceUserAuthenticator
- Throws:
DrillbitStartupException
-
isPasswordValid
Check password against hash read from the file- Parameters:
password
- User provided passwordhash
- Hash stored in the htpasswd file- Returns:
- true if the password matched the hash
-
authenticate
Validate the given username and password against the password file- Specified by:
authenticate
in interfaceUserAuthenticator
- Parameters:
username
- Username providedpassword
- Password provided- Throws:
UserAuthenticationException
- If the username and password could not be validated
-
read
protected void read()Read the password file into the map, if the file has changed since we last read it -
close
public void close()Free resources associated with this authenticator- Specified by:
close
in interfaceAutoCloseable
- Specified by:
close
in interfaceCloseable
- Specified by:
close
in interfaceUserAuthenticator
-