Skip to content
Snippets Groups Projects
Select Git revision
  • eebacd42b906734c46f9d1a379fcd7a35fee5a64
  • main default protected
  • ci_test
  • v2.0.27 protected
  • v2.0.26 protected
  • v2.0.25 protected
  • v2.0.24 protected
  • v2.0.23 protected
  • v2.0.22 protected
  • v2.0.21 protected
  • v2.0.20 protected
  • v2.0.19 protected
  • v2.0.18 protected
  • v2.0.17 protected
  • v2.0.16 protected
  • v2.0.15 protected
  • v2.0.14 protected
  • v2.0.13 protected
  • v2.0.12 protected
  • v2.0.11 protected
  • v2.0.10 protected
  • v2.0.9 protected
  • v2.0.8 protected
23 results

generate_ci_pipeline.py

Blame
  • Code owners
    Assign users and groups as approvers for specific file changes. Learn more.
    ldap.py 1.22 KiB
    from server import *
    import re
    
    LDAP_USERRE = re.compile(r'[^a-z0-9]')
    if 'LDAP_HOST' in config:
    	import ldap3
    
    	def ldapauth(user, password):
    		user = LDAP_USERRE.sub(r'', user.lower())
    		try:
    			conn = ldap3.Connection(ldap3.Server(config['LDAP_HOST'], port=config['LDAP_PORT'], use_ssl=True), 'fsmpi\\%s'%user, password, auto_bind=True, check_names=False)
    		except ldap3.core.exceptions.LDAPBindError:
    			return {}, []
    		conn.search("cn=users,dc=fsmpi,dc=rwth-aachen,dc=de", "(cn=%s)"%user, attributes=['memberOf', 'givenName', 'sn'])
    		info = {'uid': user, 'givenName': conn.response[0]['attributes']['givenName'][0], 'sn': conn.response[0]['attributes']['sn'][0]}
    		groups = [g.split(',')[0].split('=')[-1] for g in conn.response[0]['attributes']['memberOf']]
    		conn.unbind()
    		return info, groups
    
    else:
    	notldap = {
    		'videoag':('videoag', ['fachschaft','videoag'], {'uid': 'videoag', 'givenName': 'Video', 'sn': 'Geier'}),
    		'gustav':('passwort', ['fachschaft'], {'uid': 'gustav', 'givenName': 'Gustav', 'sn': 'Geier'})
    	}
    
    	def ldapauth(user, password):
    		user = LDAP_USERRE.sub(r'', user.lower())
    		if config.get('DEBUG') and user in notldap and password == notldap[user][0]:
    			return notldap[user][2], notldap[user][1]
    		return {}, []