コード例 #1
0
    def encode_token(self, token, client, access_token=None):
        assert isinstance(token, IDToken)
        assert isinstance(client, IClient)
        assert isinstance(access_token, (str, type(None)))

        jwkset = self.jwkset.copy()
        if access_token:
            jwkset.append(JWK.from_dict({
                'kty': 'oct',
                'k': access_token,
            }))

        jwt = JWT(jwkset)
        jws = jwt.encode(dict(alg=client.get_jws_alg()),
                         token.to_json().encode('utf8'))

        if not self.is_token_encryption_enabled:
            return jws

        jwe = jwt.encode(
            dict(alg=client.get_jwe_alg(), enc=client.get_jwe_enc(),
                 cty='JWT'), jws)
        return jwe
コード例 #2
0
ファイル: provider.py プロジェクト: GehirnInc/python-oidc
    def encode_token(self, token, client, access_token=None):
        assert isinstance(token, IDToken)
        assert isinstance(client, IClient)
        assert isinstance(access_token, (str, type(None)))

        jwkset = self.jwkset.copy()
        if access_token:
            jwkset.append(JWK.from_dict({
                'kty': 'oct',
                'k': access_token,
            }))

        jwt = JWT(jwkset)
        jws = jwt.encode(dict(alg=client.get_jws_alg()),
                         token.to_json().encode('utf8'))

        if not self.is_token_encryption_enabled:
            return jws

        jwe = jwt.encode(dict(alg=client.get_jwe_alg(),
                              enc=client.get_jwe_enc(),
                              cty='JWT'),
                         jws)
        return jwe