From b2a2575896a0f35b19622ab4c218143c4fd1bb8b Mon Sep 17 00:00:00 2001 From: Maxime Besson Date: Fri, 24 Jul 2020 14:03:48 +0200 Subject: [PATCH] Fix incorrect SOAP content type in SAML issuer (#2263) --- .../lib/Lemonldap/NG/Portal/Auth/SAML.pm | 4 ++-- .../lib/Lemonldap/NG/Portal/Issuer/SAML.pm | 6 +++--- .../lib/Lemonldap/NG/Portal/Lib/SAML.pm | 10 +++++----- ...-issuer-SAML-Artifact-with-SOAP-SLO-IdP-initiated.t | 4 ++-- .../t/30-Auth-and-issuer-SAML-Artifact-with-SOAP-SLO.t | 4 ++-- 5 files changed, 14 insertions(+), 14 deletions(-) diff --git a/lemonldap-ng-portal/lib/Lemonldap/NG/Portal/Auth/SAML.pm b/lemonldap-ng-portal/lib/Lemonldap/NG/Portal/Auth/SAML.pm index 37cbc269f..d749d9511 100644 --- a/lemonldap-ng-portal/lib/Lemonldap/NG/Portal/Auth/SAML.pm +++ b/lemonldap-ng-portal/lib/Lemonldap/NG/Portal/Auth/SAML.pm @@ -778,7 +778,7 @@ sub extractFormInfo { $req->response( [ 200, [ - 'Content-Type' => 'application/xml', + 'Content-Type' => 'text/xml', 'Content-Length' => length($slo_body) ], [$slo_body] @@ -846,7 +846,7 @@ sub extractFormInfo { $req->response( [ 200, [ - 'Content-Type' => 'application/xml', + 'Content-Type' => 'text/xml', 'Content-Length' => length($art_response) ], [$art_response] diff --git a/lemonldap-ng-portal/lib/Lemonldap/NG/Portal/Issuer/SAML.pm b/lemonldap-ng-portal/lib/Lemonldap/NG/Portal/Issuer/SAML.pm index 71fec2837..af60885cd 100644 --- a/lemonldap-ng-portal/lib/Lemonldap/NG/Portal/Issuer/SAML.pm +++ b/lemonldap-ng-portal/lib/Lemonldap/NG/Portal/Issuer/SAML.pm @@ -1054,7 +1054,7 @@ sub artifactServer { return [ 200, [ - 'Content-Type' => 'application/xml', + 'Content-Type' => 'text/xml', 'Content-Length' => length($art_response) ], [$art_response] @@ -1259,7 +1259,7 @@ sub soapSloServer { return [ 200, [ - 'Content-Type' => 'application/xml', + 'Content-Type' => 'text/xml', 'Content-Length' => length($slo_body) ], [$slo_body] @@ -2107,7 +2107,7 @@ sub attributeServer { return [ 200, [ - 'Content-Type' => 'application/xml', + 'Content-Type' => 'text/xml', 'Content-Length' => length($att_response) ], [$att_response] diff --git a/lemonldap-ng-portal/lib/Lemonldap/NG/Portal/Lib/SAML.pm b/lemonldap-ng-portal/lib/Lemonldap/NG/Portal/Lib/SAML.pm index 400da4292..c36a2aec0 100644 --- a/lemonldap-ng-portal/lib/Lemonldap/NG/Portal/Lib/SAML.pm +++ b/lemonldap-ng-portal/lib/Lemonldap/NG/Portal/Lib/SAML.pm @@ -1779,8 +1779,8 @@ sub resolveArtifact { } my $request = HTTP::Request->new( 'POST' => $profile->msg_url ); - $request->content_type('application/xml'); - $request->header( Accept => 'application/xml' ); + $request->content_type('text/xml'); + $request->header( Accept => 'text/xml' ); $request->content( $profile->msg_body ); $self->logger->debug( @@ -2001,8 +2001,8 @@ sub sendSOAPMessage { my $response; my $request = HTTP::Request->new( 'POST' => $endpoint ); - $request->content_type('application/xml'); - $request->header( Accept => 'application/xml' ); + $request->content_type('text/xml'); + $request->header( Accept => 'text/xml' ); $request->content($message); $self->logger->debug("Send SOAP message $message to $endpoint"); @@ -3088,7 +3088,7 @@ sub sendSLOSoapErrorResponse { return [ 200, [ - 'Content-Type' => 'application/xml', + 'Content-Type' => 'text/xml', 'Content-Length' => length($slo_body) ], [$slo_body] diff --git a/lemonldap-ng-portal/t/30-Auth-and-issuer-SAML-Artifact-with-SOAP-SLO-IdP-initiated.t b/lemonldap-ng-portal/t/30-Auth-and-issuer-SAML-Artifact-with-SOAP-SLO-IdP-initiated.t index 71aa158b7..f2e7e74a2 100644 --- a/lemonldap-ng-portal/t/30-Auth-and-issuer-SAML-Artifact-with-SOAP-SLO-IdP-initiated.t +++ b/lemonldap-ng-portal/t/30-Auth-and-issuer-SAML-Artifact-with-SOAP-SLO-IdP-initiated.t @@ -35,9 +35,9 @@ LWP::Protocol::PSGI->register( ); ok( ( $res->[0] == 200 or $res->[0] == 400 ), 'Response is 200 or 400' ) or explain( $res->[0], "200 or 400" ); - ok( getHeader( $res, 'Content-Type' ) =~ m#^application/xml#, + ok( getHeader( $res, 'Content-Type' ) =~ m#^text/xml#, 'Content is XML' ) - or explain( $res->[1], 'Content-Type => application/xml' ); + or explain( $res->[1], 'Content-Type => text/xml' ); count(4); return $res; } diff --git a/lemonldap-ng-portal/t/30-Auth-and-issuer-SAML-Artifact-with-SOAP-SLO.t b/lemonldap-ng-portal/t/30-Auth-and-issuer-SAML-Artifact-with-SOAP-SLO.t index 76f927f56..6cc816d05 100644 --- a/lemonldap-ng-portal/t/30-Auth-and-issuer-SAML-Artifact-with-SOAP-SLO.t +++ b/lemonldap-ng-portal/t/30-Auth-and-issuer-SAML-Artifact-with-SOAP-SLO.t @@ -34,9 +34,9 @@ LWP::Protocol::PSGI->register( 'Execute request' ); expectOK($res); - ok( getHeader( $res, 'Content-Type' ) =~ m#^application/xml#, + ok( getHeader( $res, 'Content-Type' ) =~ m#^text/xml#, 'Content is XML' ) - or explain( $res->[1], 'Content-Type => application/xml' ); + or explain( $res->[1], 'Content-Type => text/xml' ); count(3); return $res; }