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


Python sdb.SessionDB类代码示例

本文整理汇总了Python中oic.utils.sdb.SessionDB的典型用法代码示例。如果您正苦于以下问题:Python SessionDB类的具体用法?Python SessionDB怎么用?Python SessionDB使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


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

示例1: test_type_and_key

def test_type_and_key():
    sdb = SessionDB()
    sid = sdb.token.key(areq=AREQ)
    code = sdb.token(sid=sid)
    print sid
    part = sdb.token.type_and_key(code)
    print part
    assert part[0] == "A"
    assert part[1] == sid
开发者ID:asheidan,项目名称:pyoidc,代码行数:9,代码来源:test_sdb.py

示例2: test_sub_to_authn_event

def test_sub_to_authn_event():
    sdb = SessionDB(BASE_URL)
    ae2 = AuthnEvent("sub")
    sid = sdb.create_authz_session(ae2, AREQ)
    sub = sdb.do_sub(sid)

    # given the sub find out weather the authn event is still valid

    sids = sdb.sub2sid[sub]
    ae = sdb[sids[0]]["authn_event"]
    assert ae.valid()
开发者ID:takehikokodama,项目名称:pyoidc,代码行数:11,代码来源:test_sdb.py

示例3: test_sub_to_authn_event

def test_sub_to_authn_event():
    sdb = SessionDB(BASE_URL)
    ae2 = AuthnEvent("sub", time_stamp=time.time())
    sid = sdb.create_authz_session(ae2, AREQ)
    sub = sdb.do_sub(sid)

    # given the sub find out weather the authn event is still valid

    sids = sdb.get_sids_by_sub(sub)
    ae = sdb[sids[0]]["authn_event"]
    assert ae.valid()
开发者ID:dallerbarn,项目名称:pyoidc,代码行数:11,代码来源:test_sdb.py

示例4: test_new_token

def test_new_token():
    sdb = SessionDB()
    sid = sdb.token.key(areq=AREQ)
    assert len(sid) == 28

    code2 = sdb.token('T', sid=sid)
    assert len(sid) == 28

    code3 = sdb.token(ttype="", prev=code2)
    assert code2 != code3
    
    sid2 = sdb.token.key(areq=AREQ, user="jones")
    assert len(sid2) == 28
    assert sid != sid2
开发者ID:asheidan,项目名称:pyoidc,代码行数:14,代码来源:test_sdb.py

示例5: test_setitem

def test_setitem():
    sdb = SessionDB()
    sid = sdb.token.key(areq=AREQ)
    code = sdb.token(sid=sid)

    sdb[sid] = {"indo": "china"}

    info = sdb[sid]
    assert info == {"indo": "china"}

    info = sdb[code]
    assert info == {"indo": "china"}

    raises(KeyError, 'sdb["abcdefghijklmnop"]')
开发者ID:asheidan,项目名称:pyoidc,代码行数:14,代码来源:test_sdb.py

示例6: __init__

 def __init__(self, jwt_keys=None, name=""):
     Server.__init__(self, jwt_keys=jwt_keys)
     self.sdb = SessionDB()
     self.name = name
     self.client = {}
     self.registration_expires_in = 3600
     self.host = ""
开发者ID:imsoftware,项目名称:pyoidc,代码行数:7,代码来源:fakeoicsrv.py

示例7: test_refresh_token

def test_refresh_token():
    sdb = SessionDB()
    sid = sdb.create_authz_session("user_id", AREQ)
    grant = sdb[sid]["code"]
    _dict = sdb.update_to_token(grant)
    dict1 = _dict.copy()

    rtoken = _dict["refresh_token"]
    time.sleep(1)
    dict2 = sdb.refresh_token(rtoken)
    print dict2
    
    assert dict1["issued"] != dict2["issued"]
    assert dict1["access_token"] != dict2["access_token"]

    raises(Exception, 'sdb.refresh_token(dict2["access_token"])')
开发者ID:asheidan,项目名称:pyoidc,代码行数:16,代码来源:test_sdb.py

示例8: test_refresh_token

def test_refresh_token():
    sdb = SessionDB(BASE_URL)
    ae = AuthnEvent("sub")
    sid = sdb.create_authz_session(ae, AREQ)
    grant = sdb[sid]["code"]
    _dict = sdb.upgrade_to_token(grant)
    dict1 = _dict.copy()

    rtoken = _dict["refresh_token"]
    time.sleep(1)
    dict2 = sdb.refresh_token(rtoken)
    print dict2
    
    assert dict1["token_expires_at"] != dict2["token_expires_at"]
    assert dict1["access_token"] != dict2["access_token"]

    raises(Exception, 'sdb.refresh_token(dict2["access_token"])')
开发者ID:takehikokodama,项目名称:pyoidc,代码行数:17,代码来源:test_sdb.py

示例9: __init__

 def __init__(self, name=""):
     Server.__init__(self)
     self.sdb = SessionDB()
     self.name = name
     self.client = {}
     self.registration_expires_in = 3600
     self.host = ""
     self.webfinger = WebFinger()
开发者ID:HaToHo,项目名称:pyoidc,代码行数:8,代码来源:fakeoicsrv.py

示例10: test_create_authz_session

def test_create_authz_session():
    sdb = SessionDB()
    sid = sdb.create_authz_session("user_id", AREQ)

    info = sdb[sid]
    print info
    assert info["oauth_state"] == "authz"

    sdb = SessionDB()
    # Missing nonce property
    sid = sdb.create_authz_session("user_id", OAUTH2_AREQ)
    info = sdb[sid]
    print info
    assert info["oauth_state"] == "authz"

    sid2 = sdb.create_authz_session("user_id", AREQN)

    info = sdb[sid2]
    print info
    assert info["nonce"] == "something"

    sid3 = sdb.create_authz_session("user_id", AREQN, id_token="id_token")

    info = sdb[sid3]
    print info
    assert info["id_token"] == "id_token"

    sid4 = sdb.create_authz_session("user_id", AREQN, oidreq=OIDR)

    info = sdb[sid4]
    print info
    assert "id_token" not in info
    assert "oidreq" in info
开发者ID:asheidan,项目名称:pyoidc,代码行数:33,代码来源:test_sdb.py

示例11: __init__

 def __init__(self, name=""):
     Server.__init__(self)
     self.sdb = SessionDB(name)
     self.name = name
     self.client = {}
     self.registration_expires_in = 3600
     self.host = ""
     self.webfinger = WebFinger()
     self.userinfo_signed_response_alg = ""
开发者ID:dallerbarn,项目名称:pyoidc,代码行数:9,代码来源:mitmsrv.py

示例12: test_create_authz_session_with_sector_id

def test_create_authz_session_with_sector_id():
    sdb = SessionDB(seed="foo")
    sid5 = sdb.create_authz_session("user_id", AREQN, oidreq=OIDR,
                                    sector_id="http://example.com/")

    info_1 = sdb[sid5]
    print info_1
    assert "id_token" not in info_1
    assert "oidreq" in info_1
    assert info_1["user_id"] != "user_id"

    sid6 = sdb.create_authz_session("user_id", AREQN, oidreq=OIDR,
                                    sector_id="http://example.org/")

    info_2 = sdb[sid6]
    print info_2
    assert info_2["user_id"] != "user_id"
    assert info_2["user_id"] != info_1["user_id"]
开发者ID:imsoftware,项目名称:pyoidc,代码行数:18,代码来源:test_sdb.py

示例13: create_sdb

    def create_sdb(self):
        kb = KeyBundle(JWKS["keys"])
        kj = KeyJar()
        kj.issuer_keys[''] = [kb]

        self.sdb = SessionDB(
            "https://example.com/",
            token_factory=JWTToken('T', {'code': 3600, 'token': 900},
                                   'https://example.com/as', 'RS256', kj),
            refresh_token_factory=JWTToken(
                'R', {'': 24*3600}, 'https://example.com/as', 'RS256', kj)
        )
开发者ID:htobenothing,项目名称:pyoidc,代码行数:12,代码来源:test_token.py

示例14: create_sdb

    def create_sdb(self):
        kb = KeyBundle(JWKS["keys"])
        kj = KeyJar()
        kj.issuer_keys[""] = [kb]

        self.sdb = SessionDB(
            "https://example.com/",
            token_factory=JWTToken(
                "T", keyjar=kj, lifetime={"code": 3600, "token": 900}, iss="https://example.com/as", sign_alg="RS256"
            ),
            refresh_token_factory=JWTToken("R", keyjar=kj, lifetime={"": 24 * 3600}, iss="https://example.com/as"),
        )
开发者ID:flibbertigibbet,项目名称:pyoidc,代码行数:12,代码来源:test_token.py

示例15: test_server_authorization_endpoint_id_token

def test_server_authorization_endpoint_id_token():
    provider = provider_init

    bib = {"scope": ["openid"],
           "state": "id-6da9ca0cc23959f5f33e8becd9b08cae",
           "redirect_uri": "http://localhost:8087/authz",
           "response_type": ["code", "id_token"],
           "client_id": "a1b2c3",
           "nonce": "Nonce",
           "prompt": ["none"]}

    req = AuthorizationRequest(**bib)
    AREQ = AuthorizationRequest(response_type="code",
                                client_id="client_1",
                                redirect_uri="http://example.com/authz",
                                scope=["openid"], state="state000")

    sdb = SessionDB()
    sid = sdb.create_authz_session("username", AREQ)

    _info = sdb[sid]
    _user_info = IdToken(iss="https://foo.example.om", sub="foo",
                         aud=bib["client_id"], exp=epoch_in_a_while(minutes=10),
                        acr="2", nonce=bib["nonce"])

    print provider.keyjar.issuer_keys
    print _user_info.to_dict()
    idt = provider.id_token_as_signed_jwt(_info, access_token="access_token",
                                          user_info=_user_info)

    req["id_token"] = idt

    environ = BASE_ENVIRON.copy()
    environ["QUERY_STRING"] = req.to_urlencoded()

    resp = provider.authorization_endpoint(environ, start_response)

    print resp
    line = resp[0]
    assert "error=login_required" in line
开发者ID:asheidan,项目名称:pyoidc,代码行数:40,代码来源:test_oic_provider.py


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