本文整理汇总了Python中oic.oic.claims_provider.ClaimsClient.construct_UserClaimsRequest方法的典型用法代码示例。如果您正苦于以下问题:Python ClaimsClient.construct_UserClaimsRequest方法的具体用法?Python ClaimsClient.construct_UserClaimsRequest怎么用?Python ClaimsClient.construct_UserClaimsRequest使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类oic.oic.claims_provider.ClaimsClient
的用法示例。
在下文中一共展示了ClaimsClient.construct_UserClaimsRequest方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_srv2
# 需要导入模块: from oic.oic.claims_provider import ClaimsClient [as 别名]
# 或者: from oic.oic.claims_provider.ClaimsClient import construct_UserClaimsRequest [as 别名]
def test_srv2():
cc = ClaimsClient(client_id="client_1")
cc.client_secret = "hemlig"
req = cc.construct_UserClaimsRequest(
request_args={"sub": "diana", "claims_names": ["gender", "birthdate"]})
srv = ClaimsServer("pyoicserv", SessionDB("https://example.com"), CDB,
USERINFO, verify_client,
keyjar=KEYJAR, dist_claims_mode=ClaimsMode(USER2MODE))
srv.keyjar[""] = keybundle_from_local_file("%s/rsa.key" % BASE_PATH, "rsa", ["ver", "sig"])
assert srv
resp = srv.claims_endpoint(req.to_urlencoded(), "")
print resp.message
ucr = UserClaimsResponse().deserialize(resp.message, "json")
ucr.verify(keyjar=srv.keyjar)
print ucr
assert _eq(ucr["claims_names"], ["gender", "birthdate"])
assert "jwt" in ucr
示例2: test_srv2
# 需要导入模块: from oic.oic.claims_provider import ClaimsClient [as 别名]
# 或者: from oic.oic.claims_provider.ClaimsClient import construct_UserClaimsRequest [as 别名]
def test_srv2():
cc = ClaimsClient(client_id="client_1")
cc.client_secret="hemlig"
req = cc.construct_UserClaimsRequest(request_args={"user_id": "diana",
"claims_names":["gender", "birthdate"]})
srv = ClaimsServer("name", None, CDB, FUNCTIONS, USERDB)
srv.keystore.set_sign_key(rsa_load("rsa.key"), "rsa")
assert srv
environ = BASE_ENVIRON.copy()
environ["REQUEST_METHOD"] = "POST"
txt = req.to_urlencoded()
environ["CONTENT_LENGTH"] = len(txt)
fil = StringIO.StringIO(buf=txt)
environ["wsgi.input"] = fil
resp = srv.claims_endpoint(environ, start_response, LOG())
print resp
assert len(resp) == 1
ucr = UserClaimsResponse().deserialize(resp[0], "json")
ucr.verify(key = srv.keystore.get_keys("sig", owner=None))
print ucr
assert _eq(ucr["claims_names"], ["gender", "birthdate"])
assert "jwt" in ucr
示例3: test_srv2
# 需要导入模块: from oic.oic.claims_provider import ClaimsClient [as 别名]
# 或者: from oic.oic.claims_provider.ClaimsClient import construct_UserClaimsRequest [as 别名]
def test_srv2():
cc = ClaimsClient(client_id="client_1")
cc.client_secret="hemlig"
req = cc.construct_UserClaimsRequest(request_args={"sub": "diana",
"claims_names":["gender", "birthdate"]})
srv = ClaimsServer("name", None, CDB, FUNCTIONS, USERDB)
srv.keyjar[""] = [KeyBundle(source="file://rsa.key", usage=["ver", "sig"])]
assert srv
environ = BASE_ENVIRON.copy()
environ["REQUEST_METHOD"] = "POST"
txt = req.to_urlencoded()
environ["CONTENT_LENGTH"] = len(txt)
fil = StringIO.StringIO(buf=txt)
environ["wsgi.input"] = fil
resp = srv.claims_endpoint(environ, start_response, LOG())
print resp
assert len(resp) == 1
ucr = UserClaimsResponse().deserialize(resp[0], "json")
ucr.verify(keyjar = srv.keyjar)
print ucr
assert _eq(ucr["claims_names"], ["gender", "birthdate"])
assert "jwt" in ucr
示例4: test_1
# 需要导入模块: from oic.oic.claims_provider import ClaimsClient [as 别名]
# 或者: from oic.oic.claims_provider.ClaimsClient import construct_UserClaimsRequest [as 别名]
def test_1():
cc = ClaimsClient(client_id="client_1")
cc.client_secret="hemlig"
req = cc.construct_UserClaimsRequest(request_args={"user_id": "norah",
"claims_names":["gender", "birthdate"]})
print req
assert req.type() == "UserClaimsRequest"
assert _eq(req.keys(),['client_secret', 'claims_names', 'user_id',
'client_id'])
assert req["user_id"] == "norah"
assert req["client_id"] == "client_1"
示例5: verify_client
# 需要导入模块: from oic.oic.claims_provider import ClaimsClient [as 别名]
# 或者: from oic.oic.claims_provider.ClaimsClient import construct_UserClaimsRequest [as 别名]
CDB = {
"client_1": { "client_secret": "hemlig"}
}
def verify_client(env, req, cdb):
return True
FUNCTIONS = {
"verify_client": verify_client,
"userinfo": user_info
}
cc = ClaimsClient(client_id="client_1")
cc.client_secret="hemlig"
req = cc.construct_UserClaimsRequest(request_args={"user_id": "diana",
"claims_names":["gender", "birthdate"]})
srv = ClaimsServer("name", None, CDB, FUNCTIONS, USERDB)
srv.keyjar[""] = [KeyChain(source="file://rsa.key", usage=["ver", "sig"])]
assert srv
environ = BASE_ENVIRON.copy()
environ["REQUEST_METHOD"] = "POST"
txt = req.to_urlencoded()
environ["CONTENT_LENGTH"] = len(txt)
fil = StringIO.StringIO(buf=txt)
environ["wsgi.input"] = fil
resp = srv.claims_endpoint(environ, start_response, LOG())