def do_auth_and_return(ctxt): log.debug('context: {}'.format(ctxt)) here = ctxt['path'] log.info("here will be {0}".format(here)) redirect_here = quote_plus(here) URS_URL = get_urs_url(ctxt, redirect_here) log.info("Redirecting for auth: {0}".format(URS_URL)) return Response(body='', status_code=302, headers={'Location': URS_URL})
def do_auth_and_return(ctxt): log.debug('context: {}'.format(ctxt)) here = ctxt['path'] if os.getenv('DOMAIN_NAME'): # Pop STAGE value off the request if we have a custom domain here = '/'.join([""]+here.split('/')[2:]) if here.startswith('/{}/'.format(STAGE)) else here log.info("here will be {0}".format(here)) redirect_here = quote_plus(here) URS_URL = get_urs_url(ctxt, redirect_here) log.info("Redirecting for auth: {0}".format(URS_URL)) return Response(body='', status_code=302, headers={'Location': URS_URL})
def root(): user_profile = False template_vars = {'title': 'Welcome'} cookievars = get_cookie_vars(app.current_request.headers) if cookievars: user_profile = get_session(cookievars['urs-user-id'], cookievars['urs-access-token']) if user_profile: if os.getenv('MATURITY', '') == 'DEV': template_vars['profile'] = user_profile else: template_vars['URS_URL'] = get_urs_url(app.current_request.context) headers = {'Content-Type': 'text/html'} return make_html_response(template_vars, headers, 200, 'root.html')
def logout(): cookievars = get_cookie_vars(app.current_request.headers) template_vars = {'title': 'Logged Out', 'URS_URL': get_urs_url(app.current_request.context)} if cookievars: user_id = cookievars['urs-user-id'] urs_access_token = cookievars['urs-access-token'] delete_session(user_id, urs_access_token) template_vars['contentstring'] = 'You are logged out.' else: template_vars['contentstring'] = 'No active login found.' headers = { 'Content-Type': 'text/html', } headers.update(make_set_cookie_headers('deleted', 'deleted', 'Thu, 01 Jan 1970 00:00:00 GMT', os.getenv('COOKIE_DOMAIN', ''))) return make_html_response(template_vars, headers, 200, 'root.html')
def root(): user_profile = False template_vars = {'title': 'Welcome'} cookievars = get_cookie_vars(app.current_request.headers) if cookievars: if os.getenv('JWT_COOKIENAME', 'asf-urs') in cookievars: # We have a JWT cookie user_profile = cookievars[os.getenv('JWT_COOKIENAME', 'asf-urs')] if user_profile: if os.getenv('MATURITY') == 'DEV': template_vars['profile'] = user_profile else: template_vars['URS_URL'] = get_urs_url(app.current_request.context) headers = {'Content-Type': 'text/html'} return make_html_response(template_vars, headers, 200, 'root.html')
def logout(): cookievars = get_cookie_vars(app.current_request.headers) template_vars = { 'title': 'Logged Out', 'URS_URL': get_urs_url(app.current_request.context) } if JWT_COOKIE_NAME in cookievars: template_vars['contentstring'] = 'You are logged out.' else: template_vars['contentstring'] = 'No active login found.' headers = { 'Content-Type': 'text/html', } headers.update( make_set_cookie_headers_jwt({}, 'Thu, 01 Jan 1970 00:00:00 GMT', os.getenv('COOKIE_DOMAIN', ''))) return make_html_response(template_vars, headers, 200, 'root.html')
def root(): user_profile = False template_vars = {'title': 'Welcome'} cookievars = get_cookie_vars(app.current_request.headers) if cookievars: if os.getenv('JWT_COOKIENAME','asf-urs') in cookievars: # this means our cookie is a jwt and we don't need to go digging in the session db user_profile = cookievars[os.getenv('JWT_COOKIENAME','asf-urs')] else: log.warning('jwt cookie not found, falling back to old style') user_profile = get_session(cookievars['urs-user-id'], cookievars['urs-access-token']) if user_profile: if os.getenv('MATURITY', '') == 'DEV': template_vars['profile'] = user_profile else: template_vars['URS_URL'] = get_urs_url(app.current_request.context) headers = {'Content-Type': 'text/html'} return make_html_response(template_vars, headers, 200, 'root.html')