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

Invalid verification_uri in device authorization response when context path exists #1714

Open
sfeigl opened this issue Sep 11, 2024 · 2 comments · May be fixed by #1729
Open

Invalid verification_uri in device authorization response when context path exists #1714

sfeigl opened this issue Sep 11, 2024 · 2 comments · May be fixed by #1729
Labels
type: bug A general bug
Milestone

Comments

@sfeigl
Copy link

sfeigl commented Sep 11, 2024

Describe the bug

The OAuth2AuthorizationServerConfigurer allows to configure the "verificationUri" the user has to visit to authorize a device during the device authorization flow.

This verification URI replaces the complete path component of the URI the device used to request the device authorization. If the web application is not located on the root path, the path to the web application is truncated.

Lets say the verificationUri is configured to "verifyDevice", the authorization server is reachable with the base URL:

https://auth.server/authserver/

and the device initates the flow under the URI

https://auth.server/authserver/oauth2/device_authorization

then the returned verification uri is

https://auth.server/verifyDevice

In the OAuth2DeviceAuthorizationEndpointFilter a replacePath is used

UriComponentsBuilder uriComponentsBuilder = UriComponentsBuilder .fromHttpUrl(UrlUtils.buildFullRequestUrl(request)) .replacePath(this.verificationUri); String verificationUri = uriComponentsBuilder.build().toUriString();

So it is impossible to configure a path relative to the authorization server base URI without knowing the server base URI in advance (during application startup). Knowing the base URI in advance is sometimes difficult (in proxy scenarios)

Expected behavior

The verificationUri should be configurable relative to the authorization server base URI.

@sfeigl sfeigl added the type: bug A general bug label Sep 11, 2024
@jgrandja jgrandja added this to the 1.3.3 milestone Sep 18, 2024
@jgrandja jgrandja changed the title Device authorization flow when authorization server is not running under root path Invalid verification_uri in device authorization response when context path exists Sep 18, 2024
@jgrandja
Copy link
Collaborator

@sfeigl Thanks for reporting this. This bug was introduced in 1.3.

Would you be interested in submitting a fix for this?

@sfeigl
Copy link
Author

sfeigl commented Sep 25, 2024

I suppose

.fromHttpUrl(UrlUtils.buildFullRequestUrl(request)) .replacePath(UrlPathHelper.defaultInstance.getContextPath(request)).pathSegment(this.verificationUri)

should work.

I probably can try this end of the week.

sfeigl pushed a commit to sfeigl/spring-authorization-server that referenced this issue Sep 25, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type: bug A general bug
Projects
Status: Prioritized
Development

Successfully merging a pull request may close this issue.

2 participants