mirror of
https://github.com/spring-projects/spring-security.git
synced 2025-06-08 05:02:13 +00:00
Add Switch for Processing GET Requests
Issue gh-17099
This commit is contained in:
parent
32c7e8a6ee
commit
f73f253beb
@ -51,6 +51,8 @@ final class BaseOpenSamlAuthenticationTokenConverter implements AuthenticationCo
|
||||
|
||||
private Saml2AuthenticationRequestRepository<?> authenticationRequests = new HttpSessionSaml2AuthenticationRequestRepository();
|
||||
|
||||
private boolean shouldConvertGetRequests = true;
|
||||
|
||||
/**
|
||||
* Constructs a {@link BaseOpenSamlAuthenticationTokenConverter} given a repository
|
||||
* for {@link RelyingPartyRegistration}s
|
||||
@ -172,13 +174,19 @@ final class BaseOpenSamlAuthenticationTokenConverter implements AuthenticationCo
|
||||
this.requestMatcher = requestMatcher;
|
||||
}
|
||||
|
||||
void setShouldConvertGetRequests(boolean shouldConvertGetRequests) {
|
||||
this.shouldConvertGetRequests = shouldConvertGetRequests;
|
||||
}
|
||||
|
||||
private String decode(HttpServletRequest request) {
|
||||
String encoded = request.getParameter(Saml2ParameterNames.SAML_RESPONSE);
|
||||
boolean isGet = HttpMethod.GET.matches(request.getMethod());
|
||||
if (!this.shouldConvertGetRequests && isGet) {
|
||||
return null;
|
||||
}
|
||||
Saml2Utils.DecodingConfigurer decoding = Saml2Utils.withEncoded(encoded).requireBase64(true).inflate(isGet);
|
||||
try {
|
||||
return Saml2Utils.withEncoded(encoded)
|
||||
.requireBase64(true)
|
||||
.inflate(HttpMethod.GET.matches(request.getMethod()))
|
||||
.decode();
|
||||
return decoding.decode();
|
||||
}
|
||||
catch (Exception ex) {
|
||||
throw new Saml2AuthenticationException(Saml2Error.invalidResponse(ex.getMessage()), ex);
|
||||
|
@ -101,4 +101,14 @@ public final class OpenSaml4AuthenticationTokenConverter implements Authenticati
|
||||
this.delegate.setRequestMatcher(requestMatcher);
|
||||
}
|
||||
|
||||
/**
|
||||
* Use the given {@code shouldConvertGetRequests} to convert {@code GET} requests.
|
||||
* Default is {@code true}.
|
||||
* @param shouldConvertGetRequests the {@code shouldConvertGetRequests} to use
|
||||
* @since 7.0
|
||||
*/
|
||||
public void setShouldConvertGetRequests(boolean shouldConvertGetRequests) {
|
||||
this.delegate.setShouldConvertGetRequests(shouldConvertGetRequests);
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -101,4 +101,14 @@ public final class OpenSaml5AuthenticationTokenConverter implements Authenticati
|
||||
this.delegate.setRequestMatcher(requestMatcher);
|
||||
}
|
||||
|
||||
/**
|
||||
* Use the given {@code shouldConvertGetRequests} to convert {@code GET} requests.
|
||||
* Default is {@code true}.
|
||||
* @param shouldConvertGetRequests the {@code shouldConvertGetRequests} to use
|
||||
* @since 7.0
|
||||
*/
|
||||
public void setShouldConvertGetRequests(boolean shouldConvertGetRequests) {
|
||||
this.delegate.setShouldConvertGetRequests(shouldConvertGetRequests);
|
||||
}
|
||||
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user