root/AuthKit/trunk/examples/authorize2.py

Revision 155 (checked in by thejimmyg, 2 months ago)

WARNING: setup.enable = false now also disables authorization, added setup.fakeuser option to set the REMOTE_USER

Line 
1 """
2 This is the same as the authorize.py example but it tests that the ``authkit.setup.enable = false`` option also disables authorisation checks.
3 """
4
5 from authorize import *
6
7
8 if __name__ == '__main__':
9    
10     from paste.httpserver import serve
11     from authkit.authenticate import middleware
12    
13     def valid(environ, username, password):
14         """
15         Sample, very insecure validation function
16         """
17         return username == password
18        
19     app = httpexceptions.make_middleware(AuthorizeExampleApp())
20     app = middleware(
21         app,
22         setup_enable=False,
23         setup_method='basic',
24         basic_realm='Test Realm',
25         basic_authenticate_function=valid
26     )
27     print """
28 Clear the HTTP authentication first by closing your browser if you have been
29 testing other basic authentication examples on the same port.
30
31 You will be able to sign in as any user as long as the password is the same as
32 the username, but all users apart from `james' will be denied access to the
33 resources.
34 """
35     serve(app, host='0.0.0.0', port=8080)
Note: See TracBrowser for help on using the browser.