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

authorization_uri Supports Query Parameters #6299

Merged
merged 1 commit into from
Dec 21, 2018

Conversation

jzheaux
Copy link
Contributor

@jzheaux jzheaux commented Dec 17, 2018

Fixes: gh-5760

@jzheaux jzheaux requested a review from jgrandja December 17, 2018 23:44
@jzheaux
Copy link
Contributor Author

jzheaux commented Dec 17, 2018

@jgrandja note that while UriComponentsBuilder can encode query parameters on its own, it does not encode the redirect_uri in the same way as URLEncoder.encode.

For that reason, the code still manually encodes the query parameters. However, let me know if it's okay to change the existing way redirect_uri is encoded. Specifically : and / are not encoded by UriComponentsBuilder.

@rwinch
Copy link
Member

rwinch commented Dec 18, 2018

@jzheaux Do we know why there is a difference? Is this something we should take up with Spring Framework team?

@rwinch rwinch added the status: waiting-for-feedback We need additional information before we can continue label Dec 18, 2018
@jzheaux
Copy link
Contributor Author

jzheaux commented Dec 19, 2018

@rwinch It appears to be related to RFC 3986 (emphasis mine):

The characters slash ("/") and question mark ("?") may represent data
within the query component. Beware that some older, erroneous
implementations may not handle such data correctly when it is used as
the base URI for relative references (Section 5.1), apparently
because they fail to distinguish query data from path data when
looking for hierarchical separators. However, as query components
are often used to carry identifying information in the form of
"key=value" pairs and one frequently used value is a reference to
another URI, it is sometimes better for usability to avoid percent-
encoding those characters
.

@jzheaux
Copy link
Contributor Author

jzheaux commented Dec 19, 2018

Given that UriComponentsBuilder likely has reasonable defaults and given this recommendation from the spec, I'd prefer to just rely on UriComponentsBuilder to do the encoding. Are there reasons the code needs to continue percent-encoding / and :?

Because of this, authorization_uri can now be a fully-qualified url.

Fixes: spring-projectsgh-5760
@jzheaux jzheaux removed the status: waiting-for-feedback We need additional information before we can continue label Dec 21, 2018
@jzheaux
Copy link
Contributor Author

jzheaux commented Dec 21, 2018

@rwinch @jgrandja I've updated this to rely on UriComponentsBuilder for encoding as well.

@jgrandja jgrandja self-assigned this Dec 21, 2018
@jgrandja jgrandja added type: enhancement A general enhancement in: oauth2 An issue in OAuth2 modules (oauth2-core, oauth2-client, oauth2-resource-server, oauth2-jose) labels Dec 21, 2018
@jgrandja jgrandja added this to the 5.2.0.M1 milestone Dec 21, 2018
Copy link
Contributor

@jgrandja jgrandja left a comment

Choose a reason for hiding this comment

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

@jzheaux This looks great. As an FYI, encode() defaults to StandardCharsets.UTF_8 so no need to be explicit with encode(StandardCharsets.UTF_8). I'm indifferent on whether you keep it as-is or change it to encode().

Can you please merge this?

@jgrandja jgrandja mentioned this pull request Dec 21, 2018
@jzheaux jzheaux merged commit d77b12d into spring-projects:master Dec 21, 2018
@jzheaux jzheaux deleted the gh-5760 branch December 21, 2018 20:23
@jzheaux
Copy link
Contributor Author

jzheaux commented Dec 21, 2018

@jgrandja yes, I considered that, but I prefer the explicit statement to use UTF-8, as you may have gathered.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
in: oauth2 An issue in OAuth2 modules (oauth2-core, oauth2-client, oauth2-resource-server, oauth2-jose) type: enhancement A general enhancement
Projects
None yet
Development

Successfully merging this pull request may close these issues.

adding query parameter to authorization_uri creates malformed url
3 participants