Skip to content
Snippets Groups Projects
Commit c9f7265e authored by Bertrand Gauthier's avatar Bertrand Gauthier
Browse files

Merge branch 'release-1.3.8'

parents c8467a2a fa40379e
No related branches found
No related tags found
No related merge requests found
Pipeline #4327 passed
......@@ -28,6 +28,22 @@ $settings = [
'enabled' => true,
],
/**
* Configuration de l'authentification Shibboleth.
*/
'shibboleth' => [
/**
* Affichage ou non du formulaire d'authentification via l'annuaire LDAP.
* NB: en réalité cela permet aussi l'authentification avec un compte local.
*/
'enable' => false,
/**
* URL de déconnexion.
*/
'logout_url' => '/Shibboleth.sso/Logout?return=', // NB: '?return=' semble obligatoire!
],
/**
* Flag indiquant si l'utilisateur authenitifié avec succès via l'annuaire LDAP doit
* être enregistré/mis à jour dans la table des utilisateurs de l'appli.
......
......@@ -2,6 +2,9 @@
namespace UnicaenAuth\Options;
use Assert\Assertion;
use Assert\AssertionFailedException;
use UnicaenApp\Exception\RuntimeException;
use Zend\ServiceManager\FactoryInterface;
use Zend\ServiceManager\ServiceLocatorInterface;
......@@ -24,6 +27,42 @@ class ModuleOptionsFactory implements FactoryInterface
$moduleConfig = isset($config['unicaen-auth']) ? $config['unicaen-auth'] : [];
$moduleConfig = array_merge($config['zfcuser'], $moduleConfig);
$this->validateConfig($moduleConfig);
return new ModuleOptions($moduleConfig);
}
/**
* @param array $config
*/
private function validateConfig(array $config)
{
$configKeyPath = ['unicaen-auth'];
//
// Config shibboleth.
//
$parentKey = 'shibboleth';
if (array_key_exists($parentKey, $config)) {
$shibConfig = $config[$parentKey];
$configKeyPath[] = $parentKey;
try {
Assertion::keyExists($shibConfig, $k = 'logout_url');
} catch (AssertionFailedException $e) {
throw new RuntimeException(sprintf(
"La clé de configuration '%s.$k' est absente (inspirez-vous du fichier de config " .
"unicaen-auth.global.php.dist du module unicaen/auth si besoin)",
join('.', $configKeyPath)
));
}
array_pop($configKeyPath);
}
//
// Autres.
//
}
}
\ No newline at end of file
......@@ -100,7 +100,10 @@ EOS;
*/
private function isAuthenticated()
{
return (bool) $this->getServerArrayVariable('REMOTE_USER');
return
$this->getServerArrayVariable('REMOTE_USER') ||
$this->getServerArrayVariable('Shib-Session-ID') ||
$this->getServerArrayVariable('HTTP_SHIB_SESSION_ID');
}
/**
......@@ -363,7 +366,7 @@ EOS;
*/
public function simulateAuthenticatedUser(ShibUser $shibUser, $keyForId = 'supannEmpId')
{
// 'REMOTE_USER' est utilisé pour savoir si un utilisateur est authentifié ou non
// 'REMOTE_USER' (notamment) est utilisé pour savoir si un utilisateur est authentifié ou non
$this->setServerArrayVariable('REMOTE_USER', $shibUser->getEppn());
// // on s'assure que tous les attributs obligatoires ont une valeur
......@@ -434,13 +437,13 @@ EOS;
return '/';
}
$logoutRelativeUrl = '/Shibboleth.sso/Logout?return='; // NB: '?return=' semble obligatoire!
$logoutUrl = $this->shibbolethConfig['logout_url'];
if ($returnAbsoluteUrl) {
$logoutRelativeUrl .= urlencode($returnAbsoluteUrl);
$logoutUrl .= urlencode($returnAbsoluteUrl);
}
return $logoutRelativeUrl;
return $logoutUrl;
}
/**
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment