Commit 7917bf36 authored by Guillaume Wauquier's avatar Guillaume Wauquier
Browse files

Permettre la desactivation du gendarme

parent de04c99f
......@@ -32,6 +32,7 @@ class Gendarme implements AuthorizationCheckerInterface{
$this->accessDecisionManager = $accessDecisionManager;
$this->alwaysAuthenticate = $alwaysAuthenticate;
$this->sac = $sac;
$this->activation_securite = $sac->get('app.activation_securite');
}
......@@ -42,8 +43,10 @@ class Gendarme implements AuthorizationCheckerInterface{
* @throws AuthenticationCredentialsNotFoundException when the token storage has no authentication token
*/
final function isGrantedNiveau($attribute){
if (!$this->activation_securite){
return true;
}
if (null === ($token = $this->tokenStorage->getToken())) {
throw new AuthenticationCredentialsNotFoundException('The token storage contains no authentication token. One possible reason may be that there is no firewall configured for this URL.');
}
......@@ -79,7 +82,9 @@ class Gendarme implements AuthorizationCheckerInterface{
* @throws AuthenticationCredentialsNotFoundException when the token storage has no authentication token
*/
final function isGrantedNiveaux($tab_attribute){
if (!$this->activation_securite){
return true;
}
foreach ($tab_attribute as $profil) {
if (substr($profil,0,5)!== 'ROLE_'){
$profil = 'ROLE_'.$profil;
......@@ -102,6 +107,9 @@ class Gendarme implements AuthorizationCheckerInterface{
*/
final public function isGranted($attributes, $subject = null)
{
if (!$this->activation_securite){
return true;
}
if (null === ($token = $this->tokenStorage->getToken())) {
throw new AuthenticationCredentialsNotFoundException('The token storage contains no authentication token. One possible reason may be that there is no firewall configured for this URL.');
}
......@@ -128,6 +136,9 @@ class Gendarme implements AuthorizationCheckerInterface{
function autoriser($profils)
{
if (!$this->activation_securite){
return true;
}
$profils = is_array($profils) ? $profils:[$profils];
return $this->isGrantedNiveaux($profils);
}
......
......@@ -536,9 +536,7 @@ class Selecteur
*/
function where_restriction()
{
return $this->suc->get('restriction_where.' . $this->suc->pref('en_cours.id_entite') . '.' . $this->sac->descr($this->objet . '.groupe') . '.' . $this->objet);
}
......
......@@ -179,7 +179,7 @@ class Suc
if ($this->user) {
return $this->session->get('preference');
} else {
return array();
return null;
}
}
if ($val === null) {
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment