Implementace(1) - Získání adresy pro přesměrování uživatele

Prvním krokem je získání informací z metadat IdP

V dokumentaci je uveden odkaz na metadata NIA IdP FederationMetadata.xml

Více informací o NIA IdP metadatech je uvedeno na stránce IdP - Úvod

Postup

  1. Stažení souboru metadat
  2. Ověření obsahu metadat (dle RSA-SHA256 signatury XMLDSIG)
  3. Získání adresy pro přesměrování uživatele

1. stažení souboru a parsování jeho dat

    
 <?php
 // použijeme knihovnu simplesamlphp/saml2 z https://github.com/simplesamlphp/saml2
 use SAML2\XML\md\EntityDescriptor;
 use SAML2\DOMDocumentFactory;

 $metadata_url = "https://tnia.eidentita.cz/FPSTS/FederationMetadata/2007-06/FederationMetadata.xml";
 $metadata_string = file_get_contents($metadata_url);
 $metadata_dom = DOMDocumentFactory::fromString($metadata_string);
 $metadata = new EntityDescriptor($metadata_dom->documentElement);
 // také lze využít metodu DOMDocumentFactory::fromFile($filepath); pokud máte metadata stažena lokálně

Objekt následovně obsahuje tato data:
^ SAML2\XML\md\EntityDescriptor {#86
  -entityID: "urn:microsoft:cgg2010:fpsts"
  -ID: "_7d7065a7-b853-4169-ac23-b9182dc4a9a4"
  -Extensions: []
  -RoleDescriptor: array:2 [
    0 => SAML2\XML\md\UnknownRoleDescriptor {#91
      -xml: SAML2\XML\Chunk {#96
        -localName: "RoleDescriptor"
        -namespaceURI: "urn:oasis:names:tc:SAML:2.0:metadata"
        -xml: DOMElement {#98
          +nodeName: "RoleDescriptor"
          +nodeValue: ""
          +nodeType: XML_ELEMENT_NODE
          +parentNode: null
          +childNodes: DOMNodeList {#131
            +length: 5
          }
          +firstChild: DOMElement {#133 …}
          +lastChild: DOMElement {#135 …}
          +previousSibling: null
          +nextSibling: null
          +attributes: DOMNamedNodeMap {#138
            +length: 2
          }
          +ownerDocument: DOMDocument {#140 …}
          +namespaceURI: "urn:oasis:names:tc:SAML:2.0:metadata"
          +prefix: ""
          +localName: "RoleDescriptor"
          +baseURI: null
          +textContent: ""
          +tagName: "RoleDescriptor"
          +schemaTypeInfo: null
        }
      }
      -elementName: "md:RoleDescriptor"
      -ID: null
      -protocolSupportEnumeration: array:1 [
        0 => "http://docs.oasis-open.org/wsfed/federation/200706"
      ]
      -errorURL: null
      -Extensions: []
      -KeyDescriptor: array:1 [
        0 => SAML2\XML\md\KeyDescriptor {#95
          -use: "signing"
          -KeyInfo: SAML2\XML\ds\KeyInfo {#94
            -Id: null
            -info: array:1 [
              0 => SAML2\XML\ds\X509Data {#101
                -data: array:1 [
                  0 => SAML2\XML\ds\X509Certificate {#103
                    -certificate: "MIIH0jCCBbqgAwIBAgIEAVDtYDANBgkqhkiG9w0BAQsFADBpMQswCQYDVQQGEwJDWjEXMBUGA1UEYRMOTlRSQ1otNDcxMTQ5ODMxHTAbBgNVBAoMFMSMZXNrw6EgcG/FoXRhLCBzLnAuMSIwIAYDVQQDExlQb3N0U2lnbnVtIFF1YWxpZmllZCBDQSA0MB4XDTIwMDIxOTA4NDE0MloXDTIxMDMxMDA4NDE0MloweTELMAkGA1UEBhMCQ1oxFzAVBgNVBGETDk5UUkNaLTcyMDU0NTA2MScwJQYDVQQKDB5TcHLDoXZhIHrDoWtsYWRuw61jaCByZWdpc3Ryxa8xFjAUBgNVBAMMDUdHX0ZQU1RTX1RFU1QxEDAOBgNVBAUTB1MyNzU3MzAwggEiMA0GCSqGSIb3DQEBAQUAA4IBDwAwggEKAoIBAQC1ehtkDsxm4RMIvPZAL8axrZIAisT29kkxsi0I7dAiih2fEvWHcG5jMl8hdcO40h/RVOZEjIGyCz4zXCdHwqmuFJCRpTBEJuPmoLYjIFddB9KptR7KJZqH1ANGk9beCbmFByNTR5mTxnUm7l9lWOfB4kS8bmPhawn3EuCgzI2gVN7nfwfdPPxG7HS+BUz88wWxASiSZhBbDZzM3XL+zRkgrCs7CuqEP4/WnGJfRPRJhPIRxJRAeZm/MncVUY8tXKLx65zz7wlylS/Jw4j0CnM81Hrc7rh5BYFHlQ1e37RH5LeWK5/CdK1bf6u6MPFECnn9tyl7pAjH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xpZmllZGNhNC5jcmwwNaAzoDGGL2h0dHA6Ly9jcmwucG9zdHNpZ251bS5ldS9jcmwvcHNxdWFsaWZpZWRjYTQuY3JsMB0GA1UdDgQWBBTyYwg9iyfBRKJo3XW3pm71cA149jANBgkqhkiG9w0BAQsFAAOCAgEAJoWNxo50/RiOKiYA9+OZ+39wJOrMf6P1EoSTXPKGgFSHtBgJ5X7C3YSfJwrCbbgBjFdU4HEJOQeTl2zqJlh9DqrUxzAuLbKKbMdDn8MSWBjSb2EaQ2z/oBoCCtR/ThPc5qH30k29M/CREstTgnBTPBwiJ33MvsPY7I1g6WHgZpma55ERKvdsavrS/TvXel5/TXWZkc0EOpn6qn1XISwD1NRn+7k4n+xQ81A0R1/Xs/ZKOZshPyabIoOB11w7LX3KtJpppn5+gr0CeQzC482f5I3smgkr2PUODjOsC7SceCLqVagP6O2vwgXLDN0X3qRT+UU6iCl8m8GA3iofyNiXCm3ZHhni7dHesnW09BFjJkCzYsn6CM4W8Zg2Mtz3EKzXEYS1X0XZ5ukXie51zfjwvEssLVco1XSOnE+cW9+ZIpIcWUcmFe5YN3AT+/Z/GVUUeMXbUi6PeKMPtxj6g3Vdx68WOIl2wIuG7FthPy4heTpVjN7nniPpPbt46sVhyjwPtBDzSooFhe+lh4RaMqMzIMKJrH0PwZ6p3u/vy2+xTMDspjA+DbkjOiir5L0JpzsIsH6yhDLkvlyRTOGkMFVHYAuLS5z160usMywWJRcnyioriUxn6reKqvyJVuwR71QV2jhnuIjB23dYTJqo0rwBcrlMfImDatLX5Ts5TIN31Mc="
                  }
                ]
              }
            ]
          }
          -EncryptionMethod: []
        }
      ]
      -Organization: null
      -ContactPerson: []
      -validators: []
      +validUntil: null
      +cacheDuration: null
      #signatureKey: null
      #certificates: []
    }
    1 => SAML2\XML\md\IDPSSODescriptor {#93
      -WantAuthnRequestsSigned: null
      -SingleSignOnService: array:2 [
        0 => SAML2\XML\md\EndpointType {#106
          -Binding: "urn:oasis:names:tc:SAML:2.0:bindings:HTTP-Redirect"
          -Location: "https://tnia.eidentita.cz/FPSTS/saml2/basic"
          -ResponseLocation: null
          -attributes: []
        }
        1 => SAML2\XML\md\EndpointType {#112
          -Binding: "urn:oasis:names:tc:SAML:2.0:bindings:HTTP-POST"
          -Location: "https://tnia.eidentita.cz/FPSTS/saml2/basic"
          -ResponseLocation: null
          -attributes: []
        }
      ]
      -NameIDMappingService: []
      -AssertionIDRequestService: []
      -AttributeProfile: []
      -Attribute: []
      -ArtifactResolutionService: []
      -SingleLogoutService: array:1 [
        0 => SAML2\XML\md\EndpointType {#102
          -Binding: "urn:oasis:names:tc:SAML:2.0:bindings:HTTP-Redirect"
          -Location: "https://tnia.eidentita.cz/FPSTS/saml2/basic"
          -ResponseLocation: null
          -attributes: []
        }
      ]
      -ManageNameIDService: []
      -NameIDFormat: []
      -elementName: "md:IDPSSODescriptor"
      -ID: null
      -protocolSupportEnumeration: array:1 [
        0 => "urn:oasis:names:tc:SAML:2.0:protocol"
      ]
      -errorURL: null
      -Extensions: []
      -KeyDescriptor: array:1 [
        0 => SAML2\XML\md\KeyDescriptor {#100
          -use: "signing"
          -KeyInfo: SAML2\XML\ds\KeyInfo {#104
            -Id: null
            -info: array:1 [
              0 => SAML2\XML\ds\X509Data {#108
                -data: array:1 [
                  0 => SAML2\XML\ds\X509Certificate {#110
                    -certificate: "MIIH0jCCBbqgAwIBAgIEAVDtYDANBgkqhkiG9w0BAQsFADBpMQswCQYDVQQGEwJDWjEXMBUGA1UEYRMOTlRSQ1otNDcxMTQ5ODMxHTAbBgNVBAoMFMSMZXNrw6EgcG/FoXRhLCBzLnAuMSIwIAYDVQQDExlQb3N0U2lnbnVtIFF1YWxpZmllZCBDQSA0MB4XDTIwMDIxOTA4NDE0MloXDTIxMDMxMDA4NDE0MloweTELMAkGA1UEBhMCQ1oxFzAVBgNVBGETDk5UUkNaLTcyMDU0NTA2MScwJQYDVQQKDB5TcHLDoXZhIHrDoWtsYWRuw61jaCByZWdpc3Ryxa8xFjA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FthPy4heTpVjN7nniPpPbt46sVhyjwPtBDzSooFhe+lh4RaMqMzIMKJrH0PwZ6p3u/vy2+xTMDspjA+DbkjOiir5L0JpzsIsH6yhDLkvlyRTOGkMFVHYAuLS5z160usMywWJRcnyioriUxn6reKqvyJVuwR71QV2jhnuIjB23dYTJqo0rwBcrlMfImDatLX5Ts5TIN31Mc="
                  }
                ]
              }
            ]
          }
          -EncryptionMethod: []
        }
      ]
      -Organization: null
      -ContactPerson: []
      -validators: []
      +validUntil: null
      +cacheDuration: null
      #signatureKey: null
      #certificates: []
    }
  ]
  -AffiliationDescriptor: null
  -Organization: null
  -ContactPerson: []
  -AdditionalMetadataLocation: []
  -validators: array:1 [
    0 => array:2 [
      "Function" => array:2 [
        0 => "SAML2\Utils"
        1 => "validateSignature"
      ]
      "Data" => array:2 [
        "Signature" => RobRichards\XMLSecLibs\XMLSecurityDSig {#84
          +sigNode: DOMElement {#89
            +nodeName: "Signature"
            +nodeValue: ""
            +nodeType: XML_ELEMENT_NODE
            +parentNode: null
            +childNodes: DOMNodeList {#156
              +length: 3
            }
            +firstChild: DOMElement {#160 …}
            +lastChild: DOMElement {#162 …}
            +previousSibling: null
            +nextSibling: null
            +attributes: DOMNamedNodeMap {#165
              +length: 0
            }
            +ownerDocument: DOMDocument {#167 …}
            +namespaceURI: "http://www.w3.org/2000/09/xmldsig#"
            +prefix: ""
            +localName: "Signature"
            +baseURI: "/nix/store/7cqqfs1ji0p5mxx2halgp6js2bvj6053-nia.otevrenamesta.cz/webroot/"
            +textContent: ""
            +tagName: "Signature"
            +schemaTypeInfo: null
          }
          +idKeys: array:1 [
            0 => "ID"
          ]
          +idNS: []
          -signedInfo: "<SignedInfo xmlns="http://www.w3.org/2000/09/xmldsig#"><CanonicalizationMethod Algorithm="http://www.w3.org/2001/10/xml-exc-c14n#"></CanonicalizationMethod><SignatureMethod Algorithm="http://www.w3.org/2001/04/xmldsig-more#rsa-sha256"></SignatureMethod><Reference URI="#_7d7065a7-b853-4169-ac23-b9182dc4a9a4"><Transforms><Transform Algorithm="http://www.w3.org/2000/09/xmldsig#enveloped-signature"></Transform><Transform Algorithm="http://www.w3.org/2001/10/xml-exc-c14n#"></Transform></Transforms><DigestMethod Algorithm="http://www.w3.org/2001/04/xmlenc#sha256"></DigestMethod><DigestValue>CPggsCL6eT+n9FGqkq7XfnNCN7lU2uven/V3a7dDCEk=</DigestValue></Reference></SignedInfo>"
          -xPathCtx: DOMXPath {#88
            +document: DOMDocument {#167 …}
          }
          -canonicalMethod: null
          -prefix: "ds:"
          -searchpfx: "secdsig"
          -validatedNodes: array:1 [
            "_7d7065a7-b853-4169-ac23-b9182dc4a9a4" => DOMElement {#85
              +nodeName: "EntityDescriptor"
              +nodeValue: ""
              +nodeType: XML_ELEMENT_NODE
              +parentNode: DOMDocument {#167 …}
              +childNodes: DOMNodeList {#124
                +length: 2
              }
              +firstChild: DOMElement {#130 …}
              +lastChild: DOMElement {#191 …}
              +previousSibling: null
              +nextSibling: null
              +attributes: DOMNamedNodeMap {#188
                +length: 2
              }
              +ownerDocument: DOMDocument {#167 …}
              +namespaceURI: "urn:oasis:names:tc:SAML:2.0:metadata"
              +prefix: ""
              +localName: "EntityDescriptor"
              +baseURI: "/nix/store/7cqqfs1ji0p5mxx2halgp6js2bvj6053-nia.otevrenamesta.cz/webroot/"
              +textContent: ""
              +tagName: "EntityDescriptor"
              +schemaTypeInfo: null
            }
          ]
        }
        "Certificates" => array:1 [
          0 => "MIIH0jCCBbqgAwIBAgIEAVDtYDANBgkqhkiG9w0BAQsFADBpMQswCQYDVQQGEwJDWjEXMBUGA1UEYRMOTlRSQ1otNDcxMTQ5ODMxHTAbBgNVBAoMFMSMZXNrw6EgcG/FoXRhLCBzLnAuMSIwIAYDVQQDExlQb3N0U2lnbnVtIFF1YWxpZmllZCBDQSA0MB4XDTIwMDIxOTA4NDE0MloXDTIxMDMxMDA4NDE0MloweTELMAkGA1UEBhMCQ1oxFzAVBgNVBGETDk5UUkNaLTcyMDU0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+ZIpIcWUcmFe5YN3AT+/Z/GVUUeMXbUi6PeKMPtxj6g3Vdx68WOIl2wIuG7FthPy4heTpVjN7nniPpPbt46sVhyjwPtBDzSooFhe+lh4RaMqMzIMKJrH0PwZ6p3u/vy2+xTMDspjA+DbkjOiir5L0JpzsIsH6yhDLkvlyRTOGkMFVHYAuLS5z160usMywWJRcnyioriUxn6reKqvyJVuwR71QV2jhnuIjB23dYTJqo0rwBcrlMfImDatLX5Ts5TIN31Mc="
        ]
      ]
    ]
  ]
  +validUntil: null
  +cacheDuration: null
  #signatureKey: null
  #certificates: array:1 [
    0 => "MIIH0jCCBbqgAwIBAgIEAVDtYDANBgkqhkiG9w0BAQsFADBpMQswCQYDVQQGEwJDWjEXMBUGA1UEYRMOTlRSQ1otNDcxMTQ5ODMxHTAbBgNVBAoMFMSMZXNrw6EgcG/FoXRhLCBzLnAuMSIwIAYDVQQDExlQb3N0U2lnbnVtIFF1YWxpZmllZCBDQSA0MB4XDTIwMDIxOTA4NDE0MloXDTIxMDMxMDA4NDE0MloweTELMAkGA1UEBhMCQ1oxFzAVBgNVBGETDk5UUkNaLTcyMDU0NTA2MScwJQYDVQQKDB5TcHLDoXZhIHrDoWtsYWRuw61jaCByZWdpc3Ryxa8xFjAUBgNVBAMMDUdHX0ZQU1RTX1RFU1QxEDAOBgNVBAUTB1MyNzU3MzAwggEiMA0GCSqGSIb3DQEBAQUAA4IBDwAwggEKAoIBAQC1ehtkDsxm4RMIvPZAL8axrZIAisT29kkxsi0I7dAiih2fEvWHcG5jMl8hdcO40h/RVOZEjIGyCz4zXCdHwqmuFJCRpTBEJuPmoLYjIFddB9KptR7KJZqH1ANGk9beCbmFByNTR5mTxnUm7l9lWOfB4kS8bmPhawn3EuCgzI2gVN7nfwfdPPxG7HS+BUz88wWxASiSZhBbDZzM3XL+zRkgrCs7CuqEP4/WnGJfRPRJhPIRxJRAeZm/MncVUY8tXKLx65zz7wlylS/Jw4j0CnM81Hrc7rh5BYFHlQ1e37RH5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wb3N0c2lnbnVtLmN6L2NybC9wc3F1YWxpZmllZGNhNC5jcmwwNaAzoDGGL2h0dHA6Ly9jcmwucG9zdHNpZ251bS5ldS9jcmwvcHNxdWFsaWZpZWRjYTQuY3JsMB0GA1UdDgQWBBTyYwg9iyfBRKJo3XW3pm71cA149jANBgkqhkiG9w0BAQsFAAOCAgEAJoWNxo50/RiOKiYA9+OZ+39wJOrMf6P1EoSTXPKGgFSHtBgJ5X7C3YSfJwrCbbgBjFdU4HEJOQeTl2zqJlh9DqrUxzAuLbKKbMdDn8MSWBjSb2EaQ2z/oBoCCtR/ThPc5qH30k29M/CREstTgnBTPBwiJ33MvsPY7I1g6WHgZpma55ERKvdsavrS/TvXel5/TXWZkc0EOpn6qn1XISwD1NRn+7k4n+xQ81A0R1/Xs/ZKOZshPyabIoOB11w7LX3KtJpppn5+gr0CeQzC482f5I3smgkr2PUODjOsC7SceCLqVagP6O2vwgXLDN0X3qRT+UU6iCl8m8GA3iofyNiXCm3ZHhni7dHesnW09BFjJkCzYsn6CM4W8Zg2Mtz3EKzXEYS1X0XZ5ukXie51zfjwvEssLVco1XSOnE+cW9+ZIpIcWUcmFe5YN3AT+/Z/GVUUeMXbUi6PeKMPtxj6g3Vdx68WOIl2wIuG7FthPy4heTpVjN7nniPpPbt46sVhyjwPtBDzSooFhe+lh4RaMqMzIMKJrH0PwZ6p3u/vy2+xTMDspjA+DbkjOiir5L0JpzsIsH6yhDLkvlyRTOGkMFVHYAuLS5z160usMywWJRcnyioriUxn6reKqvyJVuwR71QV2jhnuIjB23dYTJqo0rwBcrlMfImDatLX5Ts5TIN31Mc="
  ]
}

2. Ověření obsahu souboru

    
 <?php
 use RobRichards\XMLSecLibs\XMLSecurityKey;

 // soubor s certifikátem bychom měli mít uložen lokálně, aby validace podpisu proběhla korektně
 // na uvedené adrese je uložen NIA certifikát (PEM) z testovacího prostředí
 $tnia_cert_data = file_get_contents('https://nia.otevrenamesta.cz/tnia.crt');
 // z dat certifikátu vytvoříme klíč
 $tnia_key = new XMLSecurityKey(XMLSecurityKey::RSA_SHA256, ['type' => 'public']);
 $tnia_key->loadKey($tnia_cert_data, false, true);
 // a použijeme interní metodu EntityDescriptor->validate(XMLSecurityKey $key) pro validaci
 $valid = $metadata->validate($tnia_key);

    
Obsah proměnné valid:
^ true

3. Získání adresy pro přesměrování uživatele

    
    <?php
    use SAML2\Constants;
    use SAML2\XML\md\IDPSSODescriptor;
    use SAML2\XML\md\EntityDescriptor;

    private function extractSSOLoginUrls(EntityDescriptor $idp_descriptor){
        $idp_sso_descriptor = false;
        foreach ($idp_descriptor->getRoleDescriptor() as $role_descriptor) {
            if ($role_descriptor instanceof IDPSSODescriptor) {
                $idp_sso_descriptor = $role_descriptor;
            }
        }

        $sso_redirect_login_url = false;
        $sso_post_login_url = false;

        if ($idp_sso_descriptor instanceof IDPSSODescriptor) {
            foreach ($idp_sso_descriptor->getSingleSignOnService() as $descriptorType) {
                if ($descriptorType->getBinding() === Constants::BINDING_HTTP_REDIRECT) {
                    $sso_redirect_login_url = $descriptorType->getLocation();
                } else if ($descriptorType->getBinding() === Constants::BINDING_HTTP_POST) {
                    $sso_post_login_url = $descriptorType->getLocation();
                }
            }
        }

        return [Constants::BINDING_HTTP_REDIRECT => $sso_redirect_login_url, Constants::BINDING_HTTP_POST => $sso_post_login_url];
    }

    $urls = extractSSOLoginUrls($metadata);
    $redirect_url = $urls[Constants::BINDING_HTTP_REDIRECT];
    $post_url = $urls[Constants::BINDING_HTTP_POST];
    
Obsah proměnné urls:
^ array:2 [
  "urn:oasis:names:tc:SAML:2.0:bindings:HTTP-Redirect" => "https://tnia.eidentita.cz/FPSTS/saml2/basic"
  "urn:oasis:names:tc:SAML:2.0:bindings:HTTP-POST" => "https://tnia.eidentita.cz/FPSTS/saml2/basic"
]