|
def check_for_existing_session(self): |
|
log.critical("in check_for_existing_session") |
|
#print dir(session) |
|
#print session.keys() |
|
#print session["_id"] |
|
if "userid" in session: |
|
log.critical("userid in session") |
|
return dict(logged_in=True, username=session['username'], institution=session['institution_name']) |
|
else: |
|
# check if cookie set |
|
log.critical("userid not in session") |
|
try: |
|
log.critical(request.cookies.keys()) |
|
cache_key = request.cookies[str(app_globals.LOGIN_CACHE_COOKIE)] |
|
log.critcal("pulled cookie: " + cache_key) |
|
# the cookie value is the key for the memcache, so check if valid |
|
try: |
|
auth = authenticate.memcache_check(cache_key) |
|
log.critical("cache value: " + auth) |
|
if auth is not None: |
|
self._session_save(auth) |
|
return dict(success=True, url=app_globals.navigation_urls['LOGIN_SUCCESS_URL']) |
|
else: |
|
return dict(success=False, message='Invalid username/password, or access denied.') |
|
except: |
|
# not in cache, fail the authenticated login |
|
log.critical("cache miss") |
|
return dict(logged_in=False, url="/login.html") |
|
except: |
|
log.critical("cookie miss") |
|
return dict(logged_in=False, url="/login.html") |
|
# yes, check if memcache is set |
|
|
|
#else: |
|
# log.critical("not in session and no cookie") |
|
# return dict(logged_in=False, url="/login.html") |
|
|
|
|
|
|
|
produced the following output after whacking the session cookie |
|
2010-12-13 15:50:16,929 CRITI [sharedshelf.controllers.login] in check_for_existing_session |
|
2010-12-13 15:50:16,930 CRITI [sharedshelf.controllers.login] userid not in session |
|
2010-12-13 15:50:16,930 CRITI [sharedshelf.controllers.login] ['hudson_auto_refresh', 'AS_SSO', 'f47e1843c8bb25527780def85e354b07'] |
|
2010-12-13 15:50:16,930 CRITI [sharedshelf.controllers.login] cookie miss |
|
|
|
|
|
The AS_SSO cookie is in the list, just having problems retrieving it. |