当前位置: 首页>>代码示例>>Python>>正文


Python AccessTokenResponse.verify方法代码示例

本文整理汇总了Python中oic.oic.message.AccessTokenResponse.verify方法的典型用法代码示例。如果您正苦于以下问题:Python AccessTokenResponse.verify方法的具体用法?Python AccessTokenResponse.verify怎么用?Python AccessTokenResponse.verify使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在oic.oic.message.AccessTokenResponse的用法示例。


在下文中一共展示了AccessTokenResponse.verify方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: test_wrong_alg

# 需要导入模块: from oic.oic.message import AccessTokenResponse [as 别名]
# 或者: from oic.oic.message.AccessTokenResponse import verify [as 别名]
    def test_wrong_alg(self):
        idval = {'nonce': 'KUEYfRM2VzKDaaKD', 'sub': 'EndUserSubject',
                 'iss': 'https://alpha.cloud.nds.rub.de', 'exp': 1420823073,
                 'iat': 1420822473, 'aud': 'TestClient'}
        idts = IdToken(**idval)
        key = SYMKey(key="TestPassword")
        _signed_jwt = idts.to_jwt(key=[key], algorithm="HS256")

        _info = {"access_token": "accessTok", "id_token": _signed_jwt,
                 "token_type": "Bearer", "expires_in": 3600}

        at = AccessTokenResponse(**_info)
        with pytest.raises(WrongSigningAlgorithm):
            at.verify(key=[key], algs={"sign": "HS512"})
开发者ID:joostd,项目名称:pyoidc,代码行数:16,代码来源:test_oic_message.py

示例2: test_make_id_token

# 需要导入模块: from oic.oic.message import AccessTokenResponse [as 别名]
# 或者: from oic.oic.message.AccessTokenResponse import verify [as 别名]
    def test_make_id_token(self):
        self.srv.keyjar["http://oic.example/rp"] = KC_RSA

        session = {"sub": "user0",
                   "client_id": "http://oic.example/rp"}
        issuer = "http://oic.example/idp"
        code = "abcdefghijklmnop"
        _idt = self.srv.make_id_token(session, loa="2", issuer=issuer,
                                      code=code, access_token="access_token")

        algo = "RS256"
        ckey = self.srv.keyjar.get_signing_key(alg2keytype(algo),
                                               session["client_id"])
        _signed_jwt = _idt.to_jwt(key=ckey, algorithm="RS256")

        idt = IdToken().from_jwt(_signed_jwt, keyjar=self.srv.keyjar)
        _jwt = JWT().unpack(_signed_jwt)

        lha = left_hash(code.encode("utf-8"),
                        func="HS" + _jwt.headers["alg"][-3:])
        assert lha == idt["c_hash"]

        atr = AccessTokenResponse(id_token=_signed_jwt,
                                  access_token="access_token",
                                  token_type="Bearer")
        atr["code"] = code
        assert atr.verify(keyjar=self.srv.keyjar)
开发者ID:StudienprojektUniTrier,项目名称:Authorization-Server,代码行数:29,代码来源:test_oic.py

示例3: make_refresh_request

# 需要导入模块: from oic.oic.message import AccessTokenResponse [as 别名]
# 或者: from oic.oic.message.AccessTokenResponse import verify [as 别名]
 def make_refresh_request(self, refresh_token):
     request_args = {
         'grant_type': 'refresh_token',
         'refresh_token': refresh_token,
     }
     resp = self.app.test_client().post('/token', data=request_args, headers=self.create_basic_auth_header())
     assert resp.status_code == 200
     token_response = AccessTokenResponse().from_json(resp.data.decode('utf-8'))
     assert token_response.verify()
     return token_response
开发者ID:SUNET,项目名称:se-leg-op,代码行数:12,代码来源:test_app.py

示例4: test_faulty_idtoken

# 需要导入模块: from oic.oic.message import AccessTokenResponse [as 别名]
# 或者: from oic.oic.message.AccessTokenResponse import verify [as 别名]
    def test_faulty_idtoken(self):
        idval = {'nonce': 'KUEYfRM2VzKDaaKD', 'sub': 'EndUserSubject',
                 'iss': 'https://alpha.cloud.nds.rub.de', 'exp': 1420823073,
                 'iat': 1420822473, 'aud': 'TestClient'}
        idts = IdToken(**idval)
        key = SYMKey(key="TestPassword")
        _signed_jwt = idts.to_jwt(key=[key], algorithm="HS256")

        # Mess with the signed id_token
        p = _signed_jwt.split(".")
        p[2] = "aaa"
        _faulty_signed_jwt = ".".join(p)

        _info = {"access_token": "accessTok", "id_token": _faulty_signed_jwt,
                 "token_type": "Bearer", "expires_in": 3600}

        at = AccessTokenResponse(**_info)
        with pytest.raises(BadSignature):
            at.verify(key=[key])
开发者ID:joostd,项目名称:pyoidc,代码行数:21,代码来源:test_oic_message.py

示例5: make_code_exchange_request

# 需要导入模块: from oic.oic.message import AccessTokenResponse [as 别名]
# 或者: from oic.oic.message.AccessTokenResponse import verify [as 别名]
 def make_code_exchange_request(self, code):
     request_args = {
         'grant_type': 'authorization_code',
         'code': code,
         'redirect_uri': TEST_REDIRECT_URI
     }
     resp = self.app.test_client().post('/token', data=request_args, headers=self.create_basic_auth_header())
     assert resp.status_code == 200
     token_response = AccessTokenResponse().from_json(resp.data.decode('utf-8'))
     assert token_response.verify(key=[self.app.provider.signing_key])
     return token_response
开发者ID:SUNET,项目名称:se-leg-op,代码行数:13,代码来源:test_app.py

示例6: test_make_id_token

# 需要导入模块: from oic.oic.message import AccessTokenResponse [as 别名]
# 或者: from oic.oic.message.AccessTokenResponse import verify [as 别名]
def test_make_id_token():
    srv = Server(KEYS)
    session = {"user_id": "user0", "client_id": "http://oic.example/rp"}
    issuer = "http://oic.example/idp"
    code = "abcdefghijklmnop"
    idt_jwt = srv.make_id_token(session, loa="2", issuer=issuer, code=code, access_token="access_token")

    jwt_keys = srv.keystore.get_keys("ver", owner=None)
    idt = IdToken().from_jwt(idt_jwt, key=jwt_keys)
    print idt
    header = unpack(idt_jwt)

    lha = left_hash(code, func="HS" + header[0]["alg"][-3:])
    assert lha == idt["c_hash"]

    atr = AccessTokenResponse(id_token=idt_jwt, access_token="access_token", token_type="Bearer")
    atr["code"] = code
    assert atr.verify(key=jwt_keys)
开发者ID:imsoftware,项目名称:pyoidc,代码行数:20,代码来源:test_oic.py


注:本文中的oic.oic.message.AccessTokenResponse.verify方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。