Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
Christophe Turbout
auth
Commits
c9f7265e
Commit
c9f7265e
authored
Apr 23, 2019
by
Bertrand Gauthier
Browse files
Merge branch 'release-1.3.8'
parents
c8467a2a
fa40379e
Changes
3
Hide whitespace changes
Inline
Side-by-side
config/unicaen-auth.global.php.dist
View file @
c9f7265e
...
...
@@ -28,6 +28,22 @@ $settings = [
'enabled'
=>
true
,
],
/**
* Configuration de l'authentification Shibboleth.
*/
'shibboleth'
=>
[
/**
* Affichage ou non du formulaire d'authentification via l'annuaire LDAP.
* NB: en réalité cela permet aussi l'authentification avec un compte local.
*/
'enable'
=>
false
,
/**
* URL de déconnexion.
*/
'logout_url'
=>
'/Shibboleth.sso/Logout?return='
,
// NB: '?return=' semble obligatoire!
],
/**
* Flag indiquant si l'utilisateur authenitifié avec succès via l'annuaire LDAP doit
* être enregistré/mis à jour dans la table des utilisateurs de l'appli.
...
...
src/UnicaenAuth/Options/ModuleOptionsFactory.php
View file @
c9f7265e
...
...
@@ -2,6 +2,9 @@
namespace
UnicaenAuth\Options
;
use
Assert\Assertion
;
use
Assert\AssertionFailedException
;
use
UnicaenApp\Exception\RuntimeException
;
use
Zend\ServiceManager\FactoryInterface
;
use
Zend\ServiceManager\ServiceLocatorInterface
;
...
...
@@ -24,6 +27,42 @@ class ModuleOptionsFactory implements FactoryInterface
$moduleConfig
=
isset
(
$config
[
'unicaen-auth'
])
?
$config
[
'unicaen-auth'
]
:
[];
$moduleConfig
=
array_merge
(
$config
[
'zfcuser'
],
$moduleConfig
);
$this
->
validateConfig
(
$moduleConfig
);
return
new
ModuleOptions
(
$moduleConfig
);
}
/**
* @param array $config
*/
private
function
validateConfig
(
array
$config
)
{
$configKeyPath
=
[
'unicaen-auth'
];
//
// Config shibboleth.
//
$parentKey
=
'shibboleth'
;
if
(
array_key_exists
(
$parentKey
,
$config
))
{
$shibConfig
=
$config
[
$parentKey
];
$configKeyPath
[]
=
$parentKey
;
try
{
Assertion
::
keyExists
(
$shibConfig
,
$k
=
'logout_url'
);
}
catch
(
AssertionFailedException
$e
)
{
throw
new
RuntimeException
(
sprintf
(
"La clé de configuration '%s.
$k
' est absente (inspirez-vous du fichier de config "
.
"unicaen-auth.global.php.dist du module unicaen/auth si besoin)"
,
join
(
'.'
,
$configKeyPath
)
));
}
array_pop
(
$configKeyPath
);
}
//
// Autres.
//
}
}
\ No newline at end of file
src/UnicaenAuth/Service/ShibService.php
View file @
c9f7265e
...
...
@@ -100,7 +100,10 @@ EOS;
*/
private
function
isAuthenticated
()
{
return
(
bool
)
$this
->
getServerArrayVariable
(
'REMOTE_USER'
);
return
$this
->
getServerArrayVariable
(
'REMOTE_USER'
)
||
$this
->
getServerArrayVariable
(
'Shib-Session-ID'
)
||
$this
->
getServerArrayVariable
(
'HTTP_SHIB_SESSION_ID'
);
}
/**
...
...
@@ -363,7 +366,7 @@ EOS;
*/
public
function
simulateAuthenticatedUser
(
ShibUser
$shibUser
,
$keyForId
=
'supannEmpId'
)
{
// 'REMOTE_USER' est utilisé pour savoir si un utilisateur est authentifié ou non
// 'REMOTE_USER'
(notamment)
est utilisé pour savoir si un utilisateur est authentifié ou non
$this
->
setServerArrayVariable
(
'REMOTE_USER'
,
$shibUser
->
getEppn
());
// // on s'assure que tous les attributs obligatoires ont une valeur
...
...
@@ -434,13 +437,13 @@ EOS;
return
'/'
;
}
$logout
RelativeUrl
=
'/Shibboleth.sso/Logout?return='
;
// NB: '?return=' semble obligatoire!
$logout
Url
=
$this
->
shibbolethConfig
[
'logout_url'
];
if
(
$returnAbsoluteUrl
)
{
$logout
Relative
Url
.
=
urlencode
(
$returnAbsoluteUrl
);
$logoutUrl
.
=
urlencode
(
$returnAbsoluteUrl
);
}
return
$logout
Relative
Url
;
return
$logoutUrl
;
}
/**
...
...
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