-
Notifications
You must be signed in to change notification settings - Fork 6k
Add logging to CsrfTokenRequestHandler implementations #16994
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
base: main
Are you sure you want to change the base?
Conversation
Add trace-level logging to show the logical path of CSRF token processing - Log token source (header or parameter) in resolveCsrfTokenValue - Log request attribute names in handle methods - Log failures in XorCsrfTokenRequestAttributeHandler (especially Base64 decoding) - Add similar logging to XorServerCsrfTokenRequestAttributeHandler Improves debugging capabilities without changing functionality. Signed-off-by: yybmion <yunyubin54@gmail.com>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hi, @yybmion, thanks for the PR! I've left some feedback inline for the servlet code. Will you please apply the same to the reactive code?
Also, I don't see changes to ServerCsrfTokenRequestHandler
. Can you add logging changes equivalent to CsrfTokenRequestHandler
?
web/src/main/java/org/springframework/security/web/csrf/CsrfTokenRequestAttributeHandler.java
Outdated
Show resolved
Hide resolved
web/src/main/java/org/springframework/security/web/csrf/CsrfTokenRequestHandler.java
Outdated
Show resolved
Hide resolved
web/src/main/java/org/springframework/security/web/csrf/CsrfTokenRequestHandler.java
Outdated
Show resolved
Hide resolved
...src/main/java/org/springframework/security/web/csrf/XorCsrfTokenRequestAttributeHandler.java
Outdated
Show resolved
Hide resolved
...src/main/java/org/springframework/security/web/csrf/XorCsrfTokenRequestAttributeHandler.java
Outdated
Show resolved
Hide resolved
...src/main/java/org/springframework/security/web/csrf/XorCsrfTokenRequestAttributeHandler.java
Outdated
Show resolved
Hide resolved
...src/main/java/org/springframework/security/web/csrf/XorCsrfTokenRequestAttributeHandler.java
Outdated
Show resolved
Hide resolved
web/src/main/java/org/springframework/security/web/csrf/CsrfTokenRequestAttributeHandler.java
Outdated
Show resolved
Hide resolved
...src/main/java/org/springframework/security/web/csrf/XorCsrfTokenRequestAttributeHandler.java
Outdated
Show resolved
Hide resolved
...src/main/java/org/springframework/security/web/csrf/XorCsrfTokenRequestAttributeHandler.java
Outdated
Show resolved
Hide resolved
Improve CSRF logging: consistent formatting, reduced nesting, proper encapsulation, and removal of redundant messages Signed-off-by: yybmion <yunyubin54@gmail.com>
Thank you @jzheaux for thorough review and detailed guidance! |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the updates, @yybmion! I've left some additional feedback based on your changes.
...src/main/java/org/springframework/security/web/csrf/CsrfTokenRequestHandlerLoggerHolder.java
Outdated
Show resolved
Hide resolved
...src/main/java/org/springframework/security/web/csrf/XorCsrfTokenRequestAttributeHandler.java
Outdated
Show resolved
Hide resolved
.../org/springframework/security/web/server/csrf/XorServerCsrfTokenRequestAttributeHandler.java
Outdated
Show resolved
Hide resolved
.../org/springframework/security/web/server/csrf/XorServerCsrfTokenRequestAttributeHandler.java
Outdated
Show resolved
Hide resolved
...ava/org/springframework/security/web/server/csrf/ServerCsrfTokenRequestAttributeHandler.java
Outdated
Show resolved
Hide resolved
.../org/springframework/security/web/server/csrf/ServerCsrfTokenRequestHandlerLoggerHolder.java
Outdated
Show resolved
Hide resolved
Thanks for additional feedback @jzheaux! I updated feedback. |
Thanks, @yybmion, this is taking shape nicely. When I run the build ( |
Align log messages between servlet and reactive implementations Signed-off-by: yybmion <yunyubin54@gmail.com>
@jzheaux I ran "./gradlew :spring-security-web:check" and the build completed successfully. Sorry for the small issues that extended the review process. I've learned a lot from this contribution opportunity and appreciate your patience!" |
Issue
This PR adds trace-level logging to CSRF token handlers to improve debugging capabilities.
Changes
resolveCsrfTokenValue
handle
methodsXorCsrfTokenRequestAttributeHandler
when token processing fails (as specifically requested in the issue)XorServerCsrfTokenRequestAttributeHandler
for consistencyFixes #13626