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


Python KEYS.load_dict方法代码示例

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


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

示例1: test_loads_1

# 需要导入模块: from jwkest.jwk import KEYS [as 别名]
# 或者: from jwkest.jwk.KEYS import load_dict [as 别名]
def test_loads_1():
    jwk = {
        "keys": [
            {
                "kty": "RSA",
                "use": "foo",
                "e": "AQAB",
                "n": "wf-wiusGhA-gleZYQAOPQlNUIucPiqXdPVyieDqQbXXOPBe3nuggtVzeq7pVFH1dZz4dY2Q2LA5DaegvP8kRvoSB_87ds3dy3Rfym_GUSc5B0l1TgEobcyaep8jguRoHto6GWHfCfKqoUYZq4N8vh4LLMQwLR6zi6Jtu82nB5k8",
                "kid": "1",
            },
            {
                "kty": "RSA",
                "use": "bar",
                "e": "AQAB",
                "n": "wf-wiusGhA-gleZYQAOPQlNUIucPiqXdPVyieDqQbXXOPBe3nuggtVzeq7pVFH1dZz4dY2Q2LA5DaegvP8kRvoSB_87ds3dy3Rfym_GUSc5B0l1TgEobcyaep8jguRoHto6GWHfCfKqoUYZq4N8vh4LLMQwLR6zi6Jtu82nB5k8",
                "kid": "2",
            },
        ]
    }

    keys = KEYS()
    keys.load_dict(jwk)
    print(keys)
    assert len(keys) == 2
    assert _eq(keys.kids(), ["1", "2"])
开发者ID:techguy613,项目名称:pyjwkest,代码行数:27,代码来源:test_2_jwk.py

示例2: _get_keys

# 需要导入模块: from jwkest.jwk import KEYS [as 别名]
# 或者: from jwkest.jwk.KEYS import load_dict [as 别名]
 def _get_keys(self):
     """
     Get public key from discovery.
     """
     request = self.factory.get(reverse('oidc_provider:jwks'))
     response = JwksView.as_view()(request)
     jwks_dic = json.loads(response.content.decode('utf-8'))
     SIGKEYS = KEYS()
     SIGKEYS.load_dict(jwks_dic)
     return SIGKEYS
开发者ID:RaduGatej,项目名称:django-oidc-provider,代码行数:12,代码来源:test_token_endpoint.py

示例3: test_keys

# 需要导入模块: from jwkest.jwk import KEYS [as 别名]
# 或者: from jwkest.jwk.KEYS import load_dict [as 别名]
def test_keys():
    keyl = KEYS()
    keyl.load_dict(JWKS)

    assert len(keyl) == 3
    print(keyl.keys())
    print(keyl.dump_jwks())
    assert _eq(keyl.keys(), ['RSA', 'oct', 'EC'])
    assert len(keyl['rsa']) == 1
    assert len(keyl['oct']) == 1
    assert len(keyl['ec']) == 1
开发者ID:dallerbarn,项目名称:pyjwkest,代码行数:13,代码来源:test_2_jwk.py

示例4: test_keys

# 需要导入模块: from jwkest.jwk import KEYS [as 别名]
# 或者: from jwkest.jwk.KEYS import load_dict [as 别名]
def test_keys():
    keyl = KEYS()
    keyl.load_dict(JWKS)

    assert len(keyl) == 3
    print(keyl.keys())
    print(keyl.dump_jwks())
    assert _eq(keyl.key_types(), ["RSA", "oct", "EC"])
    assert len(keyl["rsa"]) == 1
    assert len(keyl["oct"]) == 1
    assert len(keyl["ec"]) == 1
开发者ID:techguy613,项目名称:pyjwkest,代码行数:13,代码来源:test_2_jwk.py

示例5: test_loads_0

# 需要导入模块: from jwkest.jwk import KEYS [as 别名]
# 或者: from jwkest.jwk.KEYS import load_dict [as 别名]
def test_loads_0():
    keys = KEYS()
    keys.load_dict(JWK)
    assert len(keys) == 1
    key = keys["rsa"][0]
    assert key.kid == 'abc'
    assert key.kty == 'RSA'

    _ckey = pem_cert2rsa(CERT)

    print(key)
    assert key.n == _ckey.n
    assert key.e == _ckey.e
开发者ID:dallerbarn,项目名称:pyjwkest,代码行数:15,代码来源:test_2_jwk.py

示例6: test_sign_2

# 需要导入模块: from jwkest.jwk import KEYS [as 别名]
# 或者: from jwkest.jwk.KEYS import load_dict [as 别名]
def test_sign_2():
    keyset = {"keys": [
        {"alg": "RS512",
         "kty": "RSA",
         "d": "ckLyXxkbjC4szg8q8G0ERBZV-9CszeOxpRtx1KM9BLl0Do3li_Km2vvFvfXJ7MxQpiZ18pBoCcyYQEU262ym8wI22JWMPrZe24HCNxLxqzr_JEuBhpKFxQF6EFTSvJEJD1FkoTuCTvN0zD7YHGaJQG6JzVEuFUY3ewxjH0FYNa_ppTnPP3LC-T9u_GX9Yqyuw1KOYoHSzhWSWQOeAgs4dH9-iAxN1wdZ6eH1jFWAs43svk_rhwdgyJMlihFtV9MAInBlfi_Zu8wRVhVl5urkJrLf0tGFnMbnzb6dYSlUXxEYClpY12W7kXW9aePDqkCwI4oZyxmOmgq4hunKGR1dAQ",
         "e": "AQAB",
         "use": "sig",
         "kid": "af22448d-4c7b-464d-b63a-f5bd90f6d7d1",
         "n": "o9g8DpUwBW6B1qmcm-TfEh4rNX7n1t38jdo4Gkl_cI3q--7n0Blg0kN88LHZvyZjUB2NhBdFYNxMP8ucy0dOXvWGWzaPmGnq3DM__lN8P4WjD1cCTAVEYKawNBAmGKqrFj1SgpPNsSqiqK-ALM1w6mZ-QGimjOgwCyJy3l9lzZh5D8tKnS2t1pZgE0X5P7lZQWHYpHPqp4jKhETzrCpPGfv0Rl6nmmjp7NlRYBkWKf_HEKE333J6M039m2FbKgxrBg3zmYYpmHuMzVgxxb8LSiv5aqyeyJjxM-YDUAgNQBfKNhONqXyu9DqtSprNkw6sqmuxK0QUVrNYl3b03PgS5Q"
        }]}

    keys = KEYS()
    keys.load_dict(keyset)
    jws = JWS("payload", alg="RS512")
    jws.sign_compact(keys=keys)
开发者ID:juanifioren,项目名称:pyjwkest,代码行数:17,代码来源:test_3_jws.py

示例7: test_idtoken_sign_validation

# 需要导入模块: from jwkest.jwk import KEYS [as 别名]
# 或者: from jwkest.jwk.KEYS import load_dict [as 别名]
    def test_idtoken_sign_validation(self):
        """
        We MUST validate the signature of the ID Token according to JWS
        using the algorithm specified in the alg Header Parameter of
        the JOSE Header.
        """
        # Get public key from discovery.
        request = self.factory.get(reverse('oidc_provider:jwks'))
        response = JwksView.as_view()(request)
        jwks_dic = json.loads(response.content.decode('utf-8'))
        SIGKEYS = KEYS()
        SIGKEYS.load_dict(jwks_dic)
        RSAKEYS = [ k for k in SIGKEYS if k.kty == 'RSA' ]

        code = self._create_code()

        post_data = self._post_data(code=code.code)

        response = self._post_request(post_data)
        response_dic = json.loads(response.content.decode('utf-8'))

        id_token = JWS().verify_compact(response_dic['id_token'].encode('utf-8'), RSAKEYS)
开发者ID:robosung,项目名称:django-oidc-provider,代码行数:24,代码来源:test_token_endpoint.py

示例8: test_loads_1

# 需要导入模块: from jwkest.jwk import KEYS [as 别名]
# 或者: from jwkest.jwk.KEYS import load_dict [as 别名]
def test_loads_1():
    jwk = {
        "keys": [
            {
                'kty': 'RSA',
                'use': 'foo',
                'e': 'AQAB',
                "n": 'wf-wiusGhA-gleZYQAOPQlNUIucPiqXdPVyieDqQbXXOPBe3nuggtVzeq7pVFH1dZz4dY2Q2LA5DaegvP8kRvoSB_87ds3dy3Rfym_GUSc5B0l1TgEobcyaep8jguRoHto6GWHfCfKqoUYZq4N8vh4LLMQwLR6zi6Jtu82nB5k8',
                'kid': "1"
            }, {
                'kty': 'RSA',
                'use': 'bar',
                'e': 'AQAB',
                "n": 'wf-wiusGhA-gleZYQAOPQlNUIucPiqXdPVyieDqQbXXOPBe3nuggtVzeq7pVFH1dZz4dY2Q2LA5DaegvP8kRvoSB_87ds3dy3Rfym_GUSc5B0l1TgEobcyaep8jguRoHto6GWHfCfKqoUYZq4N8vh4LLMQwLR6zi6Jtu82nB5k8',
                'kid': "2"
            }
        ]
    }

    keys = KEYS()
    keys.load_dict(jwk)
    print(keys)
    assert len(keys) == 2
    assert _eq(keys.kids(), ['1', '2'])
开发者ID:dallerbarn,项目名称:pyjwkest,代码行数:26,代码来源:test_2_jwk.py

示例9: test_thumbprint

# 需要导入模块: from jwkest.jwk import KEYS [as 别名]
# 或者: from jwkest.jwk.KEYS import load_dict [as 别名]
def test_thumbprint():
    keyl = KEYS()
    keyl.load_dict(JWKS)
    for key in keyl:
        txt = key.thumbprint("SHA-256")
        assert b64e(txt) in EXPECTED
开发者ID:techguy613,项目名称:pyjwkest,代码行数:8,代码来源:test_2_jwk.py

示例10: KEYS

# 需要导入模块: from jwkest.jwk import KEYS [as 别名]
# 或者: from jwkest.jwk.KEYS import load_dict [as 别名]
        "kty": "oct",
        "use": "sig"
    },
    {
        "kty": "EC",
        "kid": "7snis",
        "use": "sig",
        "x": "q0WbWhflRbxyQZKFuQvh2nZvg98ak-twRoO5uo2L7Po",
        "y": "GOd2jL_6wa0cfnyA0SmEhok9fkYEnAHFKLLM79BZ8_E",
        "crv": "P-256"
    }
]}


SIGKEYS = KEYS()
SIGKEYS.load_dict(JWKS)

def test_1():
    claimset = {"iss": "joe",
                "exp": 1300819380,
                "http://example.com/is_root": True}

    _jws = JWS(claimset, cty="JWT")
    _jwt = _jws.sign_compact()

    _jr = JWS()
    _msg = _jr.verify_compact(_jwt, allow_none=True)
    print(_jr)
    assert _jr.jwt.headers["alg"] == 'none'
    assert _msg == claimset
开发者ID:otakup0pe,项目名称:pyjwkest,代码行数:32,代码来源:test_3_jws.py

示例11: test_pick

# 需要导入模块: from jwkest.jwk import KEYS [as 别名]
# 或者: from jwkest.jwk.KEYS import load_dict [as 别名]
def test_pick():
    keys = KEYS()
    keys.load_dict(JWK2)
    _jws = JWS("foobar", alg="RS256", kid="MnC_VZcATfM5pOYiJHMba9goEKY")
    _keys = _jws._pick_keys(keys, use="sig")
    assert len(_keys) == 1
开发者ID:jespino,项目名称:pyjwkest,代码行数:8,代码来源:test_3_jws.py

示例12: test_pick_wrong_alg

# 需要导入模块: from jwkest.jwk import KEYS [as 别名]
# 或者: from jwkest.jwk.KEYS import load_dict [as 别名]
def test_pick_wrong_alg():
    keys = KEYS()
    keys.load_dict(JWKS0)
    _jws = JWS("foobar", alg="RS256", kid="rsa1")  # should be RSA256
    _keys = _jws.pick_keys(keys, use="sig")
    assert len(_keys) == 0
开发者ID:rebeckag,项目名称:pyjwkest,代码行数:8,代码来源:test_3_jws.py

示例13: test_pick_no_use

# 需要导入模块: from jwkest.jwk import KEYS [as 别名]
# 或者: from jwkest.jwk.KEYS import load_dict [as 别名]
def test_pick_no_use():
    keys = KEYS()
    keys.load_dict(JWKS0)
    _jws = JWS("foobar", alg="RS256", kid="rsa1")
    _keys = _jws.pick_keys(keys, use="sig")
    assert len(_keys) == 1
开发者ID:techguy613,项目名称:pyjwkest,代码行数:8,代码来源:test_3_jws.py


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