-
Notifications
You must be signed in to change notification settings - Fork 6.2k
Description
UriComponentsBuilder only has formUri() and fromUriString() available for a using it with a url
The UriComponentsBuilder only has the following methods available and we must use either fromUri() or fromUriString() to pass in an url to the builder.
Current Behavior
In the documentation it currently states we should be using .fromHttpUrl() for passing in the request url to the builder but that method does not exist here.
Currently we must use the following implementation to pass a request url to the builder
UriComponentsBuilder builder = UriComponentsBuilder.fromUriString(request.getRequestURL().toString())
.replacePath(request.getContextPath())
.replaceQuery(null)
.fragment(null)
.path("/login/ott")
.queryParam("token", oneTimeToken.getTokenValue());Steps to Reproduce
- Go to the Spring Security One-Time Token Login documentation.
- Follow the example for
MagicLinkOneTimeTokenGenerationSuccessHandler. - Observe the compilation error on the line:
UriComponentsBuilder.fromHttpUrl(UrlUtils.buildFullRequestUrl(request))
- If you are using Intellij you will automatically see the infamous red squiggly line under .fromHttpUrl()
Suggested Fix
- Update the MagicLinkOneTimeTokenGenerationSuccessHandler example in the documentation to use fromUriString() and request.getRequestURL() to ensure the code is copy-paste compatible for users
Context
-
I was trying to learn about OTT using the docs but the wrong implementation made it difficult to understand when i was getting an error with my configuration
-
I am trying to create a web app with pasword-less authentication using one time token generation
-
I'm not aware of any other alternatives or workarounds but would love to know more about this from someone who has the knowledge!