X-Git-Url: http://git.cascardo.info/?p=cascardo%2Fipsilon.git;a=blobdiff_plain;f=ipsilon%2Flogin%2Fcommon.py;h=d616882c20fceb7a4f5647fcf53cd0534093232b;hp=3002d7870c6e5eb6c4e0bf2a565ec3e0ccedf5ed;hb=5497278fab59361c5b6bc5d3c17407128b924b9a;hpb=771b8fd095f3bcb922f761d297c62f1a56a997d5 diff --git a/ipsilon/login/common.py b/ipsilon/login/common.py index 3002d78..d616882 100644 --- a/ipsilon/login/common.py +++ b/ipsilon/login/common.py @@ -37,9 +37,12 @@ class LoginManagerBase(PluginConfig, PluginObject): self.path = '/' self.info = None - def redirect_to_path(self, path): + def redirect_to_path(self, path, trans=None): base = cherrypy.config.get('base.mount', "") - raise cherrypy.HTTPRedirect('%s/login/%s' % (base, path)) + url = '%s/login/%s' % (base, path) + if trans: + url += '?%s' % trans.get_GET_arg() + raise cherrypy.HTTPRedirect(url) def auth_successful(self, trans, username, auth_type=None, userdata=None): session = UserSession() @@ -100,7 +103,7 @@ class LoginManagerBase(PluginConfig, PluginObject): # try with next module next_login = self.next_login() if next_login: - return self.redirect_to_path(next_login.path) + return self.redirect_to_path(next_login.path, trans) # return to the caller if any session = UserSession() @@ -119,6 +122,9 @@ class LoginManagerBase(PluginConfig, PluginObject): raise cherrypy.HTTPRedirect(transdata['login_return']) + def set_auth_error(self): + cherrypy.response.status = 401 + def get_tree(self, site): raise NotImplementedError @@ -267,11 +273,28 @@ class Login(Page): class Logout(Page): + def __init__(self, *args, **kwargs): + super(Logout, self).__init__(*args, **kwargs) + self.handlers = {} def root(self, *args, **kwargs): - UserSession().logout(self.user) + us = UserSession() + + for provider in self.handlers: + self.debug("Calling logout for provider %s" % provider) + obj = self.handlers[provider] + obj() + + us.logout(self.user) return self._template('logout.html', title='Logout') + def add_handler(self, provider, handler): + """ + Providers can register a logout handler here that is called + when the IdP logout link is accessed. + """ + self.handlers[provider] = handler + class Cancel(Page): @@ -292,6 +315,25 @@ class Cancel(Page): return op(*args, **kwargs) +class LoginManagerInstaller(object): + def __init__(self): + self.facility = FACILITY + self.ptype = 'login' + self.name = None + + def unconfigure(self, opts): + return + + def install_args(self, group): + raise NotImplementedError + + def validate_args(self, args): + return + + def configure(self, opts): + raise NotImplementedError + + class LoginMgrsInstall(object): def __init__(self):