Skip to content
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

Merged
merged 3 commits into from
Nov 12, 2024
Merged

fix: qr code value #304

merged 3 commits into from
Nov 12, 2024

Conversation

Zicchio
Copy link
Collaborator

@Zicchio Zicchio commented Nov 11, 2024

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.

@@ -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)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
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)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
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,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
"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}"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
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

Suggested change
return f"{scheme}://{path}?{query_params}"
if "://" in scheme:
scheme = scheme
else:
scheme = f"{scheme}://"
return f"{scheme}{path}?{query_params}"

Copy link
Collaborator Author

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

  1. added to docs that the same configuration can be used for costum scheme or universal link
  2. a check for the existance of trailing slash before path component is added (required if universal link does not include them)
  3. an extension of same device integration test to make it compatible with universal links, as in that case a different exception is raised

Copy link
Member

@peppelinux peppelinux left a 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

@peppelinux peppelinux merged commit 5c3c95e into italia:dev Nov 12, 2024
5 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[Satosa][Bug] Incorrect QR code value in cross device flow
2 participants