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
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 13 additions & 6 deletions pyeudiw/satosa/default/openid4vp_backend.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)


# Cross Device flow
res_url = f'{self.client_id}?{url_params}'

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,

"qrcode_size": self.config["qrcode"]["size"],
"qrcode_logo_path": self.config["qrcode"]["logo_path"],
"qrcode_expiration_time": self.config["qrcode"]["expiration_time"],
Expand Down Expand Up @@ -342,6 +340,15 @@ def db_engine(self) -> DBEngine:

return self._db_engine

def _build_authz_request_url(self, payload: dict) -> str:
scheme = self.config["authorization"]["url_scheme"]
# NOTE: path component is currently unused by the protocol, but currently
# we leave it there as 'authorize' to stress the fact that this is an
# 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


@property
def default_metadata_private_jwk(self) -> tuple:
"""Returns the default metadata private JWK"""
Expand Down
Loading