Skip to content
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

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 7 additions & 2 deletions src/iris/ui/auth/ldap.py
Original file line number Diff line number Diff line change
Expand Up @@ -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']
Copy link
Member

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?

Copy link
Contributor

Choose a reason for hiding this comment

The 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

Copy link
Member

Choose a reason for hiding this comment

The 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:
Copy link
Member

Choose a reason for hiding this comment

The 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:
Expand Down