spring-security: Spring security version 6.0.1 jump to a wrong url after login success
Describe the bug When trying to log in, if the log in successful, then it will redirect to the wrong URL: http:localhost:9090/error?continue here it must redirect to / URL, to the URL which it comes from, but it goes to /error?continue
To Reproduce The below code processes the wrong URL
/**
* Indicates the URL that the user agent used for this request.
* @return the full URL of this request
*/
@Override
public String getRedirectUrl() {
String queryString = createQueryString(this.queryString, this.matchingRequestParameterName);
return UrlUtils.buildFullRequestUrl(this.scheme, this.serverName, this.serverPort, this.requestURI,
queryString);
}
matchingRequestParameterName = continue requestURI = error so it will become /error?continue
Expected behavior It can redirect to the URL which it comes from or redirect to root path /
Note: the previous version (5.3.4) works well
About this issue
- Original URL
- State: closed
- Created 4 years ago
- Comments: 18 (7 by maintainers)
I’m experiencing exactly the same issue. The DefaultSavedRequest object is already set to error?continue api path. I couldn’t find where the assignment was.
Spring Boot 3.x and Spring Security 6.0.1 have many challenages… Can I get a hint about the solution?
@marcusdacoregio Thanks for the reply! Here I have tried a lot to figure out the problem, but I did not get any solution. So here I have no way, but only to send you some screen shots, which let you know the configuration I did, and the DEBUG information. The below screenshot is my configuration:
And this screenshot show the request URL already set /error, I have don nothing just started the application and sent a GET request by browser as http://localhost:9999/user/list OR http://localhost:9999 which these URLs both needs to be authenticated, but I get the below result, which is very a strange error, that when and where the error has been set the request URL?!
So you can check these screenshots if figured out the problem. Thanks in advance!
I had the same issue where my application would redirect to
/errorafter login. I solved it by adding this line:In context:
There was no need to set the
shouldFilterAllDispatcherTypestofalse.@ujkim it’s hard to guess what is happening since there is a lot going on. Did you try adding
logging.level.org.springframework.security=TRACEto yourapplication.propertiesand check the console log for a clue on what is happening?