I'd setup simplesamlphp
to my localhost as a 3 different virtual host.
1. http://idp-saml.com
2. http://sp-saml.com
3. http://api-saml.com
When I tried to connect idp-saml.com
using sp-saml.com
then it works fine.
Now, I want to integrate it with my own application api-saml.com
.
For that, I'd follow the below steps:
Create "authsouce" to
sp-saml.com
on 'authsources.php'.'sp1' => array( 'saml:SP', 'privatekey' => 'sp-saml.pem', 'certificate' => 'sp-saml.crt', 'entityID' => 'http://api-saml.com', 'idp' => 'http://idp-saml.com', )
Now, go to the
Federation
page and click on "SP1" metadata and copySAML 2.0 Metadata XML
Then go to
idp-saml.com
and openmetadata-converter.php
and parseSAML 2.0 Metadata XML
.Copy both
shib13-sp-remote
andsaml20-sp-remote
tometadata\shib13-sp-remote.php
andmetadata\saml20-sp-remote.php
onidp-saml.com
virtual host and I can seeapi-saml.com
underfederation
tab underSAML 2.0 SP Metadata (Trusted)
section.
https://www.screencast.com/t/424rmDxRlRfV
- Now, Go to
api-saml.com
directory and createindex.php
and add below code
require_once('sp-saml/lib/_autoload.php');
$saml_auth = new SimpleSAML_Auth_Simple('sp1');
if ($saml_auth->isAuthenticated()) {
$attributes = $saml_auth->getAttributes();
var_dump($attributes);
}
else {
$saml_auth->requireAuth();
}
- Now, tried to access
http://api-saml.com
and it goes toidp-saml.com
and ask me for login credentials. After adding credentials it does not redirect back me toapi-saml.com
and behave like infinite redirection. You can see https://www.screencast.com/t/VGhDHE1j