Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Newer
Older
100644 43 lines (38 sloc) 1.418 kB
d17e40a @mcdonc first cut
mcdonc authored
1 from pyramid.config import Configurator
2 from pyramid_ldap import groupfinder
3
4 from pyramid.authentication import AuthTktAuthenticationPolicy
5 from pyramid.authorization import ACLAuthorizationPolicy
6 from pyramid.security import Allow, Authenticated
7
8 class RootFactory(object):
9 __acl__ = [(Allow, Authenticated, 'view')]
10 def __init__(self, request):
11 pass
12
13 def main(global_config, **settings):
14 config = Configurator(settings=settings, root_factory=RootFactory)
15 config.include('pyramid_ldap')
16 config.set_authentication_policy(
17 AuthTktAuthenticationPolicy('seekr1t', callback=groupfinder)
18 )
19 config.set_authorization_policy(
20 ACLAuthorizationPolicy()
21 )
22 config.ldap_setup(
23 'ldap://192.168.1.159',
24 bind='CN=ldap user,CN=Users,DC=example,DC=com',
25 passwd='ld@pu5er')
26 config.ldap_set_login_query(
27 'CN=Users,DC=example,DC=com',
28 '(sAMAccountName=%(login)s)',
285b46b @mcdonc docs
mcdonc authored
29 cache_period=0,
d17e40a @mcdonc first cut
mcdonc authored
30 )
31 config.ldap_set_groups_query(
32 'CN=Users,DC=example,DC=com',
33 '(member:1.2.840.113556.1.4.1941:=%(userdn)s)',
34 #'(&(objectCategory=group)(member=%(dn)s))',
285b46b @mcdonc docs
mcdonc authored
35 cache_period=60,
d17e40a @mcdonc first cut
mcdonc authored
36 )
37 config.add_route('sampleapp.root', '/')
38 config.add_route('sampleapp.login', '/login')
39 config.add_route('sampleapp.logout', '/logout')
40 config.scan('.views')
41 return config.make_wsgi_app()
42
Something went wrong with that request. Please try again.