spring-projects / spring-projects/spring-security
It is not possible to use referer as redirection location using SavedRequestAwareAuthenticationSuccessHandler
Nobody has claimed this yet.
- Dominant language
- Java
- Stars
- 9.6k
- Forks
- 6.3k
- Avg merge
- 2d 11h
- Merged PRs (30d)
- 52
Description
Summary
Current implementation by any means does not allow to use referer as redirection url despite extending AbstractAuthenticationTargetUrlRequestHandler which allows that and exposes propert setter useReferer(true).
Actual Behavior
Exposed useReferer setter has no effect.
Expected Behavior
Use referrer as redirection location if useReferer(true) is set and proper header is present in the original request.
Version
<spring-security.version>5.0.10.RELEASE</spring-security.version>
Sample
This example shows badly written (trial and error yet) workaround implementation
Will add working workaround
This is done to affect following check inside SavedRequestAwareAuthenticationSuccessHandler
In general, if isAlwaysUseDefaultTargetUrl - default target will be used even if not specified. If targetUrl parameter is set and present - it will be used. There is no other path to access .superOnAuthenticationSuccess to get referer working having saver request - and this is my goal
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with web/src/main/java/org/springframework/security/web/authentication/SavedRequestAwareAuthenticationSuccessHandler.java, especially the linked lines 84-91, and compare its behavior with AbstractAuthenticationTargetUrlRequestHandler. Reproduce the saved-request flow using the issue's referer header and useReferer(true) conditions; done means the original referer is used as the redirect location when no higher-priority target applies.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- java, spring
- Domain
- authentication, backend
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100