You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
We should consider both a HeaderWriter and a LogoutHandler since the spec lists numerous other circumstances as well as logout for which writing this header is handy.
It is possible that an application could be put into an indeterminate state by clearing only one type of storage. We mitigate that to some extent by clearing all storage options as a block, and by requiring that the header be delivered over a secure connection.
SecureRequestMatcher could turn out to be handy for this.
@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).
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 HeaderWriter and LoginHandler works and then I should be able to come up with a implementation and discuss it here before making a PR π
In regards to implementation of LogoutHandler did you mean ClearSiteDataLogoutHandler or HeaderWriterLogoutHandler?
There is a web.x and web.server.x for both headers.writer and logout and I used the web.x package. I wanted to learn more about the difference? Is there a resource?
Should I write the integration test in Groovy? I remember an issue where the tests are in the process of being migrated to java. Running all the integration tests based on Contribution Guideline take a little long. Is there a way I can run a subset of integration tests?
Feedback
Here is what I trimmed snippets of what I have done so far
Added ClearSiteDataHeaderWriter in org.springframework.security.web.header.writer
I am little confused with the logout handler. I came up with the following based on your comment above where you indicated that HeaderWriterLogoutHandler have HeaderWriter and placed it inside org.springframework.security.web.authentication.logout
public class ClearSiteDataLogoutHandler implements LogoutHandler {
private ClearSiteDataHeaderWriter clearSiteDataHeaderWriter;
public ClearSiteDataLogoutHandler(ClearSiteDataHeaderWriter clearSiteDataHeaderWriter) {
Assert.notNull(clearSiteDataHeaderWriter, "Clear-Site-Data header cannot be null.");
this.clearSiteDataHeaderWriter = clearSiteDataHeaderWriter;
}
@Override
public void logout(HttpServletRequest request, HttpServletResponse response,
Authentication authentication) {
response.setHeader("Clear-Site-Data", clearSiteDataHeaderWriter.getHeaderValue());
}
}
Depending on your feedback, I will need to
Add unit tests
Update the HeaderConfigurer & HeaderDefinitionBeanParser as well as
No, not at this point. The user can easily use the LogoutConfigurer to specify the logout handler to use
HeadersBeanDefinitionParser is part of XML config and doesn't need to be updated at this time, for the same reason that HeadersConfigurer doesn't need updating.
I think if we do HeaderWriterLogoutHandler, then users will be able to indicate any header writer on logout. So, then idea would be:
The difference is servlet vs reactive. If you are interested, we can take a look at the reactive equivalent support after this ticket. web.x is for servlet and web.server.x is for reactive.
No, thank you for asking. You are right, we are migrating to Java, so please write them in Java. As for running the test suite, you don't need to run the full suite each time, just do it before you submit your PR. For now, I'd recommend doing ../gradle clean build test from the web directory or simply running your test in your IDE.
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:
newClearSiteDataHeaderWriter(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.
Thank you @jzheaux for answering my questions and feedback.
I had initially thought of a constructor with String headerValue but, then dismissed that because of validation of headerValue but, your points about resilience to change as well as ease of read make sense. I will go ahead with the varargs version as it's more concise.
I will make the LogoutHandler implementation more generic as shown above π
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 Reactive ticket for the same π
During our discussions in this issues and in code reviews, we briefly mentioned
Reactive support
Logging strategy
I would be happy to work on those tasks since I now know how things work.
Please feel free to tag me in the issues once it's created and scoped π
I have addressed all the requested changes in the PR. Please let me know if there is any outstanding work left to do.
Activity
jzheaux commentedon Jan 29, 2019
The
Clear-Site-Dataheader is now supported by the majority of browsers with compatibility coming soon for others.Spring Security could simplify
Clear-Site-Dataconfiguration via an implementation ofHeaderWriterand an implementation ofLogoutHandler:We should consider both a
HeaderWriterand aLogoutHandlersince the spec lists numerous other circumstances as well as logout for which writing this header is handy.We should also keep in mind that the spec requires a secure connection:
SecureRequestMatchercould turn out to be handy for this.rhamedy commentedon Feb 10, 2019
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).
jzheaux commentedon Feb 11, 2019
@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.
rhamedy commentedon Feb 13, 2019
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
HeaderWriterandLoginHandlerworks and then I should be able to come up with a implementation and discuss it here before making a PR πrhamedy commentedon Feb 20, 2019
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
LogoutHandlerdid you meanClearSiteDataLogoutHandlerorHeaderWriterLogoutHandler?web.xandweb.server.xfor bothheaders.writerandlogoutand I used theweb.xpackage. I wanted to learn more about the difference? Is there a resource?Groovy? I remember an issue where the tests are in the process of being migrated tojava. Running all the integration tests based on Contribution Guideline take a little long. Is there a way I can run a subset of integration tests?Feedback
Here is what I trimmed snippets of what I have done so far
ClearSiteDataHeaderWriterinorg.springframework.security.web.header.writerHeaderWriterLogoutHandlerhaveHeaderWriterand placed it insideorg.springframework.security.web.authentication.logoutDepending on your feedback, I will need to
HeaderConfigurer&HeaderDefinitionBeanParseras well asheaders.adocandnamespace.adocThanks for your help ππ₯
jzheaux commentedon Feb 20, 2019
Good questions, @rhamedy:
LogoutConfigurerto specify the logout handler to useHeadersBeanDefinitionParseris part of XML config and doesn't need to be updated at this time, for the same reason thatHeadersConfigurerdoesn't need updating.HeaderWriterLogoutHandler, then users will be able to indicate any header writer on logout. So, then idea would be:web.xis for servlet andweb.server.xis for reactive.../gradle clean build testfrom thewebdirectory or simply running your test in your IDE.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:
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:
Or simply:
The nice thing about these is that the user can read it, and it reads similarly to the header itself:
If we just call it
HeaderWriterLogoutHandlerthen it can be used in other circumstances as well.rhamedy commentedon Feb 21, 2019
Thank you @jzheaux for answering my questions and feedback.
I had initially thought of a constructor with
String headerValuebut, then dismissed that because of validation ofheaderValuebut, your points about resilience to change as well as ease of read make sense. I will go ahead with thevarargsversion as it's more concise.I will make the
LogoutHandlerimplementation more generic as shown above π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
Reactiveticket for the same πrhamedy commentedon Feb 22, 2019
#6550
@jzheaux FYI ^
Please let me know if you see the need for any changes to be made π
jzheaux commentedon Feb 22, 2019
Thanks, @rhamedy! I've left some feedback inline in the PR.
Add Support for Clear Site Data on Logout
rhamedy commentedon Feb 23, 2019
Thank for the feedback @jzheaux
I have addressed all the code review comments except the
switch to slf4jwhere I hit a roadblock. I have left a comment in the PR FYI.rhamedy commentedon Feb 25, 2019
During our discussions in this issues and in code reviews, we briefly mentioned
I would be happy to work on those tasks since I now know how things work.
Please feel free to tag me in the issues once it's
createdandscopedπI have addressed all the requested changes in the PR. Please let me know if there is any outstanding work left to do.
Polish Tests and Error Messages