Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
A
auth
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Iterations
Wiki
Requirements
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Container registry
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
lib
unicaen
auth
Commits
878a1d3d
Commit
878a1d3d
authored
6 years ago
by
Bertrand Gauthier
Browse files
Options
Downloads
Patches
Plain Diff
Retrait des storage et identity provider Ldap lorsque l'auth LDAP est désactivée
parent
6d3ff3d5
No related branches found
No related tags found
No related merge requests found
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
src/UnicaenAuth/Authentication/Storage/ChainServiceFactory.php
+9
-0
9 additions, 0 deletions
...nicaenAuth/Authentication/Storage/ChainServiceFactory.php
src/UnicaenAuth/Provider/Identity/ChainServiceFactory.php
+27
-7
27 additions, 7 deletions
src/UnicaenAuth/Provider/Identity/ChainServiceFactory.php
with
36 additions
and
7 deletions
src/UnicaenAuth/Authentication/Storage/ChainServiceFactory.php
+
9
−
0
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
);
...
...
This diff is collapsed.
Click to expand it.
src/UnicaenAuth/Provider/Identity/ChainServiceFactory.php
+
27
−
7
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
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
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!
Save comment
Cancel
Please
register
or
sign in
to comment