-
Notifications
You must be signed in to change notification settings - Fork 14
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
fix: qr code value #304
fix: qr code value #304
Conversation
@@ -205,20 +205,18 @@ def pre_request_endpoint(self, context: Context, internal_request, **kwargs) -> | |||
'client_id': self.client_id, | |||
'request_uri': f"{self.absolute_request_url}?id={state}", | |||
} | |||
url_params = urlencode(payload, quote_via=quote_plus) | |||
|
|||
respose_url = self._build_authz_request_url(payload) |
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.
respose_url = self._build_authz_request_url(payload) | |
response_url = self._build_authz_request_url(payload) |
|
||
if is_smartphone(context.http_headers.get('HTTP_USER_AGENT')): | ||
# Same Device flow | ||
res_url = f'{self.config["authorization"]["url_scheme"]}://authorize?{url_params}' | ||
return Redirect(res_url) | ||
return Redirect(respose_url) |
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.
return Redirect(respose_url) | |
return Redirect(response_url) |
result = self.template.qrcode_page.render( | ||
{ | ||
"qrcode_color": self.config["qrcode"]["color"], | ||
"qrcode_text": res_url, | ||
"qrcode_text": respose_url, |
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.
"qrcode_text": respose_url, | |
"qrcode_text": response_url, |
# OAuth 2.0 request modified by JAR (RFC9101) | ||
path = "authorize" | ||
query_params = urlencode(payload, quote_via=quote_plus) | ||
return f"{scheme}://{path}?{query_params}" |
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.
return f"{scheme}://{path}?{query_params}" | |
return f"{scheme}://{path}?{query_params}" |
this would work only with custom url schemes, using universal links "://" will be duplicated and wrongly appended
I would suggest something like this
return f"{scheme}://{path}?{query_params}" | |
if "://" in scheme: | |
scheme = scheme | |
else: | |
scheme = f"{scheme}://" | |
return f"{scheme}{path}?{query_params}" |
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.
to support univesal link, further changes were added; this includes
- added to docs that the same configuration can be used for costum scheme or universal link
- a check for the existance of trailing slash before path component is added (required if universal link does not include them)
- an extension of same device integration test to make it compatible with universal links, as in that case a different exception is raised
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.
good catch, my suggestions bring some small improvements to be included in this PR
This pull requests closes #302
The cross device flow now uses the same URL of the same device flow, and the URL value is the very same value that was previously yielded by the same device flow.