Beispiel #1
0
async def get_session_id(request):
    if 'X-Hail-Internal-Authorization' in request.headers:
        return maybe_parse_bearer_header(
            request.headers['X-Hail-Internal-Authorization'])

    if 'Authorization' in request.headers:
        return maybe_parse_bearer_header(request.headers['Authorization'])

    session = await aiohttp_session.get_session(request)
    return session.get('session_id')
Beispiel #2
0
def authorization_token(request):
    auth_header = request.headers.get('Authorization')
    if not auth_header:
        return None
    session_id = maybe_parse_bearer_header(auth_header)
    if not session_id:
        return None
    return session_id
Beispiel #3
0
async def userinfo(request):
    if 'Authorization' not in request.headers:
        log.info('Authorization not in request.headers')
        raise web.HTTPUnauthorized()

    auth_header = request.headers['Authorization']
    session_id = maybe_parse_bearer_header(auth_header)
    if not session_id:
        log.info('Bearer not in Authorization header')
        raise web.HTTPUnauthorized()

    return web.json_response(await get_userinfo(request, session_id))