-
Notifications
You must be signed in to change notification settings - Fork 6k
DefaultRedirectStrategy should not calculate relative url if it does not contain the context-path #4142
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
DefaultRedirectStrategy should not calculate relative url if it does not contain the context-path #4142
Conversation
@mpalourdio Please sign the Contributor License Agreement! Click here to manually synchronize the status of this Pull Request. See the FAQ for frequently asked questions. |
@mpalourdio Thank you for signing the Contributor License Agreement! |
ca6a5c8
to
98fb945
Compare
0e114c6
to
fd244eb
Compare
98fb945
to
e9e3cde
Compare
e9e3cde
to
1dab18a
Compare
1dab18a
to
d4c0ec1
Compare
Thanks for the PR @mpalourdio! |
@eleftherias Thanks for feedback. I haven't really thought about this, it's been a while now :) But looking at the fact that you would prefer returning an empty string, here is how it would look if (isContextRelative() && !url.contains(contextPath)) {
return "";
} Which would lead to As a security library, I finally think that it simply should fail by throwing an exception. Otherwise, feel free to close this issue. |
@mpalourdio My concern with throwing an exception in the My thought with returning Let me know if you think there is a better approach, or an exception that is better suited than |
d4c0ec1
to
2915bdd
Compare
@eleftherias I have updated the PR so that it redirects to "" when needed. |
2915bdd
to
3c4bdd9
Compare
@mpalourdio Thank you for the quick turnaround. One last request is to change the URL in the test from |
…ve URL does not contain the context-path.
3c4bdd9
to
32098f8
Compare
@eleftherias done :) |
Thanks for all your work @mpalourdio! This is now merged into master. |
Hello,
When defining a redirect strategy, after a logout for example, you can force the redirection to be context relative, by
setContextRelative(true)
.If by mistake (or not), you want the redirect target to be an absolute url completely outside of your context-path (eg: http://www.google.com), this url obviously does not contain your context-path.
This lead to
DefaultRedirectStrategy#calculateRedirectUrl
silently calculating a completely wrong URL ifcontextRelative
istrue
This PR checks is the URL contains the context-path. If not, it early returns the untouched url.
Another possibility would be to throw an
IllegalArgumentException
ifcontextRelative
is true BUT url is absolute AND does not contain the context-path.