Beispiel #1
0
 def setUp(self):
     super(TestLDAPAuthenticatorReturnLogin, self).setUp()
     # Loading the plugin:
     self.plugin = LDAPAuthenticatorPlugin(
         self.connection,
         base_dn,
         returned_id='login',
     )
Beispiel #2
0
    def make_ldap_auth_app(global_conf, **app_conf):
        """example authenticated app with ldap"""

        assert 'auth.base_dn' in app_conf, "No base_dn specified"
        assert 'auth.ldap_host' in app_conf, "No ldap_host specified"

        app_conf['traclegos.auth'] = True

        # make the app
        app = make_app(global_conf, **app_conf)

        # XXX bad touch
        # this should really be passed to the make_app factory and used there
        # but there's no current way of doing this intelligently
        app.application.remote_user_name = ldap_remote_user

        # get the ldap connection
        conn = ldap.open(app_conf['auth.ldap_host'])
        if app_conf.get('auth.use_tls', 'False').lower() == 'true':
            conn.start_tls_s()

        # wrap in repoze.who authentication middleware
        ldap_auth = LDAPAuthenticatorPlugin(conn, app_conf['auth.base_dn'])
        auth_tkt = AuthTktCookiePlugin('secret', 'auth_tkt')
        form = RedirectingFormPlugin('/', '/login', '/logout', 'auth_tkt')
        identifiers = [('form', form), ('auth_tkt', auth_tkt)]
        authenticators = [('ldap_auth', ldap_auth)]
        challengers = [('form', form)]

        from repoze.who.classifiers import default_request_classifier
        from repoze.who.classifiers import default_challenge_decider
        log_stream = None

        #import logging
        #logger = logging.getLogger('something')
        #logger.setLevel(logging.DEBUG)
        return PluggableAuthenticationMiddleware(app,
                                                 identifiers,
                                                 authenticators,
                                                 challengers, [],
                                                 default_request_classifier,
                                                 default_challenge_decider,
                                                 log_stream=None,
                                                 log_level=logging.DEBUG)
Beispiel #3
0
 def setUp(self):
     super(TestLDAPAuthenticatorPlugin, self).setUp()
     # Loading the plugin:
     self.plugin = LDAPAuthenticatorPlugin(self.connection, base_dn)
Beispiel #4
0
 def test_connection_is_url(self):
     LDAPAuthenticatorPlugin('ldap://example.org', 'dc=example,dc=org')
Beispiel #5
0
 def test_with_connection(self):
     conn = fakeldap.FakeLDAPConnection()
     LDAPAuthenticatorPlugin(conn, 'dc=example,dc=org')
Beispiel #6
0
 def setUp(self):
     super(TestLDAPAuthenticatorPluginStartTls, self).setUp()
     # Loading the plugin:
     self.plugin = LDAPAuthenticatorPlugin(self.connection,
                                           base_dn,
                                           start_tls=True)