Rev | Line | |
---|
[10321] | 1 | """A WSGI app for serving CAS. |
---|
| 2 | """ |
---|
[10335] | 3 | import os |
---|
[10327] | 4 | from webob import exc, Response |
---|
[10321] | 5 | from webob.dec import wsgify |
---|
| 6 | |
---|
[10335] | 7 | template_dir = os.path.join(os.path.dirname(__file__), 'templates') |
---|
[10321] | 8 | |
---|
[10335] | 9 | |
---|
[10321] | 10 | class CASServer(object): |
---|
| 11 | """A WSGI CAS server. |
---|
| 12 | """ |
---|
| 13 | @wsgify |
---|
| 14 | def __call__(self, req): |
---|
[10335] | 15 | if req.path in ['/login', '/validate', '/logout']: |
---|
| 16 | return getattr(self, req.path[1:])(req) |
---|
[10321] | 17 | return exc.HTTPNotFound() |
---|
| 18 | |
---|
[10327] | 19 | def login(self, req): |
---|
[10335] | 20 | return Response( |
---|
| 21 | open(os.path.join(template_dir, 'login.html'), 'r').read()) |
---|
[10327] | 22 | return Response('Hi there!') |
---|
[10321] | 23 | |
---|
[10327] | 24 | def validate(self, req): |
---|
| 25 | return exc.HTTPNotImplemented() |
---|
| 26 | |
---|
| 27 | def logout(self, req): |
---|
| 28 | return exc.HTTPNotImplemented() |
---|
| 29 | |
---|
[10321] | 30 | cas_server = CASServer |
---|
| 31 | |
---|
| 32 | |
---|
| 33 | def make_cas_server(global_conf, **local_conf): |
---|
| 34 | return CASServer(**local_conf) |
---|
Note: See
TracBrowser for help on using the repository browser.