Begin simplesmal impletation
* saml_options.php: load simplesamlphp * balise/login_saml.php: begin support of login, logout and attributes sync * plugin.xml: spip plugin definitions
This commit is contained in:
parent
65b9498f77
commit
66c59cdd0c
|
@ -0,0 +1,93 @@
|
|||
<?php
|
||||
|
||||
/***************************************************************************\
|
||||
* SPIP, Systeme de publication pour l'internet *
|
||||
* *
|
||||
* Copyright (c) 2001-2007 *
|
||||
* Arnaud Martin, Antoine Pitrou, Philippe Riviere, Emmanuel Saint-James *
|
||||
* *
|
||||
* Ce programme est un logiciel libre distribue sous licence GNU/GPL. *
|
||||
* Pour plus de details voir le fichier COPYING.txt ou l'aide en ligne. *
|
||||
\***************************************************************************/
|
||||
|
||||
if (!defined("_ECRIRE_INC_VERSION")) return; #securite
|
||||
|
||||
include_spip('inc/headers');
|
||||
include_spip('inc/session');
|
||||
include_spip('inc/cookie');
|
||||
include_spip('inc/texte');
|
||||
|
||||
// http://doc.spip.org/@balise_URL_LOGOUT
|
||||
function balise_LOGIN_SAML ($p) {
|
||||
return calculer_balise_dynamique($p,'LOGIN_SAML', array());
|
||||
}
|
||||
|
||||
// $args[0] = url destination apres logout [(#URL_LOGOUT{url})]
|
||||
// http://doc.spip.org/@balise_URL_LOGOUT_stat
|
||||
function balise_LOGIN_SAML_stat ($args, $filtres) {
|
||||
return array($args[0]);
|
||||
}
|
||||
|
||||
// http://doc.spip.org/@balise_URL_LOGOUT_dyn
|
||||
function balise_LOGIN_SAML_dyn()
|
||||
{
|
||||
|
||||
global $simplesaml;
|
||||
|
||||
if (!$simplesaml->isAuthenticated()) {
|
||||
$url = lire_config('saml/login_url');
|
||||
spip_log("[auth_shib] login url =".$url);
|
||||
|
||||
// Appeler le squelette du formulaire de login
|
||||
return array('formulaires/saml',
|
||||
$GLOBALS['delais'],array('saml_url' => $url));
|
||||
}
|
||||
else return login_saml_successfull();
|
||||
}
|
||||
|
||||
function login_saml_successfull()
|
||||
{
|
||||
|
||||
global $simplesaml;
|
||||
|
||||
spip_log("[auth_saml] Traitement login SAML");
|
||||
|
||||
$attributes = $simplesaml->getAttributes();
|
||||
$login = $attributes['uid'][0];
|
||||
$first_name = $attributes['gn'][0];
|
||||
$last_name = $attributes['sn'][0];
|
||||
$email = $attributes['email'][0];
|
||||
$given_name = $first_name . ' ' . $last_name;
|
||||
|
||||
spip_log("[auth_saml] authentification reussi pour l'utilisateur =".$login);
|
||||
|
||||
// Si l'utilisateur figure deja dans la base, y recuperer les infos
|
||||
$result = spip_query("SELECT * FROM spip_auteurs WHERE login=" ._q($login). " AND statut<>'5poubelle'" );
|
||||
$row_auteur = spip_fetch_array($result);
|
||||
|
||||
spip_log("[auth_saml] attribus utilisateur =".$row_auteur['login']);
|
||||
|
||||
if ($row_auteur) {
|
||||
$GLOBALS['auteur_session'] = $row_auteur;
|
||||
|
||||
spip_log("[auth_saml] updating user [" . $login . "] attributes : ".\
|
||||
$given_name);
|
||||
spip_query("UPDATE spip_auteurs SET nom=" . \
|
||||
_q($display_name) . \
|
||||
", email=" . _q($email) . \
|
||||
" WHERE login="._q($login));
|
||||
|
||||
$session = charger_fonction('session', 'inc');
|
||||
$cookie_session = $session($row_auteur);
|
||||
spip_setcookie('spip_session', $cookie_session);
|
||||
$redirect = _DIR_RESTREINT_ABS. "?bonjour=oui";
|
||||
redirige_par_entete($redirect);
|
||||
}
|
||||
else
|
||||
{
|
||||
// Logout SAML au cas ou
|
||||
$simplesaml->logout();
|
||||
}
|
||||
}
|
||||
|
||||
?>
|
|
@ -0,0 +1,22 @@
|
|||
<plugin>
|
||||
<nom>SPIPSaml</nom>
|
||||
<auteur>[Jérôme Schneider->jschneider@entrouvert.org]</auteur>
|
||||
<version>0.1</version>
|
||||
<etat>experimental</etat>
|
||||
<description>
|
||||
<multi>
|
||||
[en]SAML plugin providing Shibboleth authentication.
|
||||
[fr]plugin SPIP fournissant une authentification SAML.
|
||||
</multi>
|
||||
</description>
|
||||
<lien>
|
||||
[http://repos.entrouvert.org/spip-saml.git->http://repos.entrouvert.org/spip-saml.git]
|
||||
</lien>
|
||||
<options>saml_options.php</options>
|
||||
<!-- <fonctions>mes_fonctions.php</fonctions> -->
|
||||
<prefix>saml</prefix>
|
||||
<pipeline>
|
||||
<nom>ajouter_boutons</nom>
|
||||
<inclure>shib_pipelines_private.php</inclure>
|
||||
</pipeline>
|
||||
</plugin>
|
|
@ -0,0 +1,8 @@
|
|||
<?
|
||||
|
||||
/* Chargement de la lib simplaesamlphp Debian */
|
||||
require_once('/usr/share/simplesamlphp/lib/_autoload.php');
|
||||
|
||||
$simplesaml = new SimpleSAML_Auth_Simple('default-sp');
|
||||
|
||||
?>
|
Reference in New Issue