Search code examples
phpsimplesamlphp

SimplesamlPHP error


I try to instal an SP and an IDP in local so i create another host :

127.0.0.1       localhost
::1             localhost
127.0.0.1       auth.saml.net 

and i create 2 virtual host (one for the SP and the other for the Idp)

<VirtualHost auth.saml.net:80>
    ServerAdmin [email protected]
    ServerName  auth.saml.net
    AddDefaultCharset UTF-8
    Alias /simplesaml c:/wamp/www/var2/simplesamlphp/www/   
    <Directory c:/wamp/www/var2/simplesamlphp/www/  >
        Order Deny,Allow   
        Allow from all 
    </Directory>
</VirtualHost>

<VirtualHost localhost:80>
    ServerAdmin [email protected]
    ServerName  localhost
    AddDefaultCharset UTF-8
    Alias /simplesaml c:/wamp/www/var/simplesamlphp/www/
</VirtualHost>

(The folder var2 is for my IDP and the folder var for my SP, it's not really clean but actually i just want it work)

In second i config my SP and my idp by editing the file config/config.php in each folders (i don't forget to put enable.saml20-idp at true for the IDP)

Next I edit the file config/authsources.php from my idp and i had 2 fake user :

'example-userpass' => array(
        'exampleauth:UserPass',
        'user1:pwd' => array(
            'uid' => array('user1'),
            'mail' => '[email protected]',
            'first_name' => 'User',
            'last_name' => 'One'
        ),
        'user2:pwd' => array(
            'uid' => array('user2'),
            'mail' => '[email protected]',
            'first_name' => 'User',
            'last_name' => 'Two'
        )
    )

And I also edit the file config/authsources.php on my SP part :

    'default-sp' => array(
            'saml:SP',
            'entityID' => 'auth.saml.net',
            'idp' => 'auth.saml.net/simplesaml/saml2/idp/metadata.php',
            'ssoPortalUrl'=> 'auth.saml.net/simplesaml/saml2/idp/SSOService.php',
            'discoURL' => null
);

Next I copy the metadata from my IDP (Federation -> print Metadata -> SimpleSAMLphp flat file format) to my SP in the file "metadata/saml20-idp-remote.php" :

$metadata['auth.saml.net/simplesaml/saml2/idp/metadata.php'] = array (
  'metadata-set' => 'saml20-idp-remote',
  'entityid' => 'auth.saml.net/simplesaml/saml2/idp/metadata.php',
  'SingleSignOnService' => 
  array (
    0 => 
    array (
      'Binding' => 'urn:oasis:names:tc:SAML:2.0:bindings:HTTP-Redirect',
      'Location' => 'auth.saml.net/simplesaml/saml2/idp/SSOService.php',
    ),
  ),
  'SingleLogoutService' => 
  array (
    0 => 
    array (
      'Binding' => 'urn:oasis:names:tc:SAML:2.0:bindings:HTTP-Redirect',
      'Location' => 'auth.saml.net/simplesaml/saml2/idp/SingleLogoutService.php',
    ),
  ),
  'certData' => 'certData',
  'NameIDFormat' => 'urn:oasis:names:tc:SAML:2.0:nameid-format:transient',
);

and the metadata from my SP to my IDP in the file 'metadata/saml20-sp-remote.php' :

$metadata['auth.saml.net'] = array (
  'SingleLogoutService' => 
  array (
    0 => 
    array (
      'Binding' => 'urn:oasis:names:tc:SAML:2.0:bindings:HTTP-Redirect',
      'Location' => 'http://localhost/simplesaml/module.php/saml/sp/saml2-logout.php/default-sp',
    ),
  ),
  'AssertionConsumerService' => 
  array (
    0 => 
    array (
      'index' => 0,
      'Binding' => 'urn:oasis:names:tc:SAML:2.0:bindings:HTTP-POST',
      'Location' => 'http://localhost/simplesaml/module.php/saml/sp/saml2-acs.php/default-sp',
    ),
    1 => 
    array (
      'index' => 1,
      'Binding' => 'urn:oasis:names:tc:SAML:1.0:profiles:browser-post',
      'Location' => 'http://localhost/simplesaml/module.php/saml/sp/saml1-acs.php/default-sp',
    ),
    2 => 
    array (
      'index' => 2,
      'Binding' => 'urn:oasis:names:tc:SAML:2.0:bindings:HTTP-Artifact',
      'Location' => 'http://localhost/simplesaml/module.php/saml/sp/saml2-acs.php/default-sp',
    ),
    3 => 
    array (
      'index' => 3,
      'Binding' => 'urn:oasis:names:tc:SAML:1.0:profiles:artifact-01',
      'Location' => 'http://localhost/simplesaml/module.php/saml/sp/saml1-acs.php/default-sp/artifact',
    ),
  ),
);

But when i try to test by click on 'test configured authentication sources' i have this error message :

Exception during login:
SimpleSAML_Error_Exception: Could not find the metadata of an IdP with entity ID 'auth.saml.net/simplesaml/saml2/idp/metadata.php'
Backtrace:
6 C:\wamp\www\var\simplesamlphp\modules\saml\lib\Auth\Source\SP.php:134 (sspmod_saml_Auth_Source_SP::getIdPMetadata)
5 C:\wamp\www\var\simplesamlphp\modules\saml\lib\Auth\Source\SP.php:308 (sspmod_saml_Auth_Source_SP::startSSO)
4 C:\wamp\www\var\simplesamlphp\modules\saml\lib\Auth\Source\SP.php:390 (sspmod_saml_Auth_Source_SP::authenticate)
3 C:\wamp\www\var\simplesamlphp\lib\SimpleSAML\Auth\Default.php:65 (SimpleSAML_Auth_Default::initLogin)
2 C:\wamp\www\var\simplesamlphp\lib\SimpleSAML\Auth\Simple.php:136 (SimpleSAML_Auth_Simple::login)
1 C:\wamp\www\var\simplesamlphp\modules\core\www\authenticate.php:45 (require)
0 C:\wamp\www\var\simplesamlphp\www\module.php:134 (N/A)

I already try to rebuild the configuration from the begin but the error still here. And when i go to the link 'auth.saml.net/simplesaml/saml2/idp/metadata.php' the metadata print well.


Solution

  • I do severals mistake :

    • First don't use localhost do another virtualHost
    • Second you have to do a cert directory on the SP too
    • Tird the most important pray i
      restart it 5 time for that it's work and i still don't understand why it's don't work the other time.