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