h1. SpPhpTutorial This exemple show a php script implementing two services needed by a service provider: * a metadata endpoint, returning an XML file describing metadata to connect to this service provider ; * an assertion consumer endpoint. No attribute extraction is done but you can do it easily by iterating the ``$login->assertion->attributeStatement`` array. No session creation is done, you must find a user corresponding to the received NameID and log this user by creating a php session for him.
  
  
    
    
      
      urn:oasis:names:tc:SAML:1.1:nameid-format:emailAddress
    
    
       Example SAML 2.0 metadatas
    
  
  XML;

  $idp_metadata_xml = <<<'XML'
  


    
      
        
          
      
          4yalpsp9Sxlsj07PEI8jJxhSJdo4F0iW0H8u1dhwmsW5YQvRUw/yPlmC09q4WjImmnFVNCJarAOYeFgQCxfIoBasKNnUeBQpogo8W0Q/3mCuKl6lNSr/PIuxMVVNPDWmWkhHXJx/MVar2IREKa1P4jHL0Uxl69/idLwc7TtK1h8=
          AQAB
      
  
        
      
      
        
          
      
          wLu5SdmwyS4o1On/aw4nElLGERFG931exvkzu0ewaM1/oUyD3dO7UC5xMGnPfc6IaH5BcJc3fLr6PJhX55ZrMR98ToPwoUFwuLKK43exwYBEBOOMe1CrCB/Bq+EH6/2sKNXKfgJqj06/3yzafLRiWpMxy2isllxMAvaZXrkpm4c=
          AQAB
      
  
        
      
    

  
  XML;

  if (isset($_GET["metadata"])) {
    header('Content-Type: text/xml');
    echo $sp_metadata_xml;
    exit(0);
  }

  if (isset($_GET["assertion_consumer"])) {
    $server = LassoServer::newFromBuffers($sp_metadata_xml);
    $server->addProviderFromBuffer(LASSO_PROVIDER_ROLE_IDP, $idp_metadata_xml);
    $login = new LassoLogin($server);

    function error($msg) {
        header("HTTP/1.0 500 Internal Error");
        ?> 

Erreur:

 
processAuthnResponseMsg($_POST["SAMLResponse"]); } catch (LassoDsError $e) { error('Invalid signature'); } catch (LassoProfileCannotVerifySignatureError $e) { error('Invalid signature'); } catch (LassoError $e) { error('Misc error, ' . $e); } try { $login->acceptSso(); } catch (LassoError $e) { error('Invalid assertion'); } } catch (Exception $e) { error('Unexpected error: ' . $e); } ?> You are identified as assertion->subject->nameId->content;