Skip to content

Commit

Permalink
Use Twisted endpoint strings to specify the LDAP backend.
Browse files Browse the repository at this point in the history
Using the new syntax, we can now even specify a connection
establishment timeout (see #10).
  • Loading branch information
Friedrich Weber committed Feb 16, 2017
1 parent fbe994f commit d0624f6
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 8 deletions.
8 changes: 5 additions & 3 deletions example-proxy.ini
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,11 @@ endpoint = http://10.0.0.1/validate/check
realm =

[ldap-backend]
# Host and port of the LDAP backend server
host = 10.0.0.2
port = 389
# Location of the LDAP backend server, specified using the Twisted endpoint string syntax:
# https://twistedmatrix.com/documents/16.4.1/core/howto/endpoints.html#endpoint-types-included-with-twisted
# You can also specify a timeout for connection establishment here (by providing timeout=X)
# CAUTION: LDAPS/STARTTLS is currently unsupported!
endpoint = tcp:host=10.0.0.2:port=389
# Enabling/disabling of TLS (currently unsupported)
use-tls = false

Expand Down
3 changes: 1 addition & 2 deletions pi_ldapproxy/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,7 @@
realm = string(default='')
[ldap-backend]
host = string
port = integer
endpoint = string
use-tls = boolean
[ldap-proxy]
Expand Down
4 changes: 1 addition & 3 deletions pi_ldapproxy/proxy.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,6 @@

log = Logger()

PROXIED_ENDPOINT_TEMPLATE = 'tcp:host={backend[host]}:port={backend[port]}'

class ProxyError(Exception):
pass

Expand Down Expand Up @@ -190,7 +188,7 @@ def __init__(self, config):
print 'LDAP over TLS is currently unsupported. Exiting.'
sys.exit(1)

self.proxied_endpoint_string = PROXIED_ENDPOINT_TEMPLATE.format(backend=config['ldap-backend'])
self.proxied_endpoint_string = config['ldap-backend']['endpoint']
self.validate_url = config['privacyidea']['endpoint']
self.validate_realm = config['privacyidea']['realm']

Expand Down

0 comments on commit d0624f6

Please sign in to comment.