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
611775c6
Commit
611775c6
authored
Mar 29, 2013
by
Bertrand Gauthier
Browse files
Trop de modif!
parent
3a42de22
Changes
5
Hide whitespace changes
Inline
Side-by-side
Module.php
View file @
611775c6
...
...
@@ -187,7 +187,12 @@ class Module implements ConfigProviderInterface, ViewHelperProviderInterface, Se
// ->setDbStorage($sm->get('UnicaenAuth\Authentication\Storage\Db'));
// return $storage;
// },
'ZfcUser\Authentication\Adapter\AdapterChain'
=>
'UnicaenAuth\Authentication\Adapter\AdapterChainServiceFactory'
,
// 'ZfcUser\Authentication\Adapter\AdapterChain' => 'UnicaenAuth\Authentication\Adapter\AdapterChainServiceFactory',
'UnicaenAuth\Provider\Identity\LdapPeople'
=>
function
(
$sm
)
{
$authService
=
$sm
->
get
(
'zfcuser_auth_service'
);
$provider
=
new
\
UnicaenAuth\Provider\Identity\LdapPeople
(
$authService
);
return
$provider
;
},
),
);
}
...
...
config/module.config.php
View file @
611775c6
...
...
@@ -54,8 +54,8 @@ $zfcuserSettings = array(
'auth_adapters'
=>
array
(
// 100 => 'UnicaenAuth\Authentication\Service\StrategyService',
300
=>
'UnicaenAuth\Authentication\Adapter\Ldap'
,
// notifié en 1er
200
=>
'UnicaenAuth\Authentication\Adapter\Db'
,
//
2
e (si échec d'authentification Ldap)
100
=>
'UnicaenAuth\Authentication\Adapter\Cas'
,
//
3
e (si échec d'authentification Db)
200
=>
'UnicaenAuth\Authentication\Adapter\Db'
,
//
ensuit
e (si échec d'authentification Ldap)
100
=>
'UnicaenAuth\Authentication\Adapter\Cas'
,
//
ensuit
e (si échec d'authentification Db)
),
);
...
...
src/UnicaenAuth/Provider/Identity/LdapPeople.php
0 → 100644
View file @
611775c6
<?php
namespace
UnicaenAuth\Provider\Identity
;
use
BjyAuthorize\Exception\InvalidRoleException
;
use
BjyAuthorize\Provider\Identity\ProviderInterface
;
use
Zend\Authentication\AuthenticationService
;
use
Zend\Permissions\Acl\Role\RoleInterface
;
use
Zend\ServiceManager\ServiceLocatorAwareInterface
;
use
Zend\ServiceManager\ServiceLocatorInterface
;
/**
* Description of LdapGroupProviderInterface
*
* @author Bertrand GAUTHIER <bertrand.gauthier at unicaen.fr>
*/
class
LdapPeople
implements
ProviderInterface
,
ServiceLocatorAwareInterface
{
/**
* @var ServiceLocatorAwareInterface
*/
protected
$serviceLocator
;
/**
* @var AuthenticationService
*/
protected
$authService
;
/**
* @var string|RoleInterface
*/
protected
$defaultRole
=
'guest'
;
/**
* @param AuthenticationService $authService
*/
public
function
__construct
(
AuthenticationService
$authService
)
{
$this
->
authService
=
$authService
;
}
/**
* Retrieve roles for the current identity
*
* @return string[]|RoleInterface[]
*/
public
function
getIdentityRoles
()
{
$roles
=
array
();
$identity
=
$this
->
authService
->
getIdentity
();
if
(
$identity
instanceof
\
UnicaenApp\Entity\Ldap\People
)
{
/* @var $identity \UnicaenApp\Entity\Ldap\People */
$authorizeService
=
$this
->
getServiceLocator
()
->
get
(
'BjyAuthorize\Service\Authorize'
);
/* @var $authorizeService \BjyAuthorize\Service\Authorize */
foreach
(
$identity
->
getMemberOf
()
as
$group
)
{
if
(
$authorizeService
->
getAcl
()
->
hasRole
(
$group
))
{
$roles
[]
=
$group
;
}
}
}
if
(
!
$roles
)
{
$roles
=
array
(
$this
->
getDefaultRole
());
}
// var_dump($roles);
return
$roles
;
}
/**
* Get the rule that's used if you're not authenticated
*
* @return string|RoleInterface
*/
public
function
getDefaultRole
()
{
return
$this
->
defaultRole
;
}
/**
* Set the rule that's used if you're not authenticated
*
* @param $defaultRole
*
* @throws \BjyAuthorize\Exception\InvalidRoleException
*/
public
function
setDefaultRole
(
$defaultRole
)
{
if
(
!
(
$defaultRole
instanceof
RoleInterface
||
is_string
(
$defaultRole
)))
{
throw
InvalidRoleException
::
invalidRoleInstance
(
$defaultRole
);
}
$this
->
defaultRole
=
$defaultRole
;
}
/**
* Set service locator
*
* @param \Zend\ServiceManager\ServiceLocatorInterface $serviceLocator
*/
public
function
setServiceLocator
(
ServiceLocatorInterface
$serviceLocator
)
{
$this
->
serviceLocator
=
$serviceLocator
;
return
$this
;
}
/**
* Get service locator
*
* @return \Zend\ServiceManager\ServiceLocatorInterface
*/
public
function
getServiceLocator
()
{
return
$this
->
serviceLocator
;
}
}
src/UnicaenAuth/View/Helper/UserCurrent.php
View file @
611775c6
...
...
@@ -55,7 +55,7 @@ EOS;
$out
.
=
<<<EOS
<script type="text/javascript">
$(function() {
$("#$id").popover({ html: true });
$("#$id").popover({ html: true
, container: 'body'
});
});
</script>
EOS;
...
...
src/UnicaenAuth/View/Helper/UserInfo.php
View file @
611775c6
...
...
@@ -22,18 +22,17 @@ class UserInfo extends UserAbstract
/**
* @var bool
*/
protected
$affectation
FineSiDispo
=
false
;
protected
$affectation
Principale
=
false
;
/**
* Point d'entrée.
*
* @param boolean $affectationFineSiDispo Indique s'il faut prendre en compte l'affectation
* plus fine (ucbnSousStructure) si elle existe, à la place de l'affectation standard (niveau 2)
* @param boolean $affectationPrincipale Indique s'il ne faut prendre en compte que l'affectation principale
* @return UserInfo
*/
public
function
__invoke
(
$affectation
FineSiDispo
=
false
)
public
function
__invoke
(
$affectation
Principale
=
false
)
{
$this
->
setAffectation
FineSiDispo
(
$affectation
FineSiDispo
);
$this
->
setAffectation
Principale
(
$affectation
Principale
);
return
$this
;
}
...
...
@@ -58,9 +57,9 @@ class UserInfo extends UserAbstract
if
(
$authIdentity
instanceof
People
)
{
// affectations admin
$affectations
=
$authIdentity
->
getAffectationsAdmin
(
$this
->
get
AffectationFineSiDispo
());
$affectations
=
$authIdentity
->
getAffectationsAdmin
(
$this
->
get
ServiceStructure
()
->
getMapper
(),
$this
->
getAffectationPrincipale
());
if
(
$affectations
)
{
$affectations
=
(
array
)
$this
->
getServiceStructure
()
->
getMapper
()
->
findChemin
(
array_keys
(
$affectations
));
//
$affectations = (array)$this->getServiceStructure()->getMapper()->findChemin(array_keys($affectations));
if
(
empty
(
$affectations
))
$affectations
[]
=
$this
->
getView
()
->
translate
(
"Aucune affectation trouvée."
);
ksort
(
$affectations
);
...
...
@@ -100,7 +99,7 @@ class UserInfo extends UserAbstract
// && $authIdentity->getLdapIdentityData() instanceof Unicaen_Model_LdapPeople) {
//
// // affectations admin
// $affectations = $authIdentity->getLdapIdentityData()->getAffectationsAdmin($this->getAffectation
FineSiDispo
());
// $affectations = $authIdentity->getLdapIdentityData()->getAffectationsAdmin($this->getAffectation
Principale
());
// if ($affectations) {
// $affectations = (array)$this->getServiceStructure()->findChemin(array_keys($affectations));
// if (empty($affectations))
...
...
@@ -163,23 +162,23 @@ class UserInfo extends UserAbstract
}
/**
* Indique si l'affichage de l'affectation
fine éventuelle
est activé ou non.
* Indique si l'affichage de l'affectation
princiaple seulement
est activé ou non.
* @return bool
*/
public
function
getAffectation
FineSiDispo
()
public
function
getAffectation
Principale
()
{
return
$this
->
affectation
FineSiDispo
;
return
$this
->
affectation
Principale
;
}
/**
* Active ou non l'affichage de l'affectation
fine éventuelle
.
* Active ou non l'affichage de l'affectation
principale seulement
.
*
* @param bool $affectation
FineSiDispo
* @param bool $affectation
Principale
* @return UserInfo
*/
public
function
setAffectation
FineSiDispo
(
$affectation
FineSiDispo
=
true
)
public
function
setAffectation
Principale
(
$affectation
Principale
=
true
)
{
$this
->
affectation
FineSiDispo
=
$affectation
FineSiDispo
;
$this
->
affectation
Principale
=
$affectation
Principale
;
return
$this
;
}
...
...
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