-
Notifications
You must be signed in to change notification settings - Fork 6k
Remove GET request support from Saml2AuthenticationTokenConverter #17108
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
5cdc84c
to
72867ed
Compare
Signed-off-by: Tran Ngoc Nhan <[email protected]>
eaa03b3
to
e6186a1
Compare
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, @ngocnhan-tran1996! I've left some feedback inline.
@@ -43,6 +43,8 @@ public final class Saml2AuthenticationTokenConverter implements AuthenticationCo | |||
|
|||
private Saml2AuthenticationRequestRepository<AbstractSaml2AuthenticationRequest> authenticationRequestRepository; | |||
|
|||
private Boolean shouldInflate; |
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.
Please use boolean
and give it an initial value of true
. We typically reserve null
in Boolean
for "no opinion".
@@ -86,16 +88,26 @@ public void setAuthenticationRequestRepository( | |||
this.authenticationRequestRepository = authenticationRequestRepository; | |||
} | |||
|
|||
/** | |||
* Use the given {@code shouldInflate} to inflate request. |
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.
Please indicate the default value in this JavaDoc
private String decode(HttpServletRequest request) { | ||
// prevent to break passivity in Saml2LoginBeanDefinitionParserTests | ||
if (this.shouldInflate == null) { | ||
this.shouldInflate = HttpMethod.GET.matches(request.getMethod()); |
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.
This is not thread-safe since multiple requests will use the same instance of this class. Please approach this in a way that does not involve updating a member variable.
@@ -61,6 +61,7 @@ public class Saml2AuthenticationTokenConverterTests { | |||
public void convertWhenSamlResponseThenToken() { | |||
Saml2AuthenticationTokenConverter converter = new Saml2AuthenticationTokenConverter( | |||
this.relyingPartyRegistrationResolver); | |||
converter.setShouldInflateResponse(false); |
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.
Please don't alter any unit tests. In this way, we can have high confidence that the change is a passive one.
That said, I believe adding a test would be a good idea. I think we should test when shouldInflate
is false
and the request is a GET.
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.
Please don't alter any unit tests.
This is unclear to me. I've made changes on my local machine, and some tests will fail. We should either set the value to false to keep it passive, or update the expected results in the tests. Which option should we choose?
I think we can define
Boolean shouldInflate
and methoddecode
will be addedIf not, this will break
Saml2LoginBeanDefinitionParserTests
andSaml2AuthenticationTokenConverterTests
Issue: gh-17099