def logout(self): config = cherrypy.request.app.config['filelocker'] orgConfig = get_config_dict_from_objects( session.query(ConfigParameter).filter( ConfigParameter.name.like('org_%')).all()) authType = session.query(ConfigParameter).filter( ConfigParameter.name == "auth_type").one().value if authType == "cas": from lib.CAS import CAS casUrl = session.query(ConfigParameter).filter( ConfigParameter.name == "cas_url").one().value casConnector = CAS(casUrl) casLogoutUrl = casConnector.logout_url( ) + "?redirectUrl=" + config['root_url'] + "/logout_cas" currentYear = datetime.date.today().year footerText = str( Template(file=get_template_file('footer_text.tmpl'), searchList=[locals(), globals()])) tpl = Template(file=get_template_file('cas_logout.tmpl'), searchList=[locals(), globals()]) cherrypy.session['user'], cherrypy.response.cookie['filelocker'][ 'expires'] = None, 0 return str(tpl) else: cherrypy.session['user'], cherrypy.response.cookie['filelocker'][ 'expires'] = None, 0 raise cherrypy.HTTPRedirect(config['root_url'] + '/login?msg=2')
def logout(self): config = cherrypy.request.app.config['filelocker'] orgConfig = get_config_dict_from_objects(session.query(ConfigParameter).filter(ConfigParameter.name.like('org_%')).all()) authType = session.query(ConfigParameter).filter(ConfigParameter.name=="auth_type").one().value if authType == "cas": from lib.CAS import CAS casUrl = session.query(ConfigParameter).filter(ConfigParameter.name=="cas_url").one().value casConnector = CAS(casUrl) casLogoutUrl = casConnector.logout_url()+"?redirectUrl="+config['root_url']+"/logout_cas" currentYear = datetime.date.today().year footerText = str(Template(file=get_template_file('footer_text.tmpl'), searchList=[locals(),globals()])) tpl = Template(file=get_template_file('cas_logout.tmpl'), searchList=[locals(), globals()]) cherrypy.session['user'], cherrypy.response.cookie['filelocker']['expires'] = None, 0 return str(tpl) else: cherrypy.session['user'], cherrypy.response.cookie['filelocker']['expires'] = None, 0 raise cherrypy.HTTPRedirect(config['root_url']+'/login?msg=2')
except Exception, e: raise cherrypy.HTTPError( 500, "The server is having problems communicating with the database server. Please try again in a few minutes." ) else: pass else: authType = None try: authType = session.query(ConfigParameter).filter( ConfigParameter.name == "auth_type").one().value if authType == "cas": casUrl = session.query(ConfigParameter).filter( ConfigParameter.name == "cas_url").one().value casConnector = CAS(casUrl) if cherrypy.request.params.has_key("ticket"): valid_ticket, userId = casConnector.validate_ticket( rootURL, cherrypy.request.params['ticket']) if valid_ticket: currentUser = AccountService.get_user(userId, True) cherrypy.session['request-origin'] = str( os.urandom(32).encode('hex'))[0:32] if currentUser is None: currentUser = User(id=userId, display_name="Guest user", first_name="Unknown", last_name="Unknown") cherrypy.log.error( "[%s] [requires_login] [User authenticated, but not found in directory - installing with defaults]" % str(userId))
if not AccountService.user_has_permission(user, permissionId): raise cherrypy.HTTPError(403) except Exception, e: raise cherrypy.HTTPError( 500, "The server is having problems communicating with the database server. Please try again in a few minutes.", ) else: pass else: authType = None try: authType = session.query(ConfigParameter).filter(ConfigParameter.name == "auth_type").one().value if authType == "cas": casUrl = session.query(ConfigParameter).filter(ConfigParameter.name == "cas_url").one().value casConnector = CAS(casUrl) if cherrypy.request.params.has_key("ticket"): valid_ticket, userId = casConnector.validate_ticket(rootURL, cherrypy.request.params["ticket"]) if valid_ticket: currentUser = AccountService.get_user(userId, True) cherrypy.session["request-origin"] = str(os.urandom(32).encode("hex"))[0:32] if currentUser is None: currentUser = User( id=userId, display_name="Guest user", first_name="Unknown", last_name="Unknown" ) cherrypy.log.error( "[%s] [requires_login] [User authenticated, but not found in directory - installing with defaults]" % str(userId) ) AccountService.install_user(currentUser) currentUser = AccountService.get_user(currentUser.id, True) # To populate attributes