8000 Close limited SOAP request streams in SAML endpoints by ahus1 · Pull Request #55171 · keycloak/keycloak · GitHub
[go: up one dir, main page]

Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
8000 Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -1210,7 +1210,13 @@ public AuthenticationSessionModel getOrCreateLoginSessionForIdpInitiatedSso(Keyc
@NoCache
@Consumes({"application/soap+xml", MediaType.TEXT_XML})
public Response artifactResolutionService(InputStream inputStream) {
Document soapBodyContents = Soap.extractSoapMessage(SamlProtocolUtils.limit(inputStream, maxSoapMessageRequestSize));
Document soapBodyContents;
try (InputStream limitedInputStream = SamlProtocolUtils.limit(inputStream, maxSoapMessageRequestSize)) {
soapBodyContents = Soap.extractSoapMessage(limitedInputStream);
} catch (IOException e) {
logger.debug("Error while closing the SOAP request stream", e);
return Soap.createFault().reason("").detail("").build();
}
ArtifactResolveType artifactResolveType = null;
SAMLDocumentHolder samlDocumentHolder = null;
try {
Expand Down Expand Up @@ -1262,7 +1268,7 @@ public Response artifactResolutionService(InputStream inputStream) {
public Response soapBinding(InputStream inputStream) {
SamlEcpProfileService bindingService = new SamlEcpProfileService(session, event, maxInflatingSize, destinationValidator, maxSoapMessageRequestSize, enableSaml11);

return bindingService.authenticate(SamlProtocolUtils.limit(inputStream, maxSoapMessageRequestSize));
return bindingService.authenticate(inputStream);
}

private ClientModel getAndCheckClientModel(String clientSessionId, String clientId) throws ProcessingException {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -67,12 +67,14 @@ public SamlEcpProfileService(KeycloakSession session, EventBuilder event, long m
}

public Response authenticate(InputStream inputStream) {
try {
return authenticate(Soap.extractSoapMessage(SamlProtocolUtils.limit(inputStream, maxSoapMessageRequestSize)));
Document soapMessage;
try (InputStream limitedInputStream = SamlProtocolUtils.limit(inputStream, maxSoapMessageRequestSize)) {
soapMessage = Soap.extractSoapMessage(limitedInputStream);
} catch (Exception e) {
logger.debugf(e, "Error while processing SOAP request.");
return Soap.createFault().reason("Some error occurred while processing the SOAP request.").build();
}
return authenticate(soapMessage);
}

public Response authenticate(Document soapMessage) {
Expand Down
Loading
0