Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
lib
unicaen
auth
Commits
878a1d3d
Commit
878a1d3d
authored
Aug 28, 2018
by
Bertrand Gauthier
Browse files
Retrait des storage et identity provider Ldap lorsque l'auth LDAP est désactivée
parent
6d3ff3d5
Changes
2
Hide whitespace changes
Inline
Side-by-side
src/UnicaenAuth/Authentication/Storage/ChainServiceFactory.php
View file @
878a1d3d
...
...
@@ -2,6 +2,7 @@
namespace
UnicaenAuth\Authentication\Storage
;
use
UnicaenAuth\Options\ModuleOptions
;
use
Zend\ServiceManager\FactoryInterface
;
use
Zend\ServiceManager\ServiceLocatorInterface
;
...
...
@@ -31,6 +32,14 @@ class ChainServiceFactory implements FactoryInterface
{
$chain
=
new
Chain
();
/** @var ModuleOptions $options */
$options
=
$serviceLocator
->
get
(
'unicaen-auth_module_options'
);
// retrait du fournisseur Ldap si l'auth LDAP est désactivée
if
(
isset
(
$options
->
getLdap
()[
'enabled'
])
&&
!
$options
->
getLdap
()[
'enabled'
])
{
unset
(
$this
->
mandatoryStorages
[
200
]);
}
$storages
=
$this
->
mandatoryStorages
+
$this
->
storages
;
krsort
(
$storages
);
...
...
src/UnicaenAuth/Provider/Identity/ChainServiceFactory.php
View file @
878a1d3d
<?php
namespace
UnicaenAuth\Provider\Identity
;
use
Zend\ServiceManager\FactoryInterface
;
...
...
@@ -19,16 +20,11 @@ class ChainServiceFactory implements FactoryInterface
*/
public
function
createService
(
ServiceLocatorInterface
$serviceLocator
)
{
$config
=
$serviceLocator
->
get
(
'Config'
);
//'unicaen-auth_module_options'
if
(
!
isset
(
$config
[
'unicaen-auth'
][
'identity_providers'
])
||
!
$config
[
'unicaen-auth'
][
'identity_providers'
])
{
throw
new
\
UnicaenApp\Exception\RuntimeException
(
"Aucun fournisseur d'identité spécifié dans la config."
);
}
$providers
=
(
array
)
$config
[
'unicaen-auth'
][
'identity_providers'
];
$chain
=
new
Chain
();
$chain
->
setServiceLocator
(
$serviceLocator
);
$providers
=
$this
->
computeProviders
(
$serviceLocator
);
foreach
(
$providers
as
$priority
=>
$name
)
{
$provider
=
$serviceLocator
->
get
(
$name
);
$chain
->
getEventManager
()
->
attach
(
'getIdentityRoles'
,
[
$provider
,
'injectIdentityRoles'
],
$priority
);
...
...
@@ -36,4 +32,28 @@ class ChainServiceFactory implements FactoryInterface
return
$chain
;
}
/**
* @param ServiceLocatorInterface $serviceLocator
* @return array
*/
private
function
computeProviders
(
ServiceLocatorInterface
$serviceLocator
)
{
$config
=
$serviceLocator
->
get
(
'Config'
);
//'unicaen-auth_module_options'
if
(
!
isset
(
$config
[
'unicaen-auth'
][
'identity_providers'
])
||
!
$config
[
'unicaen-auth'
][
'identity_providers'
])
{
throw
new
\
UnicaenApp\Exception\RuntimeException
(
"Aucun fournisseur d'identité spécifié dans la config."
);
}
$providers
=
(
array
)
$config
[
'unicaen-auth'
][
'identity_providers'
];
// retrait du fournisseur 'Ldap' si l'auth Ldap est désactivée
if
(
isset
(
$config
[
'unicaen-auth'
][
'ldap'
][
'enabled'
])
&&
!
$config
[
'unicaen-auth'
][
'ldap'
][
'enabled'
])
{
$key
=
array_search
(
'UnicaenAuth\Provider\Identity\Ldap'
,
$providers
,
true
);
if
(
$key
!==
false
)
{
unset
(
$providers
[
$key
]);
}
}
return
$providers
;
}
}
\ No newline at end of file
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment