本文整理汇总了Python中oic.utils.webfinger.WebFinger.response方法的典型用法代码示例。如果您正苦于以下问题:Python WebFinger.response方法的具体用法?Python WebFinger.response怎么用?Python WebFinger.response使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类oic.utils.webfinger.WebFinger
的用法示例。
在下文中一共展示了WebFinger.response方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: setup_webfinger_endpoint
# 需要导入模块: from oic.utils.webfinger import WebFinger [as 别名]
# 或者: from oic.utils.webfinger.WebFinger import response [as 别名]
def setup_webfinger_endpoint(self):
wf = WebFinger()
resp = Response(wf.response(subject=self.op_base, base=self.op_base))
responses.add(responses.GET,
self.op_base + ".well-known/webfinger",
body=resp.message,
status=200,
content_type='application/json')
示例2: _webfinger
# 需要导入模块: from oic.utils.webfinger import WebFinger [as 别名]
# 或者: from oic.utils.webfinger.WebFinger import response [as 别名]
def _webfinger(provider, request, **kwargs):
"""Handle webfinger requests."""
params = urlparse.parse_qs(request)
if params["rel"][0] == OIC_ISSUER:
wf = WebFinger()
return Response(wf.response(params["resource"][0], provider.baseurl),
headers=[("Content-Type", "application/jrd+json")])
else:
return BadRequest("Incorrect webfinger.")
示例3: webfinger
# 需要导入模块: from oic.utils.webfinger import WebFinger [as 别名]
# 或者: from oic.utils.webfinger.WebFinger import response [as 别名]
def webfinger(environ):
query = parse_qs(environ["QUERY_STRING"])
try:
assert query["rel"] == [OIC_ISSUER]
resource = query["resource"][0]
except KeyError:
resp = BadRequest("Missing parameter in request")
else:
wf = WebFinger()
resp = Response(wf.response(subject=resource, base=AUTHZSRV.baseurl))
return resp
示例4: _webfinger
# 需要导入模块: from oic.utils.webfinger import WebFinger [as 别名]
# 或者: from oic.utils.webfinger.WebFinger import response [as 别名]
def _webfinger(self):
query = request.args
try:
assert query["rel"] == OIC_ISSUER
resource = query["resource"][0]
except KeyError:
resp = BadRequest("Missing parameter in request")
else:
wf = WebFinger()
resp = Response(wf.response(subject=resource, base=self.provider.baseurl))
return resp
示例5: webfinger
# 需要导入模块: from oic.utils.webfinger import WebFinger [as 别名]
# 或者: from oic.utils.webfinger.WebFinger import response [as 别名]
def webfinger(environ, start_response, session_info, trace, **kwargs):
query = parse_qs(environ["QUERY_STRING"])
# Find the identifier
session_info["test_id"] = find_identifier(query["resource"][0])
trace.info(HEADER % "WebFinger")
trace.request(environ["QUERY_STRING"])
trace.info("QUERY: %s" % (query,))
try:
assert query["rel"] == [OIC_ISSUER]
resource = query["resource"][0]
except AssertionError:
errmsg = "Wrong 'rel' value: %s" % query["rel"][0]
trace.error(errmsg)
resp = BadRequest(errmsg)
except KeyError:
errmsg = "Missing 'rel' parameter in request"
trace.error(errmsg)
resp = BadRequest(errmsg)
else:
wf = WebFinger()
p = urlparse(resource)
if p.scheme == "acct":
l, _ = p.path.split("@")
path = pathmap.IDMAP[l.lower()]
else: # scheme == http/-s
try:
path = pathmap.IDMAP[p.path[1:].lower()]
except KeyError:
path = None
if path:
_url = os.path.join(kwargs["op_arg"]["baseurl"],
session_info["test_id"],
path[1:])
resp = Response(wf.response(subject=resource, base=_url),
content="application/jrd+json")
else:
resp = BadRequest("Incorrect resource specification")
trace.reply(resp.message)
dump_log(session_info, trace)
return resp(environ, start_response)
示例6: webfinger
# 需要导入模块: from oic.utils.webfinger import WebFinger [as 别名]
# 或者: from oic.utils.webfinger.WebFinger import response [as 别名]
def webfinger(environ, start_response, session_info, events, jlog, **kwargs):
_query = session_info['parameters']
events.store(EV_REQUEST, Operation("WebFinger", _query))
try:
assert _query["rel"] == [OIC_ISSUER]
resource = _query["resource"][0]
except AssertionError:
errmsg = "Wrong 'rel' value: %s" % _query["rel"][0]
events.store(EV_FAULT, errmsg)
resp = BadRequest(errmsg)
except KeyError:
errmsg = "Missing 'rel' parameter in request"
events.store(EV_FAULT, errmsg)
resp = BadRequest(errmsg)
else:
wf = WebFinger()
_url = os.path.join(kwargs["op_arg"]["baseurl"],
session_info['oper_id'],
session_info["test_id"])
_mesg = wf.response(subject=resource, base=_url)
if session_info['test_id'] == 'rp-discovery-webfinger-http-href':
_msg = json.loads(_mesg)
_msg['links'][0]['href'] = _msg['links'][0]['href'].replace(
'https', 'http')
_mesg = json.dumps(_msg)
elif session_info['test_id'] == 'rp-discovery-webfinger-unknown-member':
_msg = json.loads(_mesg)
_msg['dummy'] = 'foobar'
_mesg = json.dumps(_msg)
resp = Response(_mesg,
content="application/jrd+json")
events.store(EV_RESPONSE, resp.message)
jlog.info(resp2json(resp))
dump_log(session_info, events)
return resp(environ, start_response)
示例7: webfinger
# 需要导入模块: from oic.utils.webfinger import WebFinger [as 别名]
# 或者: from oic.utils.webfinger.WebFinger import response [as 别名]
def webfinger(environ, start_response, session, trace):
query = parse_qs(environ["QUERY_STRING"])
# Find the identifier
session["test_id"] = find_identifier(query["resource"][0])
trace.info(HEADER % "WebFinger")
trace.request(environ["QUERY_STRING"])
trace.info("QUERY: %s" % (query,))
try:
assert query["rel"] == [OIC_ISSUER]
resource = query["resource"][0]
except AssertionError:
errmsg = "Wrong 'rel' value: %s" % query["rel"][0]
trace.error(errmsg)
resp = BadRequest(errmsg)
except KeyError:
errmsg = "Missing 'rel' parameter in request"
trace.error(errmsg)
resp = BadRequest(errmsg)
else:
wf = WebFinger()
p = urlparse(resource)
if p.scheme == "acct":
l, _ = p.path.split("@")
path = pathmap.IDMAP[l]
else: # scheme == http/-s
path = pathmap.IDMAP[p.path[1:]]
_url = os.path.join(OP_ARG["baseurl"], session["test_id"], path[1:])
resp = Response(wf.response(subject=resource, base=_url))
trace.reply(resp.message)
dump_log(session, trace)
return resp(environ, start_response)
示例8: MyFakeOICServer
# 需要导入模块: from oic.utils.webfinger import WebFinger [as 别名]
# 或者: from oic.utils.webfinger.WebFinger import response [as 别名]
class MyFakeOICServer(Server):
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()
#noinspection PyUnusedLocal
def http_request(self, path, method="GET", **kwargs):
part = urlparse(path)
path = part[2]
query = part[4]
self.host = "%s://%s" % (part.scheme, part.netloc)
response = Response
response.status_code = 500
response.text = ""
if path == ENDPOINT["authorization_endpoint"]:
assert method == "GET"
response = self.authorization_endpoint(query)
elif path == ENDPOINT["token_endpoint"]:
assert method == "POST"
response = self.token_endpoint(kwargs["data"])
elif path == ENDPOINT["user_info_endpoint"]:
assert method == "POST"
response = self.userinfo_endpoint(kwargs["data"])
elif path == ENDPOINT["refresh_session_endpoint"]:
assert method == "GET"
response = self.refresh_session_endpoint(query)
elif path == ENDPOINT["check_session_endpoint"]:
assert method == "GET"
response = self.check_session_endpoint(query)
elif path == ENDPOINT["end_session_endpoint"]:
assert method == "GET"
response = self.end_session_endpoint(query)
elif path == ENDPOINT["registration_endpoint"]:
if method == "POST":
response = self.registration_endpoint(kwargs["data"])
elif path == "/.well-known/webfinger":
assert method == "GET"
qdict = parse_qs(query)
response.status_code = 200
response.text = self.webfinger.response(qdict["resource"][0],
"%s/" % self.name)
elif path == "/.well-known/openid-configuration":
assert method == "GET"
response = self.openid_conf()
return response
def authorization_endpoint(self, query):
req = self.parse_authorization_request(query=query)
sid = self.sdb.create_authz_session(sub="user", areq=req)
_info = self.sdb[sid]
_info["sub"] = _info["local_sub"]
if "code" in req["response_type"]:
if "token" in req["response_type"]:
grant = _info["code"]
_dict = self.sdb.upgrade_to_token(grant)
_dict["oauth_state"] = "authz",
_dict = by_schema(AuthorizationResponse(), **_dict)
resp = AuthorizationResponse(**_dict)
#resp.code = grant
else:
resp = AuthorizationResponse(state=req["state"],
code=_info["code"])
else: # "implicit" in req.response_type:
grant = _info["code"]
params = AccessTokenResponse.c_param.keys()
_dict = dict([(k, v) for k, v in
self.sdb.upgrade_to_token(grant).items() if k in
params])
try:
del _dict["refresh_token"]
except KeyError:
pass
if "id_token" in req["response_type"]:
_idt = self.make_id_token(_info, issuer=self.name,
access_token=_dict["access_token"])
alg = "RS256"
ckey = self.keyjar.get_signing_key(alg2keytype(alg),
_info["client_id"])
_dict["id_token"] = _idt.to_jwt(key=ckey, algorithm=alg)
resp = AccessTokenResponse(**_dict)
location = resp.request(req["redirect_uri"])
response = Response()
response.headers = {"location": location}
response.status_code = 302
response.text = ""
#.........这里部分代码省略.........