public function test_decrypt()
    {
        $xml = <<<EOT
<?xml version="1.0"?>
<samlp:Response xmlns:samlp="urn:oasis:names:tc:SAML:2.0:protocol" ID="_973220eb0b94e0367859487a8135e7855742ae2431" InResponseTo="_981d6909d57a6131e98da42ac76720776bd2a59d25" Version="2.0" IssueInstant="2015-09-28T07:24:17Z" Destination="https://localhost/lightsaml/lightSAML/web/sp/acs.php"><saml:Issuer xmlns:saml="urn:oasis:names:tc:SAML:2.0:assertion" Format="urn:oasis:names:tc:SAML:2.0:nameid-format:entity">https://lightsaml.local/idp</saml:Issuer><ds:Signature xmlns:ds="http://www.w3.org/2000/09/xmldsig#">
  <ds:SignedInfo><ds:CanonicalizationMethod Algorithm="http://www.w3.org/2001/10/xml-exc-c14n#"/>
    <ds:SignatureMethod Algorithm="http://www.w3.org/2000/09/xmldsig#rsa-sha1"/>
  <ds:Reference URI="#_973220eb0b94e0367859487a8135e7855742ae2431"><ds:Transforms><ds:Transform Algorithm="http://www.w3.org/2000/09/xmldsig#enveloped-signature"/><ds:Transform Algorithm="http://www.w3.org/2001/10/xml-exc-c14n#"/></ds:Transforms><ds:DigestMethod Algorithm="http://www.w3.org/2000/09/xmldsig#sha1"/><ds:DigestValue>FKXI2BoZn0ix6Yc5m3QM3PDV8dQ=</ds:DigestValue></ds:Reference></ds:SignedInfo><ds:SignatureValue>o6redfiU43TO5s0RtHUj9R0PSZVJryAs1e39biVOm84Xrd/n9IKCui3vWd9bN/wBAD9/ZZ4b48fMKfLI0hRivNEi9yJZb91uavdU1StjgpckdZtWdt315zf1+p4+xqnFAtDMWcTP3V8XAGuGfBUT+VndsS7VHVjzSjCj6+qC123TBpJ7HvC9sFUbH+uXgJaK71so8b3z79VH3C26Qnly3bmmARLkNZL8bnwlHJA/BrG/kJN5Lgv6tKB6xRbYU0grSGsA1Vt/nk2bpIGYPZU3SOIVVLUoHTkA6gGceKyJNqPcfJQVNpljTxqZjsJy7mZF9coWBSbTr5DRiGjd9pFOUA==</ds:SignatureValue>
<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gAPMMUbkLP9DFWkjbK241isCZZD/LvA1anbV+7Pidn+swZ5dR7ynX2vj0kFYb+VsGPkavNcj8RN/DduhN/Tmi5sQAlWhaw06UAeEqXtFeLbTgLffBaj7PmR0IYjvTZA0X2FdRu0GXRxn7zghjpvSq9nuWa3pGbfdVtL6GIkwYUPcDzjr4OeGXNmIZe/wMCnz6VGZY+LUgzi/4DAC6V3OjMuhdqS/2+o1+CXCwN08CIHQV6+AUBenEVawMsiadLBgx3kFe5iXrYRMA=</ds:X509Certificate></ds:X509Data></ds:KeyInfo></ds:Signature><ds:Signature xmlns:ds="http://www.w3.org/2000/09/xmldsig#">
  <ds:SignedInfo><ds:CanonicalizationMethod Algorithm="http://www.w3.org/2001/10/xml-exc-c14n#"/>
    <ds:SignatureMethod Algorithm="http://www.w3.org/2000/09/xmldsig#rsa-sha1"/>
  <ds:Reference URI="#_973220eb0b94e0367859487a8135e7855742ae2431"><ds:Transforms><ds:Transform Algorithm="http://www.w3.org/2000/09/xmldsig#enveloped-signature"/><ds:Transform Algorithm="http://www.w3.org/2001/10/xml-exc-c14n#"/></ds:Transforms><ds:DigestMethod Algorithm="http://www.w3.org/2000/09/xmldsig#sha1"/><ds:DigestValue>yo6ajbd+5N4zfH1IK+Up21KDuQw=</ds:DigestValue></ds:Reference></ds:SignedInfo><ds:SignatureValue>ETYMDZA7IzajOPOqxrLjQImiEhC92u3k3ICoeytaI2KtLRK76hsWtNGIABvSAERUaCpHq+Uzit3yxTTXnCz1lHNzhKL27i42YwbMUe5IWRUYCVk1fJVrAcjWYYsnFMeBq7KRP8a5fHeg9PcIAZoEVz48DOUyx+kSArv2eF8B07fayu2Xp6fVGlJHAOcFWh6mK9ahLhEO3u4cLlvzVH0djF3jsY/qcH6xSK+dXu3JIgo84iJCIVayjxHbYYWA85/gnanODQ+t6cQmVqUztTfgebORgJ+PCXi5FxLPgSJM/PzO/uQ5TavKNuG3rmjjc9nHEYTrdFQ2OOU/gkLi+y31Iw==</ds:SignatureValue>
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KgAPMMUbkLP9DFWkjbK241isCZZD/LvA1anbV+7Pidn+swZ5dR7ynX2vj0kFYb+VsGPkavNcj8RN/DduhN/Tmi5sQAlWhaw06UAeEqXtFeLbTgLffBaj7PmR0IYjvTZA0X2FdRu0GXRxn7zghjpvSq9nuWa3pGbfdVtL6GIkwYUPcDzjr4OeGXNmIZe/wMCnz6VGZY+LUgzi/4DAC6V3OjMuhdqS/2+o1+CXCwN08CIHQV6+AUBenEVawMsiadLBgx3kFe5iXrYRMA=</ds:X509Certificate></ds:X509Data></ds:KeyInfo></ds:Signature><samlp:Status><samlp:StatusCode Value="urn:oasis:names:tc:SAML:2.0:status:Success"/></samlp:Status><saml:EncryptedAssertion xmlns:saml="urn:oasis:names:tc:SAML:2.0:assertion"><xenc:EncryptedData xmlns:xenc="http://www.w3.org/2001/04/xmlenc#" xmlns:dsig="http://www.w3.org/2000/09/xmldsig#" Type="http://www.w3.org/2001/04/xmlenc#Element"><xenc:EncryptionMethod Algorithm="http://www.w3.org/2001/04/xmlenc#aes128-cbc"/><dsig:KeyInfo xmlns:dsig="http://www.w3.org/2000/09/xmldsig#"><xenc:EncryptedKey><xenc:EncryptionMethod Algorithm="http://www.w3.org/2000/09/xmldsig#rsa-sha1"/><xenc:CipherData><xenc:CipherValue>eBXzY5t2TX8r2uNK3aO+4w4K26kGTMgYUaUL22CI4Ntb4Y2tPvenP0R/ncf0GLUXcfwtLLq9dXfV+PI0fucdu9lSZ2yqjj63aBMMZUlxtKA0WXAOI7JX0kj8TG8PFOau+ByLOlUT1oxibCcNT/Xae6YS2muvR3oM3ADn5EOEVKx5Ubzo8WoKxDBjEAluzruikc6gkyoWRexnUlYuhm0XaAnzDz8+9qYIriRoAk+wxmD8eJ6WwRcdahIpCotJ2LaJ/SGmp388x8l6C5G+ITxe5fJScQpUr1bb/UKL3r6mV9NMF0yAe2LfqlJLHQ3iYCcJKRsn59CmLPH1ku+8yd1low==</xenc:CipherValue></xenc:CipherData></xenc:EncryptedKey></dsig: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g5DGK8Qzg0b3ruzpXPDfKpAV8C0gt28+02HO8ThhDh1i+LssR8/nUO+0E6bKDmFADnFb/ISx3L8fj1MCyrDrwo0P9WUhYd9a0UDg2ty8Slb+8FLjtwqxY6ADphwgtkfbTJbZgCkDu7+bOScTZ31+cSqEFqEDljrdKIljvH2vMMty3mnUm59IahghWy3UIgtmW3UjtUC/IRxCk63vgjOKVhs/RzCQzOCk5hUO/W4L0XNEYo7dpEauRDNCVkMJ70PRWognr5u6Yoq2zM=</xenc:CipherValue>
   </xenc:CipherData>
</xenc:EncryptedData></saml:EncryptedAssertion></samlp:Response>

EOT;
        $deserializationContext = new DeserializationContext();
        $deserializationContext->getDocument()->loadXML($xml);
        $response = new Response();
        $response->deserialize($deserializationContext->getDocument()->firstChild, $deserializationContext);
        $credential = new X509Credential(X509Certificate::fromFile(__DIR__ . '/../../../../../../resources/sample/Certificate/lightsaml-idp.crt'), KeyHelper::createPrivateKey(__DIR__ . '/../../../../../../resources/sample/Certificate/lightsaml-idp.key', '', true));
        $decryptDeserializeContext = new DeserializationContext();
        /** @var EncryptedAssertionReader $reader */
        $reader = $response->getFirstEncryptedAssertion();
        $assertion = $reader->decryptMultiAssertion([$credential], $decryptDeserializeContext);
        $this->assertEquals('_c9cbe081e1b1294c9ea31d98f4a473a081466502a0', $assertion->getId());
        $this->assertEquals('https://lightsaml.local/idp', $assertion->getIssuer()->getValue());
        $this->assertEquals('*****@*****.**', $assertion->getSubject()->getNameID()->getValue());
        $this->assertEquals('common-name', $assertion->getFirstAttributeStatement()->getFirstAttributeByName(ClaimTypes::COMMON_NAME)->getFirstAttributeValue());
        $this->assertEquals('*****@*****.**', $assertion->getFirstAttributeStatement()->getFirstAttributeByName(ClaimTypes::EMAIL_ADDRESS)->getFirstAttributeValue());
    }
 /**
  * @param  string $email
  * @param  string $message_id
  * @return string
  */
 public function send($email, $message_id)
 {
     $message = $this->saml_data_manager->get($message_id);
     if (!$message) {
         if ($this->logger) {
             $this->logger->error("Saml message with id {$message_id} not found or expired");
         }
         throw new RuntimeException('Authentication message does not exist');
     }
     $this->saml_data_manager->delete($message_id);
     $response = new Response();
     $assertion = new Assertion();
     $response->addAssertion($assertion)->setID(Helper::generateID())->setIssueInstant(new DateTime())->setDestination($message->getAssertionConsumerServiceURL())->setIssuer(new Issuer($message->getIssuer()->getValue()));
     $assertion->setId(Helper::generateID())->setIssueInstant(new DateTime())->setIssuer(new Issuer($message->getIssuer()->getValue()))->setSubject((new Subject())->setNameID(new NameID($email, SamlConstants::NAME_ID_FORMAT_EMAIL))->addSubjectConfirmation((new SubjectConfirmation())->setMethod(SamlConstants::CONFIRMATION_METHOD_BEARER)->setSubjectConfirmationData((new SubjectConfirmationData())->setInResponseTo($message->getID())->setNotOnOrAfter(new DateTime('+1 MINUTE'))->setRecipient($message->getAssertionConsumerServiceURL()))))->setConditions((new Conditions())->setNotBefore(new DateTime())->setNotOnOrAfter(new DateTime('+1 MINUTE'))->addItem(new AudienceRestriction([$message->getAssertionConsumerServiceURL()])))->addItem((new AttributeStatement())->addAttribute(new Attribute(ClaimTypes::EMAIL_ADDRESS, $email)))->addItem((new AuthnStatement())->setAuthnInstant(new DateTime('-10 MINUTE'))->setSessionIndex($message_id)->setAuthnContext((new AuthnContext())->setAuthnContextClassRef(SamlConstants::AUTHN_CONTEXT_PASSWORD_PROTECTED_TRANSPORT)));
     $certificate = X509Certificate::fromFile($this->saml_crt);
     $private_key = KeyHelper::createPrivateKey($this->saml_key, '', true);
     $response->setSignature(new SignatureWriter($certificate, $private_key));
     $binding_factory = new BindingFactory();
     $post_binding = $binding_factory->create(SamlConstants::BINDING_SAML2_HTTP_POST);
     $message_context = new MessageContext();
     $message_context->setMessage($response);
     /** @var SymfonyResponse $http_response */
     $http_response = $post_binding->send($message_context);
     return $http_response->getContent();
 }
 public function test_response()
 {
     $response = new Response();
     $response->addAssertion($assertion = new Assertion())->setStatus(new Status(new StatusCode(SamlConstants::STATUS_SUCCESS)));
     $assertion->setId(Helper::generateID())->setIssuer(new Issuer('https://issuer.com'));
     $this->verify($response);
 }
 public function test_does_nothing_if_response_has_at_least_one_assertion()
 {
     $action = new HasAssertionsValidatorAction(TestHelper::getLoggerMock($this));
     $context = new ProfileContext(Profiles::SSO_IDP_RECEIVE_AUTHN_REQUEST, ProfileContext::ROLE_IDP);
     $context->getInboundContext()->setMessage($response = new Response());
     $response->addAssertion(new Assertion());
     $action->execute($context);
 }
 /**
  * @param Response $response
  *
  * @return string|null
  */
 public function getUsername(Response $response)
 {
     foreach ($response->getAllAssertions() as $assertion) {
         $username = $this->getUsernameFromAssertion($assertion);
         if ($username) {
             return $username;
         }
     }
     return null;
 }
Esempio n. 6
0
 /**
  * @expectedException \LightSaml\Error\LightSamlAuthenticationException
  * @expectedExceptionMessage("Unsuccessful SAML response: urn:oasis:names:tc:SAML:2.0:status:Requester
  * urn:oasis:names:tc:SAML:2.0:status:UnsupportedBinding")
  */
 public function test_throws_authentication_exception_if_status_not_success()
 {
     $action = new StatusAction($loggerMock = TestHelper::getLoggerMock($this));
     $context = new ProfileContext(Profiles::SSO_IDP_RECEIVE_AUTHN_REQUEST, ProfileContext::ROLE_IDP);
     $context->getInboundContext()->setMessage($response = new Response());
     $response->setStatus(new Status($statusCode = new StatusCode(SamlConstants::STATUS_REQUESTER)));
     $statusCode->setStatusCode(new StatusCode(SamlConstants::STATUS_UNSUPPORTED_BINDING));
     $loggerMock->expects($this->once())->method('error');
     $action->execute($context);
 }
Esempio n. 7
0
 public function test_success_response_with_xsd()
 {
     $response = new Response();
     $response->setStatus(new Status(new StatusCode(SamlConstants::STATUS_SUCCESS)))->setInResponseTo(Helper::generateID())->setID(Helper::generateID())->setIssueInstant(new \DateTime())->setIssuer(new Issuer('https://idp.com'));
     $response->addAssertion($assertion = new Assertion());
     $assertion->setId(Helper::generateID())->setIssueInstant(new \DateTime())->setIssuer(new Issuer('https://idp.com'))->setSubject((new Subject())->setNameID(new NameID('*****@*****.**', SamlConstants::NAME_ID_FORMAT_EMAIL))->addSubjectConfirmation((new SubjectConfirmation())->setMethod(SamlConstants::CONFIRMATION_METHOD_BEARER)->setSubjectConfirmationData((new SubjectConfirmationData())->setInResponseTo(Helper::generateID())->setNotOnOrAfter(new \DateTime('+1 hour'))->setRecipient('https://sp.com/acs'))))->setConditions((new Conditions())->setNotBefore(new \DateTime())->setNotOnOrAfter(new \DateTime('+1 hour'))->addItem(new AudienceRestriction(['https://sp.com/acs'])))->addItem((new AttributeStatement())->addAttribute(new Attribute(ClaimTypes::EMAIL_ADDRESS, '*****@*****.**')))->addItem((new AuthnStatement())->setAuthnInstant(new \DateTime('-1 hour'))->setSessionIndex(Helper::generateID())->setAuthnContext((new AuthnContext())->setAuthnContextClassRef(SamlConstants::AUTHN_CONTEXT_PASSWORD_PROTECTED_TRANSPORT)));
     $this->sign($assertion);
     $this->sign($response);
     $this->validateProtocol($response);
 }
 /**
  * @expectedException \LightSaml\Error\LightSamlContextException
  * @expectedExceptionMessage No credentials resolved for assertion decryption
  */
 public function test_throws_context_exception_when_no_credentials_resolved()
 {
     $action = new DecryptAssertionsAction($loggerMock = TestHelper::getLoggerMock($this), $credentialResolverMock = $this->getCredentialResolverMock());
     $context = new ProfileContext(Profiles::SSO_IDP_RECEIVE_AUTHN_REQUEST, ProfileContext::ROLE_IDP);
     $context->getOwnEntityContext()->setEntityDescriptor(new EntityDescriptor($entityId = 'http://entity.id'));
     $context->getInboundContext()->setMessage($response = new Response());
     $response->addEncryptedAssertion($encryptedAssertionMock1 = $this->getEncryptedAssertionReaderMock());
     $credentialResolverMock->expects($this->once())->method('query')->willReturn($query = new CredentialResolverQuery($credentialResolverMock));
     $credentialResolverMock->expects($this->once())->method('resolve')->with($query)->willReturn([]);
     $action->execute($context);
 }
 public function test_does_nothing_if_there_is_bearer_assertion()
 {
     $action = new HasBearerAssertionsValidatorAction(TestHelper::getLoggerMock($this));
     $context = new ProfileContext(Profiles::SSO_IDP_RECEIVE_AUTHN_REQUEST, ProfileContext::ROLE_IDP);
     $context->getInboundContext()->setMessage($response = new Response());
     $response->addAssertion($assertion = new Assertion());
     $assertion->addItem(new AuthnStatement());
     $assertion->setSubject($subject = new Subject());
     $subject->addSubjectConfirmation($subjectConfirmation = new SubjectConfirmation());
     $subjectConfirmation->setMethod(SamlConstants::CONFIRMATION_METHOD_BEARER);
     $action->execute($context);
 }
Esempio n. 10
0
 public function test_creates_context_for_each_assertion()
 {
     $action = new AssertionAction(TestHelper::getLoggerMock($this), $assertionActionMock = $this->getActionMock());
     $context = new ProfileContext(Profiles::SSO_IDP_RECEIVE_AUTHN_REQUEST, ProfileContext::ROLE_IDP);
     $context->getInboundContext()->setMessage($response = new Response());
     $response->addAssertion($assertion1 = new Assertion())->addAssertion($assertion2 = new Assertion());
     $action->execute($context);
     /** @var AssertionContext $assertionContext */
     $assertionContext = $context->getSubContext('assertion_0');
     $this->assertInstanceOf(AssertionContext::class, $assertionContext);
     $this->assertSame($assertion1, $assertionContext->getAssertion());
     $assertionContext = $context->getSubContext('assertion_1');
     $this->assertInstanceOf(AssertionContext::class, $assertionContext);
     $this->assertSame($assertion2, $assertionContext->getAssertion());
 }
Esempio n. 11
0
 public function test_calls_session_processor()
 {
     $action = new SpSsoStateAction(TestHelper::getLoggerMock($this), $sessionProcessorMock = $this->getSessionProcessorMock());
     $context = new ProfileContext(Profiles::SSO_IDP_RECEIVE_AUTHN_REQUEST, ProfileContext::ROLE_IDP);
     $context->getInboundContext()->setMessage($response = new Response());
     $response->addAssertion($assertion1 = new Assertion());
     $response->addAssertion($assertion2 = new Assertion());
     $context->getOwnEntityContext()->setEntityDescriptor(new EntityDescriptor($ownEntityId = 'http://own.entity.id'));
     $context->getPartyEntityContext()->setEntityDescriptor(new EntityDescriptor($partyEntityId = 'http://party.id'));
     $sessionProcessorMock->expects($this->once())->method('processAssertions')->with($this->isType('array'), $ownEntityId, $partyEntityId)->willReturnCallback(function (array $assertions, $ownId, $partyId) use($assertion1, $assertion2) {
         $this->assertSame($assertion1, $assertions[0]);
         $this->assertSame($assertion2, $assertions[1]);
     });
     $action->execute($context);
 }
Esempio n. 12
0
 /**
  * @param  Response $response
  * @return string
  */
 public function getIssuerUrl(Response $response)
 {
     return $response->getIssuer()->getValue();
 }
Esempio n. 13
0
 /**
  * @return Response
  */
 private function getResponseObject()
 {
     $response = new Response();
     $response->setId('response-id')->setIssueInstant('2013-10-27T11:55:37Z')->setDestination('http://destination.com')->setConsent(SamlConstants::CONSENT_UNSPECIFIED)->setInResponseTo('in-reponse-to')->addAssertion((new Assertion())->setId('assertion-id')->setIssueInstant('2013-10-27T11:55:37Z')->setIssuer((new Issuer())->setValue('assertion-issuer'))->setSubject((new Subject())->setNameID((new NameID())->setValue('assertion-name-id')->setFormat(SamlConstants::NAME_ID_FORMAT_PERSISTENT))->addSubjectConfirmation((new SubjectConfirmation())->setMethod(SamlConstants::CONFIRMATION_METHOD_BEARER)->setSubjectConfirmationData((new SubjectConfirmationData())->setInResponseTo('assertion-in-response-to')->setNotOnOrAfter('2013-10-27T12:00:37Z')->setRecipient('http://recipient.com'))))->setConditions((new Conditions())->setNotBefore('2013-10-27T11:55:37Z')->setNotOnOrAfter('2013-10-27T12:55:37Z')->addItem((new AudienceRestriction())->addAudience('http://audience.com')))->addItem((new AttributeStatement())->addAttribute((new Attribute())->setName(ClaimTypes::COMMON_NAME)->setFriendlyName('Common Name')->addAttributeValue('cn value'))->addAttribute((new Attribute())->setName(ClaimTypes::GROUP)->setFriendlyName('Group')->addAttributeValue('group one')->addAttributeValue('group two')))->addItem((new AuthnStatement())->setAuthnInstant('2013-10-27T11:55:36Z')->setSessionIndex('session-index')->setAuthnContext((new AuthnContext())->setAuthnContextClassRef('authn-context-class-ref')))->setSignature(new SignatureWriter(X509Certificate::fromFile(__DIR__ . '/../../../../../resources/sample/Certificate/saml.crt'), KeyHelper::createPrivateKey(__DIR__ . '/../../../../../resources/sample/Certificate/saml.pem', '', true))))->setIssuer((new Issuer())->setValue('the-issuer'));
     return $response;
 }
    public function test_deserialize_invalid02()
    {
        $context = new DeserializationContext();
        $context->getDocument()->load(__DIR__ . '/../../../../../../resources/sample/Response/invalid02.xml');
        $response = new Response();
        $response->deserialize($context->getDocument(), $context);
        $this->assertEquals('_274be8a4-c2ba-43ca-a7c6-2f1613762576', $response->getID());
        $this->assertEquals('2.0', $response->getVersion());
        $this->assertEquals('2013-11-17T12:35:10Z', $response->getIssueInstantString());
        $this->assertEquals('_b04e5e6166a0ba08f3ae9327a7145498e9f8a60e2f', $response->getInResponseTo());
        $this->assertNotNull($response->getIssuer());
        $this->assertEquals('https://sts.windows.net/554fadfe-f04f-4975-90cb-ddc8b147aaa2/', $response->getIssuer()->getValue());
        $this->assertNotNull($response->getStatus());
        $this->assertEquals(SamlConstants::STATUS_REQUESTER, $response->getStatus()->getStatusCode()->getValue());
        $this->assertEquals(SamlConstants::STATUS_UNSUPPORTED_BINDING, $response->getStatus()->getStatusCode()->getStatusCode()->getValue());
        $expectedMessage = <<<EOT
ACS75006: An error occurred while processing a SAML2 Authentication request. ACS75003: SAML protocol response cannot be sent via bindings other than HTTP POST. Requested binding: urn:oasis:names:tc:SAML:2.0:bindings:HTTP-Redirect
            Trace ID: d75d5305-d3fc-40b0-9087-d59032682dd9
            Correlation ID: ca26b4bd-23d4-4233-9c28-96bc0a336c39
            Timestamp: 2013-11-17 12:35:10Z
EOT;
        $expectedMessage = trim(str_replace("\r", '', $expectedMessage));
        $this->assertEquals($expectedMessage, trim(str_replace("\r", '', $response->getStatus()->getStatusMessage())));
        $this->assertCount(0, $response->getAllAssertions());
    }