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
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidauthenticate(String username, String password) Validate the given username and password against the password filevoidclose()Free resources associated with this authenticatorstatic booleanisPasswordValid(String password, String hash) Check password against hash read from the fileprotected voidread()Read the password file into the map, if the file has changed since we last read itvoidsetup(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:UserAuthenticatorSetup for authenticating user credentials.- Specified by:
setupin 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:
authenticatein 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:
closein interfaceAutoCloseable- Specified by:
closein interfaceCloseable- Specified by:
closein interfaceUserAuthenticator
-