-
Notifications
You must be signed in to change notification settings - Fork 6k
Add Clear Site Data to Log Out #4187
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
Comments
The Spring Security could simplify public class ClearSiteDataHeaderWriter implements HeaderWriter {
String directives;
// ...
} public class HeaderWriterLogoutHandler implements LogoutHandler {
HeaderWriter headerWriter;
// ...
} We should consider both a We should also keep in mind that the spec requires a secure connection:
|
Can I work on this issue? @jzheaux thank you for your insightful comment. Is there anything else that I should know as a first time contributor? Even though this task is not labeled as first-timers-only , I would love to work on it since I have previously used Spring Framework and (even did some debugging of Spring OAuth2 - obviously different). |
@rhamedy yes, it's yours! I'd recommend keeping the solution as minimal as possible - usually, the smallest public API is the easiest to comprehend its impact on the rest of the codebase. I'd also recommend taking a look at the contribution guidelines. It's not a long read, but it's easy to forget to do. |
Thanks. I will start working on this. I read the clear-site-data webpsec and understand its purpose. I will just how to figure out how the |
Hi @jzheaux , I wanted to share what I have done some far to get some feedback as well as ask the question that came up. Questions
Feedback
Depending on your feedback, I will need to
Thanks for your help 👍🥇 |
Good questions, @rhamedy:
http
.logout()
.addLogoutHandler(new HeaderWriterLogoutHandler(new ClearSiteDataHeaderWriter(...)))
Regarding what you've done so far, thank you for sharing early - it helps us to work off of the same page. 1 & 2. When there are several constructors that all take the same type, it can be tricky for the user to keep track of what he sent to where. Consider what this looks like to the user: new ClearSiteDataHeaderWriter(true, false, true) Also, we'd like these constructors to be as resilient to change as possible. If the clear site data header specification adds another value, we'd need to revisit these constructors again, wait for browser support, etc. What if you did this instead: public ClearSiteDataHeaderWriter(String... sources) {
Assert.notEmpty(sources, "sources cannot be empty");
this.headerValue = Stream.of(sources).map(this::quote).collect(Collectors.joining(","));
} Or simply: public ClearSiteData(String headerValue) {
Assert.hasText(headerValue, "headerValue cannot be empty");
this.headerValue = headerValue;
} The nice thing about these is that the user can read it, and it reads similarly to the header itself: new ClearSiteDataHeaderWriter("cache", "storage")
public class HeaderWriterLogoutHandler implements LogoutHandler {
private final HeaderWriter headerWriter;
public HeaderWriterLogoutHandler(HeaderWriter headerWriter) {
Assert.notNull(headerWriter, "headerWriter cannot be null");
this.headerWriter = headerWriter;
}
public void logout(...) {
this.headerWriter.writeHeaders(request, response);
}
} If we just call it
|
Thank you @jzheaux for answering my questions and feedback. I had initially thought of a constructor with I will make the Looks like the solution I have is not far from a PR! I will let you know once I have a PR. I agree let's finish off this one and I would be happy to work on the |
Thanks, @rhamedy! I've left some feedback inline in the PR. |
Added an implementation of HeaderWriter for Clear-Site-Data HTTP response header as welll as an implementation of LogoutHanlder that accepts an implementation of HeaderWriter to write headers. - Added ClearSiteDataHeaderWriter and HeaderWriterLogoutHandler that implements HeaderWriter and LogoutHandler respectively - Added unit tests for both implementations's behaviours - Integration tests for HeaderWriterLogoutHandler that uses ClearSiteDataHeaderWriter - Updated the documentation to include link to HeaderWriterLogoutHandler Fixes spring-projectsgh-4187
Thank for the feedback @jzheaux I have addressed all the code review comments except the |
During our discussions in this issues and in code reviews, we briefly mentioned
I have addressed all the requested changes in the PR. Please let me know if there is any outstanding work left to do. |
MockMvc matchers are best matched with the MockMvc execution API - it's a little odd to try and use them inside of an AssertJ assertion since they do their own asserting. It's more readable to place "this." in front of member variables. It's best to test just one class at a time in a unit test. Issue: gh-4187
We should investigate adding Clear Site Data to Spring Security's LogoutHandler implementations. See https://w3c.github.io/webappsec-clear-site-data/
The text was updated successfully, but these errors were encountered: