labpack/parsing/flask.py
def extract_session_details(request_headers, session_header, secret_key):

    '''
        a method to extract and validate jwt session token from request headers

    :param request_headers: dictionary with header fields from request
    :param session_header: string with name of session token header key
    :param secret_key: string with secret key to json web token encryption
    :return: dictionary with request details with session details or error coding
    '''

    session_details = {
        'error': '',
        'code': 200,
        'session': {}
    }

    if not session_header in request_headers.keys():
        session_details['error'] = '%s is missing.' % session_header
        session_details['code'] = 400
    else:
        import jwt
        session_token = request_headers[session_header]
        try:
            session_details['session'] = jwt.decode(session_token, secret_key)
        except jwt.DecodeError as err:
            session_details['error'] = 'Session token decoding error.'
            session_details['code'] = 400
        except jwt.ExpiredSignatureError as err:
            session_details['error'] = 'Session token has expired.'
            session_details['code'] = 400
        except Exception:
            session_details['error'] = 'Session token is invalid.'
            session_details['code'] = 400

    return session_details

        a method to extract and validate jwt session token from request headers

    :param request_headers: dictionary with header fields from request
    :param session_header: string with name of session token header key
    :param secret_key: string with secret key to json web token encryption
    :return: dictionary with request details with session details or error coding
    
a method to extract and validate jwt session token from request headers
a method to extract and validate jwt session token from request headers
def extract_session_details(request_headers, session_header, secret_key):
    session_details = {
        'error': '',
        'code': 200,
        'session': {}
    }
    if not session_header in request_headers.keys():
        session_details['error'] = '%s is missing.' % session_header
        session_details['code'] = 400
    else:
        import jwt
        session_token = request_headers[session_header]
        try:
            session_details['session'] = jwt.decode(session_token, secret_key)
        except jwt.DecodeError as err:
            session_details['error'] = 'Session token decoding error.'
            session_details['code'] = 400
        except jwt.ExpiredSignatureError as err:
            session_details['error'] = 'Session token has expired.'
            session_details['code'] = 400
        except Exception:
            session_details['error'] = 'Session token is invalid.'
            session_details['code'] = 400
    return session_details
def extract_session_details ( request_headers , session_header , secret_key ) : session_details = { 'error' : '' , 'code' : 200 , 'session' : { } } if not session_header in request_headers . keys ( ) : session_details [ 'error' ] = '%s is missing.' % session_header session_details [ 'code' ] = 400 else : import jwt session_token = request_headers [ session_header ] try : session_details [ 'session' ] = jwt . decode ( session_token , secret_key ) except jwt . DecodeError as err : session_details [ 'error' ] = 'Session token decoding error.' session_details [ 'code' ] = 400 except jwt . ExpiredSignatureError as err : session_details [ 'error' ] = 'Session token has expired.' session_details [ 'code' ] = 400 except Exception : session_details [ 'error' ] = 'Session token is invalid.' session_details [ 'code' ] = 400 return session_details
a method to extract and validate jwt session token from request headers
a method to extract and validate jwt session token from request headers
'''
        a method to extract and validate jwt session token from request headers

    :param request_headers: dictionary with header fields from request
    :param session_header: string with name of session token header key
    :param secret_key: string with secret key to json web token encryption
    :return: dictionary with request details with session details or error coding
    '''
dictionary with request details with session details or error coding
dictionary with request details with session details or error coding
request_headers
dictionary with header fields from request
dictionary with header fields from request
session_header
string with name of session token header key
string with name of session token header key
secret_key
string with secret key to json web token encryption
string with secret key to json web token encryption