Skip to content

Commit 35e4cac

Browse files
tvdijenthijskh
andauthored
Fix SOAP binding Content-Type and SOAPAction processing (#314)
Removed incorrect application/soap+xml; this is SOAP 1.2 specific and SAML2 doesn't support that Co-authored-by: Thijs Kinkhorst <thijs@kinkhorst.com>
1 parent 3954916 commit 35e4cac

2 files changed

Lines changed: 19 additions & 2 deletions

File tree

src/SAML2/Binding.php

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,15 @@ public static function getCurrentBinding() : Binding
8787
return new HTTPPost();
8888
} elseif (array_key_exists('SAMLart', $_POST)) {
8989
return new HTTPArtifact();
90-
} elseif ($contentType === 'text/xml' || $contentType === 'application/soap+xml') {
90+
} elseif (
91+
/**
92+
* The registration information for text/xml is in all respects the same
93+
* as that given for application/xml (RFC 7303 - Section 9.1)
94+
*/
95+
($contentType === 'text/xml' || $contentType === 'application/xml')
96+
// See paragraph 3.2.3 of Binding for SAML2 (OASIS)
97+
|| (isset($_SERVER['HTTP_SOAPACTION']) && $_SERVER['HTTP_SOAPACTION'] === 'http://www.oasis-open.org/committees/security'))
98+
{
9199
return new SOAP();
92100
}
93101
break;

tests/SAML2/BindingTest.php

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -78,12 +78,21 @@ public function testBindingGuesserPOST() : void
7878
$bind = Binding::getCurrentBinding();
7979
$this->assertInstanceOf(SOAP::class, $bind);
8080

81+
$_SERVER['CONTENT_TYPE'] = 'application/xml';
82+
$bind = Binding::getCurrentBinding();
83+
$this->assertInstanceOf(SOAP::class, $bind);
84+
85+
unset($_SERVER['CONTENT_TYPE']);
86+
$_SERVER['HTTP_SOAPACTION'] = 'http://www.oasis-open.org/committees/security';
87+
$bind = Binding::getCurrentBinding();
88+
$this->assertInstanceOf(SOAP::class, $bind);
89+
unset($_SERVER['HTTP_SOAPACTION']);
90+
8191
$_POST = ['SAMLart' => 'AAQAAI4sWYpfoDDYJrHzsMnG+jyNM94p5ejn49a+nZ0s3ylY7knQ6tkLMDE='];
8292
$bind = Binding::getCurrentBinding();
8393
$this->assertInstanceOf(HTTPArtifact::class, $bind);
8494

8595
$_POST = ['AAP' => 'Noot'];
86-
unset($_SERVER['CONTENT_TYPE']);
8796
$this->expectException(UnsupportedBindingException::class, 'Unable to find the current binding.');
8897
$bind = Binding::getCurrentBinding();
8998
}

0 commit comments

Comments
 (0)