Advertisement
Guest User

uulm: MoinMoin LDAP auth

a guest
Mar 6th, 2014
177
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 4.61 KB | None | 0 0
  1.     # [...]
  2.  
  3.  
  4.     # stop new accounts being created
  5.     actions_excluded = multiconfig.DefaultConfig.actions_excluded + ['newaccount']
  6.  
  7.  
  8.     # LDAP / ActiveDirectory Auth
  9.     # See http://master19.moinmo.in/HelpOnAuthentication#LDAP_based_user_authentication
  10.     #     http://master19.moinmo.in/HelpOnConfiguration#auth
  11.     from MoinMoin.auth import MoinAuth
  12.     from MoinMoin.auth.ldap_login import LDAPAuth
  13.  
  14.     ldap_authenticator1 = LDAPAuth(
  15.         # the values shown below are the DEFAULT values (you may remove them if you are happy with them),
  16.         # the examples shown in the comments are typical for Active Directory (AD) or OpenLDAP.
  17.         server_uri='ldap://134.60.777.777',
  18.                          # ldap / active directory server URI
  19.                          # use ldaps://server:636 url for ldaps,
  20.                          # use  ldap://server for ldap without tls (and set start_tls to 0),
  21.                          # use  ldap://server for ldap with tls (and set start_tls to 1 or 2).
  22.         #bind_dn='',  # We can either use some fixed user and password for binding to LDAP.
  23.         # Be careful if you need a % char in those strings - as they are used as
  24.         # a format string, you have to write %% to get a single % in the end.
  25.         #bind_dn = 'binduser@example.org' # (AD)
  26.         #bind_dn = 'cn=admin,dc=example,dc=org' # (OpenLDAP)
  27.         #bind_pw = 'secret'
  28.         # or we can use the username and password we got from the user:
  29.         bind_dn = '%(username)s@abteilungs-domain.local',
  30.                         # DN we use for first bind (AD)
  31.         bind_pw = '%(password)s',
  32.                         # password we use for first bind
  33.                         # or we can bind anonymously (if that is supported by your directory).
  34.                         # In any case, bind_dn and bind_pw must be defined.
  35.         base_dn='ou=benutzer,ou=abteilung,dc=abteilungs-domain,dc=local',
  36.                         # base DN we use for searching
  37.                         #base_dn = 'ou=SOMEUNIT,dc=example,dc=org'
  38.         scope=2,
  39.                         # scope of the search we do (2 == ldap.SCOPE_SUBTREE)
  40.         referrals=0,
  41.                         # LDAP REFERRALS (0 needed for AD)
  42.         search_filter='(sAMAccountName=%(username)s)',
  43.                         # ldap filter used for searching:
  44.                         #search_filter = '(sAMAccountName=%(username)s)' # (AD)
  45.                         #search_filter = '(uid=%(username)s)' # (OpenLDAP)
  46.                         # you can also do more complex filtering like:
  47.                         # "(&(cn=%(username)s)(memberOf=CN=WikiUsers,OU=Groups,DC=example,DC=org))"
  48.  
  49.         # some attribute names we use to extract information from LDAP (if not None,
  50.         # if None, the attribute won't be extracted from LDAP):
  51.         givenname_attribute='givenName',
  52.                         # often 'givenName' - ldap attribute we get the first name from
  53.         surname_attribute='sn',
  54.                         # often 'sn' - ldap attribute we get the family name from
  55.         aliasname_attribute='displayName',
  56.                         # often 'displayName' - ldap attribute we get the aliasname from
  57.         email_attribute='mail',
  58.                         # often 'mail' - ldap attribute we get the email address from
  59.         email_callback=None,
  60.                         # callback function called to make up email address
  61.         coding='utf-8',
  62.                         # coding used for ldap queries and result values
  63.         timeout=10,
  64.                         # how long we wait for the ldap server [s]
  65.         start_tls=0,
  66.                         # usage of Transport Layer Security 0 = No, 1 = Try, 2 = Required
  67.         tls_cacertdir=None,
  68.         tls_cacertfile=None,
  69.         tls_certfile=None,
  70.         tls_keyfile=None,
  71.         tls_require_cert=0,
  72.                         # 0 == ldap.OPT_X_TLS_NEVER (needed for self-signed certs)
  73.         bind_once=False,
  74.                         # set to True to only do one bind - useful if configured to bind as the user on the first attempt
  75.         autocreate=True,
  76.                         # set to True to automatically create/update user profiles
  77.         name='ldap',
  78.                         # use e.g. 'ldap_pdc' and 'ldap_bdc' (or 'ldap1' and 'ldap2') if you auth against 2 ldap servers
  79.         report_invalid_credentials=True,
  80.                         # whether to emit "invalid username or password" msg at login time or not
  81.     )
  82.  
  83.     auth = [ldap_authenticator1, ] # this is a list, you may have multiple ldap authenticators
  84.                                    # as well as other authenticators
  85.  
  86.     # [...]
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement