-
Notifications
You must be signed in to change notification settings - Fork 266
Distributed claims #420
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Distributed claims #420
Changes from 4 commits
5fd587a
43e0a77
007244d
eed4b70
323f074
1013ede
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -764,6 +764,7 @@ def do_end_session_request(self, request=EndSessionRequest, scope="", | |
| def user_info_request(self, method="GET", state="", scope="", **kwargs): | ||
| uir = UserInfoRequest() | ||
| logger.debug("[user_info_request]: kwargs:%s" % (sanitize(kwargs),)) | ||
| token = None | ||
| if "token" in kwargs: | ||
| if kwargs["token"]: | ||
| uir["access_token"] = kwargs["token"] | ||
|
|
@@ -773,12 +774,11 @@ def user_info_request(self, method="GET", state="", scope="", **kwargs): | |
| kwargs["behavior"] = "use_authorization_header" | ||
| else: | ||
| # What to do ? Need a callback | ||
| token = None | ||
| pass | ||
| elif "access_token" in kwargs and kwargs["access_token"]: | ||
| uir["access_token"] = kwargs["access_token"] | ||
| del kwargs["access_token"] | ||
| token = None | ||
| else: | ||
| elif state: | ||
| token = self.grant[state].get_token(scope) | ||
|
|
||
| if token.is_valid(): | ||
|
|
@@ -808,17 +808,19 @@ def user_info_request(self, method="GET", state="", scope="", **kwargs): | |
| if "behavior" in kwargs: | ||
| _behav = kwargs["behavior"] | ||
| _token = uir["access_token"] | ||
| _ttype = '' | ||
| try: | ||
| _ttype = kwargs["token_type"] | ||
| except KeyError: | ||
| try: | ||
| _ttype = token.token_type | ||
| except AttributeError: | ||
| raise MissingParameter("Unspecified token type") | ||
| if token: | ||
| try: | ||
| _ttype = token.token_type | ||
| except AttributeError: | ||
| raise MissingParameter("Unspecified token type") | ||
|
|
||
| if 'as_query_parameter' == _behav: | ||
| method = 'GET' | ||
| else: | ||
| elif token: | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The comparison is still not explicit. It believe that it should be
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I don't think that is good enough. token='' should be handled the same way as token=None
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. And is there any case where token would be an empty string? |
||
| # use_authorization_header, token_in_message_body | ||
| if "use_authorization_header" in _behav: | ||
| token_header = "{type} {token}".format( | ||
|
|
@@ -899,12 +901,13 @@ def do_user_info_request(self, method="POST", state="", scope="openid", | |
| if 'error' in res: # Error response | ||
| res = UserInfoErrorResponse(**res.to_dict()) | ||
|
|
||
| # Verify userinfo sub claim against what's returned in the ID Token | ||
| idt = self.grant[state].get_id_token() | ||
| if idt: | ||
| if idt['sub'] != res['sub']: | ||
| raise SubMismatch( | ||
| 'Sub identifier not the same in userinfo and Id Token') | ||
| if state: | ||
| # Verify userinfo sub claim against what's returned in the ID Token | ||
| idt = self.grant[state].get_id_token() | ||
| if idt: | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This seems to never be triggered in tests. |
||
| if idt['sub'] != res['sub']: | ||
| raise SubMismatch( | ||
| 'Sub identifier not the same in userinfo and Id Token') | ||
|
|
||
| self.store_response(res, _txt) | ||
|
|
||
|
|
@@ -1064,12 +1067,16 @@ def fetch_distributed_claims(self, userinfo, callback=None): | |
| if "endpoint" in spec: | ||
| if "access_token" in spec: | ||
| _uinfo = self.do_user_info_request( | ||
| token=spec["access_token"], | ||
| method='GET', token=spec["access_token"], | ||
| userinfo_endpoint=spec["endpoint"]) | ||
| else: | ||
| _uinfo = self.do_user_info_request( | ||
| token=callback(csrc), | ||
| userinfo_endpoint=spec["endpoint"]) | ||
| if callback: | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This part is not covered by tests.
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Does the recent changes meet your requirements ?
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Sorry for not responding earlier. I am having a busy week at work. I will have a look today.
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Here again, comparison to
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. OK now ? Need to get this out the door soon. |
||
| _uinfo = self.do_user_info_request( | ||
| method='GET', token=callback(spec['endpoint']), | ||
| userinfo_endpoint=spec["endpoint"]) | ||
| else: | ||
| _uinfo = self.do_user_info_request( | ||
| method='GET', userinfo_endpoint=spec["endpoint"]) | ||
|
|
||
| claims = [value for value, src in | ||
| userinfo["_claim_names"].items() if src == csrc] | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The same goes here:
if token is not None: