Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
lib
unicaen
auth
Commits
d1041cbe
Commit
d1041cbe
authored
Oct 01, 2013
by
Bertrand Gauthier
Browse files
Refactorisation.
parent
1a057b13
Changes
4
Hide whitespace changes
Inline
Side-by-side
src/UnicaenAuth/Provider/Identity/ChainServiceFactory.php
View file @
d1041cbe
...
...
@@ -39,7 +39,7 @@ class ChainServiceFactory implements FactoryInterface
foreach
(
$providers
as
$priority
=>
$name
)
{
$provider
=
$serviceLocator
->
get
(
$name
);
$chain
->
getEventManager
()
->
attach
(
'getIdentityRoles'
,
array
(
$provider
,
'getIdentityRoles'
),
$priority
);
$chain
->
getEventManager
()
->
attach
(
'getIdentityRoles'
,
array
(
$provider
,
'getIdentityRoles
Trigger
'
),
$priority
);
}
return
$chain
;
...
...
src/UnicaenAuth/Provider/Identity/ChainableProvider.php
View file @
d1041cbe
...
...
@@ -7,7 +7,7 @@ interface ChainableProvider
/**
* Retrieve roles for the current identity
*
* @
return string[]|\Zend\Permissions\Acl\Role\RoleInterface[]
* @
param ChainEvent $event
*/
public
function
getIdentityRoles
(
ChainEvent
$e
);
public
function
getIdentityRoles
Trigger
(
ChainEvent
$e
);
}
\ No newline at end of file
src/UnicaenAuth/Provider/Identity/Db.php
View file @
d1041cbe
...
...
@@ -17,11 +17,17 @@ use UnicaenAuth\Entity\Db\User;
class
Db
extends
AuthenticationIdentityProvider
implements
ChainableProvider
{
/**
* Retrieve roles for the current identity
*
* @return string[]|RoleInterface[]
* {@inheritDoc}
*/
public
function
getIdentityRoles
(
ChainEvent
$event
=
null
)
public
function
getIdentityRolesTrigger
(
ChainEvent
$event
)
{
$event
->
addRoles
(
$this
->
getIdentityRoles
());
}
/**
* {@inheritDoc}
*/
public
function
getIdentityRoles
()
{
if
(
!
$identity
=
$this
->
authService
->
getIdentity
())
{
return
array
(
$this
->
defaultRole
);
...
...
@@ -43,10 +49,6 @@ class Db extends AuthenticationIdentityProvider implements ChainableProvider
$roles
=
array
(
$this
->
authenticatedRole
);
}
if
(
null
!==
$event
)
{
$event
->
addRoles
(
$roles
);
}
return
$roles
;
}
}
\ No newline at end of file
src/UnicaenAuth/Provider/Identity/Ldap.php
View file @
d1041cbe
...
...
@@ -4,7 +4,6 @@ namespace UnicaenAuth\Provider\Identity;
use
Zend\ServiceManager\ServiceLocatorAwareInterface
;
use
Zend\ServiceManager\ServiceLocatorInterface
;
use
Zend\Permissions\Acl\Role\RoleInterface
;
use
UnicaenApp\Entity\Ldap\People
as
BasePeople
;
use
UnicaenAuth\Entity\Ldap\People
;
use
BjyAuthorize\Provider\Identity\AuthenticationIdentityProvider
;
...
...
@@ -26,17 +25,22 @@ class Ldap extends AuthenticationIdentityProvider implements ChainableProvider,
protected
$serviceLocator
;
/**
* Retrieve roles for the current identity
*
* @return string[]|RoleInterface[]
* {@inheritDoc}
*/
public
function
getIdentityRoles
(
ChainEvent
$event
=
null
)
public
function
getIdentityRoles
Trigger
(
ChainEvent
$event
)
{
if
(
!
$identity
=
$this
->
authService
->
getIdentity
())
{
$event
->
addRoles
(
$this
->
getIdentityRoles
());
}
/**
* {@inheritDoc}
*/
public
function
getIdentityRoles
()
{
if
(
!
$identity
=
$this
->
authService
->
getIdentity
())
{
return
array
(
$this
->
defaultRole
);
}
$identity
=
$this
->
authService
->
getIdentity
();
if
(
is_array
(
$identity
)
&&
isset
(
$identity
[
'ldap'
]))
{
$identity
=
$identity
[
'ldap'
];
}
...
...
@@ -44,9 +48,6 @@ class Ldap extends AuthenticationIdentityProvider implements ChainableProvider,
if
(
$identity
instanceof
People
)
{
$roles
=
$identity
->
getRoles
();
}
elseif
(
$identity
instanceof
BasePeople
)
{
$roles
=
$identity
->
getMemberOf
();
}
else
{
$roles
=
array
();
}
...
...
@@ -63,10 +64,6 @@ class Ldap extends AuthenticationIdentityProvider implements ChainableProvider,
$roles
=
array
(
$this
->
authenticatedRole
);
}
if
(
null
!==
$event
)
{
$event
->
addRoles
(
$roles
);
}
return
$roles
;
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a 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