diff options
author | Simo Sorce <simo@redhat.com> | 2014-02-23 18:39:35 -0500 |
---|---|---|
committer | Simo Sorce <simo@redhat.com> | 2014-02-24 20:30:06 -0500 |
commit | f7070919e1350f784f639fd2054eab80384abeea (patch) | |
tree | 0b8d801d6b4c8400988afb060d0b1fe9500d5b38 /ipsilon/login | |
parent | 639c307ccd557d43e46c6f5cfa913a41d5d53550 (diff) | |
download | ipsilon-f7070919e1350f784f639fd2054eab80384abeea.tar.gz ipsilon-f7070919e1350f784f639fd2054eab80384abeea.tar.xz ipsilon-f7070919e1350f784f639fd2054eab80384abeea.zip |
Better session management at login
Save data bout the prformed authentication
Do not destroy the whole session at login, providers may need to store
data before the user is authenticate and retrieve it later if
authentication ws successful.
Signed-off-by: Simo Sorce <simo@redhat.com>
Diffstat (limited to 'ipsilon/login')
-rwxr-xr-x | ipsilon/login/common.py | 24 |
1 files changed, 16 insertions, 8 deletions
diff --git a/ipsilon/login/common.py b/ipsilon/login/common.py index 4888060..5879fda 100755 --- a/ipsilon/login/common.py +++ b/ipsilon/login/common.py @@ -37,21 +37,29 @@ class LoginManagerBase(PluginObject): def auth_successful(self, username): # save ref before calling UserSession login() as it # may regenerate the session - ref = cherrypy.config.get('base.mount', "") + '/' - if 'referral' in cherrypy.session: - ref = cherrypy.session['referral'] + session = UserSession() + ref = session.get_data('login', 'Return') + if not ref: + ref = cherrypy.config.get('base.mount', "") + '/' - UserSession().login(username) + session.login(username) raise cherrypy.HTTPRedirect(ref) def auth_failed(self): - # Just make sure we destroy the session - UserSession().logout(None) - + # try with next module if self.next_login: return self.redirect_to_path(self.next_login.path) - ref = cherrypy.config.get('base.mount', "") + '/unauthorized' + # return to the caller if any + session = UserSession() + ref = session.get_data('login', 'Return') + + # otherwise destroy session and return error + if not ref: + ref = cherrypy.config.get('base.mount', "") + '/unauthorized' + # Just make sure we destroy the session + session.logout(None) + raise cherrypy.HTTPRedirect(ref) |