Esempio n. 1
0
 def _load_signed_jwt(txt):
     signing_input, crypto_segment = txt.rsplit('.', 1)
     header, claims, signing_input, signature = jws._load(txt)
     readable = {
         'protected': header,
         'payload': json.loads(claims.decode('utf-8')),
         'signature': crypto_segment
     }
     return readable
Esempio n. 2
0
    def test_add_headers(self, payload):

        additional_headers = {'test': 'header'}

        expected_headers = {
            'test': 'header',
            'alg': 'HS256',
            'typ': 'JWT',
        }

        token = jws.sign(payload, 'secret', headers=additional_headers)
        header, payload, signing_input, signature = jws._load(token)
        assert expected_headers == header
Esempio n. 3
0
    def test_add_headers(self, payload):

        additional_headers = {"test": "header"}

        expected_headers = {
            "test": "header",
            "alg": "HS256",
            "typ": "JWT",
        }

        token = jws.sign(payload, "secret", headers=additional_headers)
        header, payload, signing_input, signature = jws._load(token)
        assert expected_headers == header
Esempio n. 4
0
    def test_add_headers(self, payload):

        additional_headers = {
            'test': 'header'
        }

        expected_headers = {
            'test': 'header',
            'alg': 'HS256',
            'typ': 'JWT',
        }

        token = jws.sign(payload, 'secret', headers=additional_headers)
        header, payload, signing_input, signature = jws._load(token)
        assert expected_headers == header
Esempio n. 5
0
    def get_id(self, token_response):
        header, payload, signing_input, signature = jws._load(
            token_response.id_token)
        kid = header.get('kid')
        key = None
        for k in json.loads(self.keys).get('keys', {}):
            if k.get('kid', None) == kid:
                key = k

        return jwt.decode(
            token_response.id_token,
            key,
            algorithms=['RS256'],
            audience=self.client_id,
            issuer=self.issuer,
            options=dict(verify_at_hash=False),
        )