src/fedoidcmsg/utils.py
def verify_request_signed_by_signing_keys(smsreq):
    """
    Verify that a JWT is signed with a key that is inside the JWT.
    
    :param smsreq: Signed Metadata Statement signing request
    :return: Dictionary containing 'ms' (the signed request) and 'iss' (the
        issuer of the JWT).
    """

    _jws = factory(smsreq)
    _json = _jws.jwt.part[1]
    _body = json.loads(as_unicode(_json))
    iss = _body['iss']
    _jwks = _body['signing_keys']

    _kj = jwks_to_keyjar(_jwks, iss)

    try:
        _kid = _jws.jwt.headers['kid']
    except KeyError:
        _keys = _kj.get_signing_key(owner=iss)
    else:
        _keys = _kj.get_signing_key(owner=iss, kid=_kid)

    _ver = _jws.verify_compact(smsreq, _keys)
    # remove the JWT specific claims
    for k in JsonWebToken.c_param.keys():
        try:
            del _ver[k]
        except KeyError:
            pass
    try:
        del _ver['kid']
    except KeyError:
        pass

    return {'ms': MetadataStatement(**_ver), 'iss': iss}
def verify_request_signed_by_signing_keys(smsreq):
    """
    Verify that a JWT is signed with a key that is inside the JWT.
    
    :param smsreq: Signed Metadata Statement signing request
    :return: Dictionary containing 'ms' (the signed request) and 'iss' (the
        issuer of the JWT).
    """

    _jws = factory(smsreq)
    _json = _jws.jwt.part[1]
    _body = json.loads(as_unicode(_json))
    iss = _body['iss']
    _jwks = _body['signing_keys']

    _kj = jwks_to_keyjar(_jwks, iss)

    try:
        _kid = _jws.jwt.headers['kid']
    except KeyError:
        _keys = _kj.get_signing_key(owner=iss)
    else:
        _keys = _kj.get_signing_key(owner=iss, kid=_kid)

    _ver = _jws.verify_compact(smsreq, _keys)
    # remove the JWT specific claims
    for k in JsonWebToken.c_param.keys():
        try:
            del _ver[k]
        except KeyError:
            pass
    try:
        del _ver['kid']
    except KeyError:
        pass

    return {'ms': MetadataStatement(**_ver), 'iss': iss}
def verify_request_signed_by_signing_keys ( smsreq ) : _jws = factory ( smsreq ) _json = _jws . jwt . part [ 1 ] _body = json . loads ( as_unicode ( _json ) ) iss = _body [ 'iss' ] _jwks = _body [ 'signing_keys' ] _kj = jwks_to_keyjar ( _jwks , iss ) try : _kid = _jws . jwt . headers [ 'kid' ] except KeyError : _keys = _kj . get_signing_key ( owner = iss ) else : _keys = _kj . get_signing_key ( owner = iss , kid = _kid ) _ver = _jws . verify_compact ( smsreq , _keys ) # remove the JWT specific claims for k in JsonWebToken . c_param . keys ( ) : try : del _ver [ k ] except KeyError : pass try : del _ver [ 'kid' ] except KeyError : pass return { 'ms' : MetadataStatement ( * * _ver ) , 'iss' : iss }
Verify that a JWT is signed with a key that is inside the JWT.
    
    :param smsreq: Signed Metadata Statement signing request
    :return: Dictionary containing 'ms' (the signed request) and 'iss' (the
        issuer of the JWT).
Verify that a JWT is signed with a key that is inside the JWT . : param smsreq : Signed Metadata Statement signing request : return : Dictionary containing ms ( the signed request ) and iss ( the issuer of the JWT ) .