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
09583662
Commit
09583662
authored
Feb 27, 2019
by
Bertrand Gauthier
Browse files
Passage à ZF 2.x ; modifications minimales pour le supporter.
parent
9dd896a0
Pipeline
#3783
passed with stage
in 17 seconds
Changes
14
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
src/UnicaenAuth/Assertion/AbstractAssertion.php
View file @
09583662
...
...
@@ -11,7 +11,7 @@ use Zend\Permissions\Acl\Acl;
use
Zend\Permissions\Acl\Assertion\AssertionInterface
;
use
Zend\Permissions\Acl\Resource\ResourceInterface
;
use
Zend\Permissions\Acl\Role\RoleInterface
;
use
Zend
\ServiceManager\ServiceLocatorAwareInterface
;
use
UnicaenApp
\ServiceManager\ServiceLocatorAwareInterface
;
use
Zend\ServiceManager\ServiceLocatorAwareTrait
;
/**
...
...
src/UnicaenAuth/Authentication/Adapter/Cas.php
View file @
09583662
...
...
@@ -4,6 +4,7 @@ namespace UnicaenAuth\Authentication\Adapter;
use
phpCAS
;
use
UnicaenApp\Mapper\Ldap\People
as
LdapPeopleMapper
;
use
UnicaenApp\ServiceManager\ServiceLocatorAwareInterface
;
use
UnicaenAuth\Options\ModuleOptions
;
use
UnicaenAuth\Service\User
;
use
Zend\Authentication\Exception\UnexpectedValueException
;
...
...
@@ -12,8 +13,7 @@ use Zend\EventManager\EventManager;
use
Zend\EventManager\EventManagerAwareInterface
;
use
Zend\EventManager\EventManagerInterface
;
use
Zend\Mvc\Router\Http\TreeRouteStack
;
use
Zend\ServiceManager\ServiceManager
;
use
Zend\ServiceManager\ServiceManagerAwareInterface
;
use
Zend\ServiceManager\ServiceLocatorAwareTrait
;
use
ZfcUser\Authentication\Adapter\AbstractAdapter
;
use
ZfcUser\Authentication\Adapter\AdapterChainEvent
as
AuthEvent
;
use
ZfcUser\Authentication\Adapter\ChainableAdapter
;
...
...
@@ -23,12 +23,9 @@ use ZfcUser\Authentication\Adapter\ChainableAdapter;
*
* @author Bertrand GAUTHIER <bertrand.gauthier@unicaen.fr>
*/
class
Cas
extends
AbstractAdapter
implements
Service
ManagerAwareInterface
,
EventManage
rAwareInterface
class
Cas
extends
AbstractAdapter
implements
Event
ManagerAwareInterface
,
ServiceLocato
rAwareInterface
{
/**
* @var ServiceManager
*/
protected
$serviceManager
;
use
ServiceLocatorAwareTrait
;
/**
* @var EventManager
...
...
@@ -105,7 +102,7 @@ class Cas extends AbstractAdapter implements ServiceManagerAwareInterface, Event
$ldapPeople
=
$this
->
getLdapPeopleMapper
()
->
findOneByUsername
(
$identity
);
/* @var $userService User */
$userService
=
$this
->
getS
ervice
Manager
()
->
get
(
'unicaen-auth_user_service'
);
$userService
=
$this
->
s
ervice
Locator
->
get
(
'unicaen-auth_user_service'
);
$userService
->
userAuthenticated
(
$ldapPeople
);
}
...
...
@@ -120,7 +117,7 @@ class Cas extends AbstractAdapter implements ServiceManagerAwareInterface, Event
return
;
// NB: l'authentification CAS est désactivée ssi le tableau des options est vide
}
$router
=
$this
->
getS
ervice
Manager
()
->
get
(
'router'
);
/* @var $router TreeRouteStack */
$router
=
$this
->
s
ervice
Locator
->
get
(
'router'
);
/* @var $router TreeRouteStack */
$returnUrl
=
$router
->
getRequestUri
()
->
setPath
(
$router
->
getBaseUrl
())
->
toString
();
$this
->
getCasClient
()
->
logoutWithRedirectService
(
$returnUrl
);
}
...
...
@@ -191,8 +188,8 @@ class Cas extends AbstractAdapter implements ServiceManagerAwareInterface, Event
{
if
(
!
$this
->
options
instanceof
ModuleOptions
)
{
$options
=
array_merge
(
$this
->
getS
ervice
Manager
()
->
get
(
'zfcuser_module_options'
)
->
toArray
(),
$this
->
getS
ervice
Manager
()
->
get
(
'unicaen-auth_module_options'
)
->
toArray
());
$this
->
s
ervice
Locator
->
get
(
'zfcuser_module_options'
)
->
toArray
(),
$this
->
s
ervice
Locator
->
get
(
'unicaen-auth_module_options'
)
->
toArray
());
$this
->
setOptions
(
new
ModuleOptions
(
$options
));
}
return
$this
->
options
;
...
...
@@ -206,7 +203,7 @@ class Cas extends AbstractAdapter implements ServiceManagerAwareInterface, Event
public
function
getLdapPeopleMapper
()
{
if
(
null
===
$this
->
ldapPeopleMapper
)
{
$this
->
ldapPeopleMapper
=
$this
->
getS
ervice
Manager
()
->
get
(
'ldap_people_mapper'
);
$this
->
ldapPeopleMapper
=
$this
->
s
ervice
Locator
->
get
(
'ldap_people_mapper'
);
}
return
$this
->
ldapPeopleMapper
;
}
...
...
@@ -223,28 +220,6 @@ class Cas extends AbstractAdapter implements ServiceManagerAwareInterface, Event
return
$this
;
}
/**
* Get service manager
*
* @return ServiceManager
*/
public
function
getServiceManager
()
{
return
$this
->
serviceManager
;
}
/**
* Set service manager
*
* @param ServiceManager $serviceManager
* @return self
*/
public
function
setServiceManager
(
ServiceManager
$serviceManager
)
{
$this
->
serviceManager
=
$serviceManager
;
return
$this
;
}
/**
* Retrieve EventManager instance
*
...
...
src/UnicaenAuth/Authentication/Adapter/Db.php
View file @
09583662
...
...
@@ -2,10 +2,11 @@
namespace
UnicaenAuth\Authentication\Adapter
;
use
UnicaenApp\ServiceManager\ServiceLocatorAwareInterface
;
use
UnicaenAuth\Options\ModuleOptions
;
use
Zend\ServiceManager\Exception\ServiceNotFoundException
;
use
Zend\ServiceManager\Service
Manager
;
use
Zend\ServiceManager\Service
ManagerAware
Interface
;
use
Zend\ServiceManager\Service
LocatorAwareTrait
;
use
Zend\ServiceManager\Service
Locator
Interface
;
use
ZfcUser\Authentication\Adapter\AdapterChainEvent
as
AuthEvent
;
use
ZfcUser\Options\AuthenticationOptionsInterface
;
...
...
@@ -17,12 +18,24 @@ use ZfcUser\Options\AuthenticationOptionsInterface;
*
* @author Bertrand GAUTHIER <bertrand.gauthier@unicaen.fr>
*/
class
Db
extends
\
ZfcUser\Authentication\Adapter\Db
implements
Service
Manage
rAwareInterface
class
Db
extends
\
ZfcUser\Authentication\Adapter\Db
implements
Service
Locato
rAwareInterface
{
use
ServiceLocatorAwareTrait
;
/**
* @var ServiceManager
* Set service locator
*
* @param ServiceLocatorInterface $serviceLocator
* @return self
* @deprecated Abandonnez l'injection du service locator, svp
*/
protected
$serviceManager
;
public
function
setServiceLocator
(
ServiceLocatorInterface
$serviceLocator
)
{
$this
->
serviceLocator
=
$serviceLocator
;
$this
->
serviceManager
=
$serviceLocator
;
return
$this
;
}
/**
* Authentification.
...
...
@@ -66,26 +79,4 @@ class Db extends \ZfcUser\Authentication\Adapter\Db implements ServiceManagerAwa
}
return
$this
->
options
;
}
/**
* Get service manager
*
* @return ServiceManager
*/
public
function
getServiceManager
()
{
return
$this
->
serviceManager
;
}
/**
* Set service manager
*
* @param ServiceManager $serviceManager
* @return self
*/
public
function
setServiceManager
(
ServiceManager
$serviceManager
)
{
$this
->
serviceManager
=
$serviceManager
;
return
$this
;
}
}
\ No newline at end of file
src/UnicaenAuth/Authentication/Adapter/Ldap.php
View file @
09583662
...
...
@@ -4,6 +4,7 @@ namespace UnicaenAuth\Authentication\Adapter;
use
UnicaenApp\Exception\RuntimeException
;
use
UnicaenApp\Mapper\Ldap\People
as
LdapPeopleMapper
;
use
UnicaenApp\ServiceManager\ServiceLocatorAwareInterface
;
use
UnicaenAuth\Options\ModuleOptions
;
use
UnicaenAuth\Service\User
;
use
Zend\Authentication\Adapter\Ldap
as
LdapAuthAdapter
;
...
...
@@ -13,8 +14,7 @@ use Zend\EventManager\Event;
use
Zend\EventManager\EventManager
;
use
Zend\EventManager\EventManagerAwareInterface
;
use
Zend\EventManager\EventManagerInterface
;
use
Zend\ServiceManager\ServiceManager
;
use
Zend\ServiceManager\ServiceManagerAwareInterface
;
use
Zend\ServiceManager\ServiceLocatorAwareTrait
;
use
ZfcUser\Authentication\Adapter\AbstractAdapter
;
use
ZfcUser\Authentication\Adapter\AdapterChainEvent
as
AuthEvent
;
use
ZfcUser\Authentication\Adapter\ChainableAdapter
;
...
...
@@ -24,14 +24,11 @@ use ZfcUser\Authentication\Adapter\ChainableAdapter;
*
* @author Bertrand GAUTHIER <bertrand.gauthier@unicaen.fr>
*/
class
Ldap
extends
AbstractAdapter
implements
Service
Manage
rAwareInterface
,
EventManagerAwareInterface
class
Ldap
extends
AbstractAdapter
implements
Service
Locato
rAwareInterface
,
EventManagerAwareInterface
{
const
USURPATION_USERNAMES_SEP
=
'='
;
use
ServiceLocatorAwareTrait
;
/**
* @var ServiceManager
*/
protected
$serviceManager
;
const
USURPATION_USERNAMES_SEP
=
'='
;
/**
* @var EventManager
...
...
@@ -122,7 +119,7 @@ class Ldap extends AbstractAdapter implements ServiceManagerAwareInterface, Even
->
setMessages
([
'Authentication successful.'
]);
/* @var $userService User */
$userService
=
$this
->
getS
ervice
Manager
()
->
get
(
'unicaen-auth_user_service'
);
$userService
=
$this
->
s
ervice
Locator
->
get
(
'unicaen-auth_user_service'
);
$userService
->
userAuthenticated
(
$ldapPeople
);
}
...
...
@@ -207,7 +204,7 @@ class Ldap extends AbstractAdapter implements ServiceManagerAwareInterface, Even
public
function
getLdapPeopleMapper
()
{
if
(
null
===
$this
->
ldapPeopleMapper
)
{
$this
->
ldapPeopleMapper
=
$this
->
getS
ervice
Manager
()
->
get
(
'ldap_people_mapper'
);
$this
->
ldapPeopleMapper
=
$this
->
s
ervice
Locator
->
get
(
'ldap_people_mapper'
);
}
return
$this
->
ldapPeopleMapper
;
}
...
...
@@ -239,8 +236,8 @@ class Ldap extends AbstractAdapter implements ServiceManagerAwareInterface, Even
{
if
(
!
$this
->
options
instanceof
ModuleOptions
)
{
$options
=
array_merge
(
$this
->
getS
ervice
Manager
()
->
get
(
'zfcuser_module_options'
)
->
toArray
(),
$this
->
getS
ervice
Manager
()
->
get
(
'unicaen-auth_module_options'
)
->
toArray
());
$this
->
s
ervice
Locator
->
get
(
'zfcuser_module_options'
)
->
toArray
(),
$this
->
s
ervice
Locator
->
get
(
'unicaen-auth_module_options'
)
->
toArray
());
$this
->
setOptions
(
new
ModuleOptions
(
$options
));
}
return
$this
->
options
;
...
...
@@ -251,7 +248,7 @@ class Ldap extends AbstractAdapter implements ServiceManagerAwareInterface, Even
*/
public
function
getAppModuleOptions
()
{
return
$this
->
getS
ervice
Manager
()
->
get
(
'unicaen-app_module_options'
);
return
$this
->
s
ervice
Locator
->
get
(
'unicaen-app_module_options'
);
}
/**
...
...
@@ -285,28 +282,6 @@ class Ldap extends AbstractAdapter implements ServiceManagerAwareInterface, Even
return
$this
;
}
/**
* Get service manager
*
* @return ServiceManager
*/
public
function
getServiceManager
()
{
return
$this
->
serviceManager
;
}
/**
* Set service manager
*
* @param ServiceManager $serviceManager
* @return Ldap
*/
public
function
setServiceManager
(
ServiceManager
$serviceManager
)
{
$this
->
serviceManager
=
$serviceManager
;
return
$this
;
}
/**
* Retrieve EventManager instance
*
...
...
src/UnicaenAuth/Authentication/Storage/Db.php
View file @
09583662
...
...
@@ -3,11 +3,11 @@
namespace
UnicaenAuth\Authentication\Storage
;
use
Doctrine\DBAL\DBALException
;
use
UnicaenApp\ServiceManager\ServiceLocatorAwareInterface
;
use
Zend\Authentication\Storage\Session
;
use
Zend\Authentication\Storage\StorageInterface
;
use
Zend\ServiceManager\Exception\ServiceNotFoundException
;
use
Zend\ServiceManager\ServiceManager
;
use
Zend\ServiceManager\ServiceManagerAwareInterface
;
use
Zend\ServiceManager\ServiceLocatorAwareTrait
;
use
ZfcUser\Mapper\UserInterface
as
UserMapper
;
/**
...
...
@@ -15,8 +15,10 @@ use ZfcUser\Mapper\UserInterface as UserMapper;
*
* @author Bertrand GAUTHIER <bertrand.gauthier at unicaen.fr>
*/
class
Db
implements
ChainableStorage
,
Service
Manage
rAwareInterface
class
Db
implements
ChainableStorage
,
Service
Locato
rAwareInterface
{
use
ServiceLocatorAwareTrait
;
/**
* @var StorageInterface
*/
...
...
@@ -32,11 +34,6 @@ class Db implements ChainableStorage, ServiceManagerAwareInterface
*/
protected
$resolvedIdentity
;
/**
* @var ServiceManager
*/
protected
$serviceManager
;
/**
* Returns the contents of storage
*
...
...
@@ -177,7 +174,7 @@ class Db implements ChainableStorage, ServiceManagerAwareInterface
public
function
getMapper
()
{
if
(
null
===
$this
->
mapper
)
{
$this
->
mapper
=
$this
->
getS
ervice
Manager
()
->
get
(
'zfcuser_user_mapper'
);
$this
->
mapper
=
$this
->
s
ervice
Locator
->
get
(
'zfcuser_user_mapper'
);
}
return
$this
->
mapper
;
}
...
...
@@ -193,26 +190,4 @@ class Db implements ChainableStorage, ServiceManagerAwareInterface
$this
->
mapper
=
$mapper
;
return
$this
;
}
/**
* Retrieve service manager instance
*
* @return ServiceManager
*/
public
function
getServiceManager
()
{
return
$this
->
serviceManager
;
}
/**
* Set service manager instance
*
* @param ServiceManager $serviceManager
* @return self
*/
public
function
setServiceManager
(
ServiceManager
$serviceManager
)
{
$this
->
serviceManager
=
$serviceManager
;
return
$this
;
}
}
\ No newline at end of file
src/UnicaenAuth/Authentication/Storage/Ldap.php
View file @
09583662
...
...
@@ -2,22 +2,25 @@
namespace
UnicaenAuth\Authentication\Storage
;
use
UnicaenAuth\Entity\Ldap\People
;
use
UnicaenApp\Mapper\Ldap\People
as
LdapPeopleMapper
;
use
UnicaenApp\ServiceManager\ServiceLocatorAwareInterface
;
use
UnicaenAuth\Entity\Ldap\People
;
use
UnicaenAuth\Options\ModuleOptions
;
use
Zend\Authentication\Exception\InvalidArgumentException
;
use
Zend\Authentication\Storage\Session
;
use
Zend\Authentication\Storage\StorageInterface
;
use
Zend\ServiceManager\ServiceLocatorAwareTrait
;
use
Zend\ServiceManager\ServiceManager
;
use
Zend\ServiceManager\ServiceManagerAwareInterface
;
use
Zend\Authentication\Storage\Session
;
/**
* Ldap authentication storage.
*
* @author Bertrand GAUTHIER <bertrand.gauthier at unicaen.fr>
*/
class
Ldap
implements
ChainableStorage
,
Service
Manage
rAwareInterface
class
Ldap
implements
ChainableStorage
,
Service
Locato
rAwareInterface
{
use
ServiceLocatorAwareTrait
;
/**
* @var StorageInterface
*/
...
...
@@ -38,11 +41,6 @@ class Ldap implements ChainableStorage, ServiceManagerAwareInterface
*/
protected
$resolvedIdentity
;
/**
* @var ServiceManager
*/
protected
$serviceManager
;
/**
* Returns the contents of storage
*
...
...
@@ -154,7 +152,7 @@ class Ldap implements ChainableStorage, ServiceManagerAwareInterface
public
function
getMapper
()
{
if
(
null
===
$this
->
mapper
)
{
$this
->
mapper
=
$this
->
getS
ervice
Manager
()
->
get
(
'ldap_people_mapper'
);
$this
->
mapper
=
$this
->
s
ervice
Locator
->
get
(
'ldap_people_mapper'
);
}
return
$this
->
mapper
;
}
...
...
@@ -171,28 +169,6 @@ class Ldap implements ChainableStorage, ServiceManagerAwareInterface
return
$this
;
}
/**
* Retrieve service manager instance
*
* @return ServiceManager
*/
public
function
getServiceManager
()
{
return
$this
->
serviceManager
;
}
/**
* Set service manager instance
*
* @param ServiceManager $locator
* @return self
*/
public
function
setServiceManager
(
ServiceManager
$serviceManager
)
{
$this
->
serviceManager
=
$serviceManager
;
return
$this
;
}
/**
* @param ModuleOptions $options
*/
...
...
@@ -208,7 +184,7 @@ class Ldap implements ChainableStorage, ServiceManagerAwareInterface
public
function
getOptions
()
{
if
(
!
$this
->
options
instanceof
ModuleOptions
)
{
$this
->
setOptions
(
$this
->
getS
ervice
Manager
()
->
get
(
'unicaen-auth_module_options'
));
$this
->
setOptions
(
$this
->
s
ervice
Locator
->
get
(
'unicaen-auth_module_options'
));
}
return
$this
->
options
;
}
...
...
src/UnicaenAuth/Authentication/Storage/Shib.php
View file @
09583662
...
...
@@ -6,7 +6,7 @@ use UnicaenAuth\Entity\Shibboleth\ShibUser;
use
UnicaenAuth\Service\ShibService
;
use
Zend\Authentication\Storage\Session
;
use
Zend\Authentication\Storage\StorageInterface
;
use
Zend
\ServiceManager\ServiceLocatorAwareInterface
;
use
UnicaenApp
\ServiceManager\ServiceLocatorAwareInterface
;
use
Zend\ServiceManager\ServiceLocatorAwareTrait
;
use
Zend\ServiceManager\ServiceManager
;
...
...
src/UnicaenAuth/Form/Droits/RoleForm.php
View file @
09583662
...
...
@@ -6,7 +6,7 @@ use UnicaenAuth\Entity\Db\Role;
use
UnicaenAuth\Service\Traits\RoleServiceAwareTrait
;
use
Zend\Form\Form
;
use
UnicaenApp\Util
;
use
Zend
\ServiceManager\ServiceLocatorAwareInterface
;
use
UnicaenApp
\ServiceManager\ServiceLocatorAwareInterface
;
use
Zend\ServiceManager\ServiceLocatorAwareTrait
;
use
Zend\Stdlib\Hydrator\HydratorInterface
;
use
Zend\InputFilter\InputFilterProviderInterface
;
...
...
src/UnicaenAuth/Provider/Identity/Chain.php
View file @
09583662
...
...
@@ -8,7 +8,7 @@ use Zend\EventManager\EventManagerAwareInterface;
use
Zend\EventManager\EventManagerAwareTrait
;
use
Zend\Permissions\Acl\Role\Registry
;
use
Zend\Permissions\Acl\Role\RoleInterface
;
use
Zend
\ServiceManager\ServiceLocatorAwareInterface
;
use
UnicaenApp
\ServiceManager\ServiceLocatorAwareInterface
;
use
Zend\ServiceManager\ServiceLocatorAwareTrait
;
/**
...
...
src/UnicaenAuth/Service/AbstractService.php
View file @
09583662
...
...
@@ -4,7 +4,7 @@ namespace UnicaenAuth\Service;
use
UnicaenApp\Service\EntityManagerAwareTrait
;
use
UnicaenAuth\Options\ModuleOptions
;
use
Zend
\ServiceManager\ServiceLocatorAwareInterface
;
use
UnicaenApp
\ServiceManager\ServiceLocatorAwareInterface
;
use
Zend\ServiceManager\ServiceLocatorAwareTrait
;
abstract
class
AbstractService
implements
ServiceLocatorAwareInterface
...
...
src/UnicaenAuth/Service/User.php
View file @
09583662
...
...
@@ -20,7 +20,7 @@ use Zend\Form\Element\Submit;
use
Zend\Form\Element\Text
;
use
Zend\Form\Form
;
use
Zend\InputFilter\Input
;
use
Zend
\ServiceManager\ServiceLocatorAwareInterface
;
use
UnicaenApp
\ServiceManager\ServiceLocatorAwareInterface
;
use
Zend\ServiceManager\ServiceLocatorAwareTrait
;
use
Zend\Validator\EmailAddress
;
use
Zend\Validator\Identical
;
...
...
tests/UnicaenAuthTest/Authentication/Adapter/LdapTest.php
View file @
09583662
...
...
@@ -69,7 +69,7 @@ class LdapTest extends PHPUnit_Framework_TestCase
}));
$this
->
adapter
=
new
Ldap
();
$this
->
adapter
->
setService
Manage
r
(
$serviceManager
)
$this
->
adapter
->
setService
Locato
r
(
$serviceManager
)
->
setEventManager
(
new
EventManager
());
}
...
...
tests/UnicaenAuthTest/Authentication/Storage/DbTest.php
View file @
09583662
...
...
@@ -34,7 +34,7 @@ class DbTest extends PHPUnit_Framework_TestCase
$this
->
storage
=
new
Db
();
$this
->
storage
->
setMapper
(
$this
->
mapper
)
->
setService
Manage
r
(
$this
->
serviceManager
)
->
setService
Locato
r
(
$this
->
serviceManager
)
->
setStorage
(
$this
->
innerStorage
);
}
...
...
tests/UnicaenAuthTest/Authentication/Storage/LdapTest.php
View file @
09583662
...
...
@@ -36,7 +36,7 @@ class LdapTest extends PHPUnit_Framework_TestCase
$this
->
storage
=
new
Ldap
();
$this
->
storage
->
setMapper
(
$this
->
mapper
)
->
setService
Manage
r
(
$this
->
serviceManager
)
->
setService
Locato
r
(
$this
->
serviceManager
)
->
setStorage
(
$this
->
innerStorage
);
}
...
...
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