-
Notifications
You must be signed in to change notification settings - Fork 139
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Support ldap login with start tls #267
base: master
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -10,16 +10,21 @@ class Authenticator: | |
def __init__(self, config): | ||
root = os.path.abspath('./') | ||
self.ldap_url = config['auth']['ldap_url'] | ||
self.cert_path = os.path.join(root, config['auth']['ldap_cert_path']) | ||
self.start_tls = config['auth']['start_tls'] | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Switch to config['auth'].get('start_tls') to maintain existing behavior without need for config change There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. ^ agreed :) |
||
if not self.start_tls: | ||
self.cert_path = os.path.join(root, config['auth']['ldap_cert_path']) | ||
self.user_suffix = config['auth']['ldap_user_suffix'] | ||
self.authenticate = self.ldap_auth | ||
if config.get('debug'): | ||
self.authenticate = self.debug_auth | ||
|
||
def ldap_auth(self, username, password): | ||
ldap.set_option(ldap.OPT_X_TLS_CACERTFILE, self.cert_path) | ||
if not self.start_tls: | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. is start tls mutually exclusive with passing a cacert file? |
||
ldap.set_option(ldap.OPT_X_TLS_CACERTFILE, self.cert_path) | ||
connection = ldap.initialize(self.ldap_url) | ||
connection.set_option(ldap.OPT_REFERRALS, 0) | ||
if self.start_tls: | ||
connection.start_tls_s() | ||
|
||
try: | ||
if password: | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
can you update the sample config to add the new usage of this?