I just started developing with simplesamlPHP. I installed simpleSamlPhp and I followed the steps given in https://simplesamlphp.org/docs/development/simplesamlphp-sp-api to integrate my php application with simpleSAMLPhp and I am using the simpleSaml APIs given in the document.
Below is the code:
require_once('/var/simplesamlphp/lib/_autoload.php');
$auth = new \SimpleSAML\Auth\Simple('default-sp');
if($auth->isAuthenticated()){
$attributes = $auth->getAttributes();
}else{
echo "Not authenticated";
$auth->requireAuth();
}
$auth->isAuthenticated() is always returning false. Do I need to do anything else? or am I missing something?
Before calling isAuthenticated()
, you need to call requireAuth()
. The idea is that you request authentication against an entity and later on you are able to check if the user is authenticated or not.
require_once('/var/simplesamlphp/lib/_autoload.php');
$auth = new \SimpleSAML\Auth\Simple('default-sp');
$auth->requireAuth();
if($auth->isAuthenticated()){
$attributes = $auth->getAttributes();
}else{
echo "Not authenticated";
}