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.comon '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
Federationpage and click on "SP1" metadata and copySAML 2.0 Metadata XMLThen go to
idp-saml.comand openmetadata-converter.phpand parseSAML 2.0 Metadata XML.Copy both
shib13-sp-remoteandsaml20-sp-remotetometadata\shib13-sp-remote.phpandmetadata\saml20-sp-remote.phponidp-saml.comvirtual host and I can seeapi-saml.comunderfederationtab underSAML 2.0 SP Metadata (Trusted)section.
https://www.screencast.com/t/424rmDxRlRfV
- Now, Go to
api-saml.comdirectory and createindex.phpand 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.comand it goes toidp-saml.comand ask me for login credentials. After adding credentials it does not redirect back me toapi-saml.comand behave like infinite redirection. You can see https://www.screencast.com/t/VGhDHE1j