Cela semble être a bug of the Shibboleth module, donc la connexion 'événement' n'est en effet pas soulevée par elle (en termes de Drupal, elle n'invoque pas hook_user()
avec $op = 'login'
).
Looking at the Shibboleth code, la connexion semble se produire dans sa mise en œuvre hook_init()
:
/**
* Create a new user based on informations from the Shibboleth handler if it's necessary or log in.
*/
function shib_auth_init() {
global $user;
$unameVar = variable_get('shib_auth_username_variable', 'REMOTE_USER');
$umailVar = variable_get('shib_auth_username_email', 'HTTP_SHIB_MAIL');
// If
// - The user isn't logged in
// - There is Shibboleth authentication in the background
// - The settings are fine and there has been a valid username setted up
// - The settings are fine and there has been a valid user email address setted up
if (!$user->uid && $_SERVER['HTTP_SHIB_IDENTITY_PROVIDER']) {
if ($_SERVER[$unameVar] && $_SERVER[$umailVar]) {
user_external_login_register($_SERVER[$unameVar], "shib_auth");
}
else {
drupal_set_message(t("Username or e-mail address is missing. Maybe the Shibboleth configuration is not perfect."),"error");
}
}
if ($user->uid && $_SERVER['HTTP_SHIB_IDENTITY_PROVIDER']) {
$account = user_save($user,array('mail' => $_SERVER[$umailVar]));
// Terminate if an error occured during user_save().
if (!$account) {
drupal_set_message(t("Error saving user account."), 'error');
return;
}
$user = $account;
}
} // function shib_auth_init()
Vous aurez besoin de patcher et et veiller à ce que user_module_invoke()
est appelé. La méthode standard pour le faire serait d'appeler user_authenticate_finalize()
après une connexion réussie (qui appellera à son tour user_module_invoke()
), de sorte que vous souhaitez ajouter qu'après l'appel user_external_login_register()
:
[...]
if ($_SERVER[$unameVar] && $_SERVER[$umailVar]) {
user_external_login_register($_SERVER[$unameVar], "shib_auth");
// Do we have a logged in user now?
if ($user->uid) {
// Yes, ensure watchdog logging and proper invocation of hook_user
// NOTE: We pass an empty array, as no form submit was involved here,
// but we could also pass an array with 'unameVar' and 'umailVar',
// as they would be the closest substitute.
user_authenticate_finalize(array());
}
}
[...]
REMARQUE: code non testé, méfiez-vous de fautes de frappe et autres oublis stupides;)
Si vous finissez par le faire, vous pourriez vouloir le soumettre comme un correctif au rapport de bug lié ci-dessus. (seulement si cela fonctionne, évidemment;)
À mon humble avis, l'ordre d'exécution (ou de chargement) n'est pas pertinent ici, car le crochet n'est pas invoqué du tout! (La commande ne serait pertinente que s'il voulait réagir après une autre implémentation de modules du même hook, mais dans ce cas il n'y a rien à réagir en premier lieu) –