mirror of
https://github.com/spring-projects/spring-security.git
synced 2025-06-08 13:12:12 +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 Saml2AuthenticationRequestRepository<?> authenticationRequests = new HttpSessionSaml2AuthenticationRequestRepository();
|
||||||
|
|
||||||
|
private boolean shouldConvertGetRequests = true;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Constructs a {@link BaseOpenSamlAuthenticationTokenConverter} given a repository
|
* Constructs a {@link BaseOpenSamlAuthenticationTokenConverter} given a repository
|
||||||
* for {@link RelyingPartyRegistration}s
|
* for {@link RelyingPartyRegistration}s
|
||||||
@ -172,13 +174,19 @@ final class BaseOpenSamlAuthenticationTokenConverter implements AuthenticationCo
|
|||||||
this.requestMatcher = requestMatcher;
|
this.requestMatcher = requestMatcher;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void setShouldConvertGetRequests(boolean shouldConvertGetRequests) {
|
||||||
|
this.shouldConvertGetRequests = shouldConvertGetRequests;
|
||||||
|
}
|
||||||
|
|
||||||
private String decode(HttpServletRequest request) {
|
private String decode(HttpServletRequest request) {
|
||||||
String encoded = request.getParameter(Saml2ParameterNames.SAML_RESPONSE);
|
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 {
|
try {
|
||||||
return Saml2Utils.withEncoded(encoded)
|
return decoding.decode();
|
||||||
.requireBase64(true)
|
|
||||||
.inflate(HttpMethod.GET.matches(request.getMethod()))
|
|
||||||
.decode();
|
|
||||||
}
|
}
|
||||||
catch (Exception ex) {
|
catch (Exception ex) {
|
||||||
throw new Saml2AuthenticationException(Saml2Error.invalidResponse(ex.getMessage()), ex);
|
throw new Saml2AuthenticationException(Saml2Error.invalidResponse(ex.getMessage()), ex);
|
||||||
|
@ -101,4 +101,14 @@ public final class OpenSaml4AuthenticationTokenConverter implements Authenticati
|
|||||||
this.delegate.setRequestMatcher(requestMatcher);
|
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);
|
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