"""A WSGI app for serving CAS. """ import os from webob import exc, Response from webob.dec import wsgify template_dir = os.path.join(os.path.dirname(__file__), 'templates') class CASServer(object): """A WSGI CAS server. """ @wsgify def __call__(self, req): if req.path in ['/login', '/validate', '/logout']: return getattr(self, req.path[1:])(req) return exc.HTTPNotFound() def login(self, req): return Response( open(os.path.join(template_dir, 'login.html'), 'r').read()) def validate(self, req): return exc.HTTPNotImplemented() def logout(self, req): return exc.HTTPNotImplemented() cas_server = CASServer def make_cas_server(global_conf, **local_conf): return CASServer(**local_conf)