/trunk/tools/login/libs/identificationsso.class.php |
---|
New file |
0,0 → 1,180 |
<?php |
class identificationSso { |
private $wiki = null; |
private $config = null; |
private $cookie_tentative_identification = ""; |
private $delai_tentative_identification = 60; |
public function __construct($wiki) { |
$this->wiki = $wiki; |
$this->config = $wiki->config; |
$this->cookie_tentative_identification = 'wikini_sso_tentative_identification'; |
} |
function getToken() { |
// Premier essai, dans le header |
$headers = @apache_request_headers(); |
$token = !empty($headers['Authorization']) ? $headers['Authorization'] : null; |
// Sinon dans $_REQUEST ? |
if($token == null) { |
$token = !empty($_REQUEST['Authorization']) ? $_REQUEST['Authorization'] : null; |
} |
// Sinon dans $_COOKIE ? |
if($token == null) { |
$token = !empty($_COOKIE['tb_auth']) ? $_COOKIE['tb_auth'] : null; |
} |
return $token; |
} |
function decoderToken($token) { |
$token_parts = explode('.', $token); |
return json_decode(base64_decode($token_parts[1]), true); |
} |
function getPage() { |
return !empty($this->wiki->page) ? $this->wiki->page['tag'] : 'PagePrincipale'; |
} |
// http://stackoverflow.com/questions/1251582/beautiful-way-to-remove-get-variables-with-php?lq=1 |
function supprimerUrlVar($url, $var) { |
return rtrim(preg_replace('/([?&])'.$var.'=[^&]+(&|$)/','$1',$url), '&?'); |
} |
function getInfosCookie() { |
$infos = null; |
if(!empty($_COOKIE[$this->cookie_tentative_identification])) { |
$infos = json_decode($_COOKIE[$this->cookie_tentative_identification], true); |
} |
return $infos; |
} |
function setInfosCookie($infos) { |
$infos['expire'] = !empty($infos['expire']) ? $infos['expire'] : 0; |
setcookie($this->cookie_tentative_identification, json_encode($infos), $infos['expire'], $this->wiki->CookiePath); |
} |
function verifierEtInsererUtilisateurParJeton($jeton_rafraichi) { |
if(!empty($jeton_rafraichi['session']) && $jeton_rafraichi['session'] == true) { |
$token_decode = $this->decoderToken($jeton_rafraichi['token']); |
$nom_wiki = $token_decode['nomWiki']; |
$courriel = $token_decode['sub']; |
$utilisateur_wiki_existe = $this->wiki->LoadAll("SELECT * FROM ".$this->wiki->config["table_prefix"]."users ". |
"WHERE ". |
"name = '".mysql_escape_string($nom_wiki)."' OR ". |
"email = '".mysql_escape_string($courriel)."'"); |
// pas inscrit ? on l'ajout à la base de données |
if(empty($utilisateur_wiki_existe)) { |
// mot de passe généré à l'arrache, le mieux serait de trouver celui de tela encodé |
// mais en gérant bien le sso on peut s'en passer car l'utilisateur ne devrait jamais avoir |
// à s'identifier par le wiki |
$pool = '0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ'; |
$pass = substr(str_shuffle(str_repeat($pool, 16)), 0, 16); |
$this->wiki->Query("insert into ".$this->wiki->config["table_prefix"]."users set ". |
"signuptime = now(), ". |
"name = '".mysql_escape_string($token_decode['nomWiki'])."', ". |
"email = '".mysql_escape_string($token_decode['sub'])."', ". |
"password = md5('".mysql_escape_string($pass)."')"); |
} else { |
// Un utilisateur peut déjà s'être inscrit sur le wiki avec un autre nom que son pseudo |
$nom_wiki = $utilisateur_wiki_existe[0]['name']; |
// s'il existe un enregistrement avec ce mail et un autre avec ce nomWiki on garde celui qui correspond au bon courriel |
foreach($utilisateur_wiki_existe as $utilisateur_wiki) { |
if($utilisateur_wiki['email'] == $courriel) { |
$nom_wiki = $utilisateur_wiki['name']; |
} |
} |
} |
} |
return $nom_wiki; |
} |
function recupererIdentiteConnectee() { |
$infos_cookie = $this->getInfosCookie(); |
if($infos_cookie == null || $infos_cookie['tentative_identification'] == false) { |
// peut importe si l'annuaire répond oui ou non, on a fait une tentative d'identification |
// et si on a trouvé quelqu'un on ne réésaiera pas jusqu'à la fermeture du navigateur |
$infos_cookie = array('tentative_identification' => true, 'expire' => 0); |
$this->setInfosCookie($infos_cookie); |
$annuaire_url = $this->wiki->config['sso_url'].'identite'; |
// Attention si le paramètre wiki de l'url est vide, la redirection de retour pose des problèmes |
$url = $annuaire_url.'?redirect_url='.urlencode($this->wiki->config['base_url'].$this->getPage()); |
header('Location: '.$url); |
exit; |
} else { |
$token = $this->getToken(); |
if($token != null) { |
// On demande à l'annuaire si le jeton est bien valide |
$jeton_rafraichi = json_decode(file_get_contents($this->wiki->config['sso_url'].'rafraichir?token='.$token), true); |
$nom_wiki = $this->verifierEtInsererUtilisateurParJeton($jeton_rafraichi); |
$token_decode = $this->decoderToken($jeton_rafraichi['token']); |
// dans le pire des cas, si on se déconnecte dans une autre application, on sera déconnecté |
// lorsque le jeton expirera |
$infos_cookie = array('tentative_identification' => true, 'expire' => time()+$jeton_rafraichi['duration']); |
$this->setInfosCookie($infos_cookie); |
$this->wiki->SetUser($this->wiki->LoadUser($nom_wiki)); |
} else { |
// personne n'a été trouvé ? on remplace le cookie par un de durée plus courte |
// pour rééssayer dans delai_tentative_identification si on en a pas déjà un |
if($infos_cookie['expire'] == 0) { |
$infos_cookie['expire'] = time()+$this->delai_tentative_identification; |
$this->setInfosCookie($infos_cookie); |
} |
} |
} |
} |
function connecterUtilisateur($login, $pass, $url_redirect = null) { |
if(strpos($login, '@') === false) { |
$utilisateur_wiki = $this->wiki->LoadSingle("SELECT email FROM ".$this->wiki->config["table_prefix"]."users ". |
"WHERE name = '".mysql_escape_string($login)."'"); |
$login = !empty($utilisateur_wiki) ? $utilisateur_wiki['email'] : $login; |
// TODO: si le courriel a changé dans l'annuaire, on devrait mettre à jour les informations |
// si on a utilisé le nom wiki pour s'identifier mais le flow du programme rend cela complexe |
} |
$url_redirect = ($url_redirect == null) ? $this->wiki->config['base_url'].'PagePrincipale' : $url_redirect; |
// le cookie de tentative d'identification est remis à zéro pour qu'au rechargement de la page il vérifie l'identité |
// connectée du nouvel utilisateur |
$infos_cookie = array('tentative_identification' => false, 'expire' => 0); |
$this->setInfosCookie($infos_cookie); |
// On demande à l'annuaire si l'utilisateur est bien valide |
$annuaire_url = $this->wiki->config['sso_url'].'connexion?login='.$login.'&password='.$pass; |
$url = $annuaire_url.'&redirect_url='.urlencode($url_redirect); |
header('Location: '.$url); |
exit; |
} |
function deconnecterUtilisateur($url_redirect = null) { |
$url_redirect = ($url_redirect == null) ? $this->wiki->config['base_url'].'PagePrincipale' : $url_redirect; |
// Suppression d'un eventuel jeton contenu dans l'url |
$url_redirect = $this->supprimerUrlVar($url_redirect, 'Authorization'); |
$infos_cookie = array('tentative_identification' => false, 'expire' => 0); |
$this->setInfosCookie($infos_cookie); |
// On demande à l'annuaire si l'utilisateur est bien valide |
$annuaire_url = $this->wiki->config['sso_url'].'deconnexion'; |
$url = $annuaire_url.'?redirect_url='.urlencode($url_redirect); |
header('Location: '.$url); |
exit; |
} |
} |
?> |
Property changes: |
Added: svn:executable |
+* |
\ No newline at end of property |
/trunk/tools/login/libs/squelettephp.class.php |
---|
New file |
0,0 → 1,48 |
<?php |
// Auteur d'origine : Brian Lozier |
// Source : http://www.massassi.com/php/articles/template_engines/ |
class SquelettePhp { |
private $vars; // Contient toutes les variables à insérer dans le squelette |
/** |
* Constructeur |
* |
* @param $fichier string le nom du fichier de template à charger. |
*/ |
public function __construct($fichier_tpl = null) |
{ |
$this->fichier = $fichier_tpl; |
} |
/** |
* Ajout une variable pour le squelette. |
*/ |
public function set($nom, $valeur = null) |
{ |
if (is_null($valeur) && is_array($nom)) { |
$this->vars = $nom; |
} else if ($valeur instanceof SquelettePhp) { |
$this->vars[$nom] = $valeur->analyser(); |
} else { |
$this->vars[$nom] = $valeur; |
} |
} |
/** |
* Ouvre, parse, and retourne le squelette. |
* |
* @param $fichier string le nom du fichier squelette. |
*/ |
public function analyser($fichier = null) |
{ |
if(!$fichier) $fichier = $this->fichier; |
extract($this->vars); // Extrait les variables et les ajoutes à l'espace de noms local |
ob_start(); // Démarre le buffer |
include($fichier); // Inclusion du fichier |
$contenu = ob_get_contents(); // Récupérer le contenu du buffer |
ob_end_clean(); // Arrête et détruit le buffer |
return $contenu; // Retourne le contenu |
} |
} |
?> |
Property changes: |
Added: svn:executable |
+* |
\ No newline at end of property |
/trunk/tools/login/wiki.php |
---|
New file |
0,0 → 1,13 |
<?php |
// Partie publique |
if (!defined("WIKINI_VERSION")) |
{ |
die ("accès direct interdit"); |
} |
// Code pour l'inclusion des langues |
include_once 'tools/login/lang/login_'.$wakkaConfig['lang'].'.inc.php'; |
?> |
Property changes: |
Added: svn:executable |
+* |
\ No newline at end of property |
/trunk/tools/login/README.txt |
---|
New file |
0,0 → 1,7 |
# Utilisation du sso avec wikini |
Afin de pouvoir utiliser le sso, en plus du remplacement de ce tool |
il faut ajouter deux variables de configuration au wiki : |
sso_url => 'https://localhost/annuaire/jrest/auth/' |
use_sso => '1' |
Property changes: |
Added: svn:eol-style |
+native |
\ No newline at end of property |
/trunk/tools/login/presentation/templates/default.tpl.html |
---|
New file |
0,0 → 1,46 |
<?php if ($connected) : ?> |
<h5><i class="icon-user"></i> <?php echo LOGIN_CONNECTED_AS.' '.$user; ?></h5> |
<ul class="login-actions"> |
<?php echo $PageMenuUser; ?> |
<li><a href="<?php echo $profileurl; ?>" title="<?php echo LOGIN_MODIFY_USER; ?>"><?php echo LOGIN_MODIFY_USER; ?></a></li> |
<li><a href="<?php echo $incomingurl; ?>&action=logout" class="login-signout-link" title="<?php echo LOGIN_LOGOUT; ?>"><?php echo LOGIN_LOGOUT; ?></a></li> |
</ul> |
<?php else : ?> |
<?php if ($error) : ?> |
<div class="alert alert-error"><button type="button" class="close" data-dismiss="alert">×</button><?= $error; ?></div> |
<?php endif; ?> |
<form class="form-horizontal" action="<?php echo $incomingurl; ?>" method="post"> |
<?php if ($signupurl != '' && $signupurl != '0') : ?><h5><?php echo LOGIN_ALREADY_MEMBER; ?></h5><?php endif; ?> |
<div class="control-group"> |
<label for="inputWikiName" class="control-label"><?php echo LOGIN_WIKINAME; ?></label> |
<div class="controls"> |
<input id="inputWikiName" class="input-medium" required="required" placeholder="<?php echo LOGIN_WIKINAME; ?>" type="text" name="name" value="<?php if($user) echo htmlspecialchars($user); ?>" /> |
</div> |
</div> |
<div class="control-group"> |
<label for="inputPassword" class="control-label"><?php echo LOGIN_PASSWORD; ?></label> |
<div class="controls"> |
<input id="inputPassword" class="input-medium" required="required" placeholder="<?php echo LOGIN_PASSWORD; ?>" name="password" type="password" /> |
</div> |
</div> |
<div class="control-group"> |
<div class="controls"> |
<label class="checkbox" for="remember-default"> |
<input type="checkbox" id="remember-default" name="remember" value="1" /><?php echo LOGIN_REMEMBER_ME; ?> |
</label> |
</div> |
</div> |
<div class="control-group"> |
<div class="controls"> |
<button type="submit" class="btn <?php if ($btnclass!='') echo ' '.$btnclass; ?>"><i class="icon-user"></i> <?php echo LOGIN_LOGIN; ?></button> |
</div> |
</div> |
<input type="hidden" name="action" value="login" /> |
<input type="hidden" name="incomingurl" value="<?php echo $userpage; ?>" /> |
<input type="hidden" name="remember" value="0" /> |
<?php if ($signupurl != '' && $signupurl != '0') : ?> |
<h5><?php echo LOGIN_NEW_MEMBER; ?></h5> |
<a class="btn <?php if ($btnclass!='') echo ' '.$btnclass; ?>" href="<?php echo $signupurl; ?>"><i class="icon-plus"></i> <?php echo LOGIN_SIGNUP; ?></a> |
<?php endif; ?> |
</form> <!-- /.form-horizontal --> |
<?php endif; ?> |
Property changes: |
Added: svn:executable |
+* |
\ No newline at end of property |
/trunk/tools/login/presentation/templates/horizontal.tpl.html |
---|
New file |
0,0 → 1,26 |
<?php if ($connected) : ?> |
<div class="btn-group"> |
<button data-toggle="dropdown" class="btn dropdown-toggle<?php if ($btnclass!='') echo ' '.$btnclass; ?>"><i class="icon-user"></i> <?php echo $user; ?> <span class="caret"></span></button> |
<ul class="dropdown-menu"> |
<?php echo $PageMenuUser; ?> |
<li><a href="<?php echo $profileurl; ?>" title="<?php echo LOGIN_MODIFY_USER; ?>"><?php echo LOGIN_MODIFY_USER; ?></a></li> |
<li><a href="<?php echo $incomingurl; ?>&action=logout" class="login-signout-link" title="<?php echo LOGIN_LOGOUT; ?>"><?php echo LOGIN_LOGOUT; ?></a></li> |
</ul> |
</div> |
<?php else : ?> |
<?php if ($error) : ?> |
<div class="alert alert-error"><button type="button" class="close" data-dismiss="alert">×</button><?= $error; ?></div> |
<?php endif; ?> |
<form class="form-inline" action="<?php echo $incomingurl; ?>" method="post"> |
<input id="inputWikiName" class="input-small" required="required" placeholder="<?php echo LOGIN_WIKINAME; ?>" type="text" name="name" value="<?php if($user) echo htmlspecialchars($user); ?>" /> |
<input id="inputPassword" class="input-small" required="required" placeholder="<?php echo LOGIN_PASSWORD; ?>" name="password" type="password" /> |
<label class="checkbox" for="remember-horizontal"> |
<input type="checkbox" id="remember-horizontal" name="remember" value="1" /><?php echo LOGIN_REMEMBER_ME; ?> |
</label> |
<button type="submit" class="btn<?php if ($btnclass!='') echo ' '.$btnclass; ?>"><i class="icon-user"></i> <?php echo LOGIN_LOGIN; ?></button> |
<?php if ($signupurl != '' && $signupurl != '0') : ?><a class="btn <?php if ($btnclass!='') echo ' '.$btnclass; ?>" href="<?php echo $signupurl; ?>"><i class="icon-plus"></i> <?php echo LOGIN_SIGNUP; ?></a><?php endif; ?> |
<input type="hidden" name="action" value="login" /> |
<input type="hidden" name="incomingurl" value="<?php echo $userpage; ?>" /> |
<input type="hidden" name="remember" value="0" /> |
</form> |
<?php endif; ?> |
Property changes: |
Added: svn:executable |
+* |
\ No newline at end of property |
/trunk/tools/login/presentation/templates/horizontal.en.tpl.html |
---|
New file |
0,0 → 1,54 |
<?php if ($connected) : ?> |
<a data-target="#loginModal" data-toggle="modal"> |
<i class="icon-user"></i><?= $user; ?> |
</a> |
<!-- Modal --> |
<div id="loginModal" class="modal hide fade" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true"> |
<div class="modal-header"> |
<button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button> |
<h3 id="myModalLabel">Connected as <?= $user; ?></h3> |
</div> |
<form class="login-inline-form" method="post" id="signout" action="<?= $signupurl; ?>"> |
<div class="modal-body"> |
<?= $PageMenuUser; ?> |
<input type="hidden" name="incomingurl" value="<?= $userpage; ?>" /> |
<a class="btn btn-block" href="<?= $signupurl; ?>" title="Change my settings">Change my account's settings</a></span> |
<input class="btn btn-block btn-danger login-signout-button" type="button" value="Logout" onclick="document.location='<?= $signupurl; ?>&action=logout'" /> |
</div> |
</form> |
</div> |
<?php else : ?> |
<a data-target="#loginModal" data-toggle="modal" class="link_login"><img src="tools/login/presentation/images/user-icon10-black.gif" height="10" width="8" style="margin:2px 5px 0 0" alt="user" /><span>Sign-in</span></a> |
<span class="login-link"><a href="<?= $signupurl; ?>" title="Register">Register</a></span> |
<div id="loginModal" class="modal hide fade" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true"> |
<div class="modal-header"> |
<button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button> |
<h3 id="myModalLabel">Login form</h3> |
</div> |
<form class="form-horizontal" action="<?= $signupurl; ?>" method="post"> |
<div class="modal-body"> |
<?php if ($error) : ?> |
<div class="error_box"><?= $error; ?></div> |
<?php endif; ?> |
<input type="hidden" name="action" value="login" /> |
<input type="hidden" name="incomingurl" value="<?= $userpage; ?>" /> |
<input type="hidden" name="remember" value="0" /> |
<label class="login-label">WikiName</label> |
<input name="name" class="login-input" size="7" value="<?php if($user) : ?><?= htmlspecialchars($user) ?><?php endif; ?>" /> |
<div class="clear"></div> |
<label class="login-label">Password</label> |
<input type="password" name="password" class="login-input" size="7" /> |
<div class="clear"></div> |
<div class="login-label"> |
<input type="checkbox" id="remember-default" name="remember" value="1" /> |
<label for="remember-default" class="login-label-remember">Remember me</label> |
</div> |
</div> |
<div class="modal-footer"> |
<input type="submit" class="btn btn-primary login-button" value="Connection" /> |
</div> |
</form> |
</div> |
<?php endif; ?> |
Property changes: |
Added: svn:executable |
+* |
\ No newline at end of property |
/trunk/tools/login/presentation/templates/dropdown.tpl.html |
---|
New file |
0,0 → 1,37 |
<div class="btn-group"> |
<?php if ($connected) : ?> |
<button data-toggle="dropdown" class="btn dropdown-toggle<?php if ($btnclass!='') echo ' '.$btnclass; ?>"><i class="icon-user"></i> <?php echo $user; ?> <span class="caret"></span></button> |
<ul class="dropdown-menu"> |
<?php echo $PageMenuUser; ?> |
<li><a href="<?php echo $profileurl; ?>" title="<?php echo LOGIN_MODIFY_USER; ?>"><?php echo LOGIN_MODIFY_USER; ?></a></li> |
<li><a href="<?php echo $incomingurl; ?>&action=logout" class="login-signout-link" title="<?php echo LOGIN_LOGOUT; ?>"><?php echo LOGIN_LOGOUT; ?></a></li> |
</ul> |
<?php else : ?> |
<button data-toggle="dropdown" class="btn dropdown-toggle<?php if ($btnclass!='') echo ' '.$btnclass; ?>"><i class="icon-user"></i> <?php echo LOGIN_LOGIN; ?> <span class="caret"></span></button> |
<div class="dropdown-menu"> |
<form class="login-form" action="<?php echo $incomingurl; ?>" method="post"> |
<?php if ($signupurl != '' && $signupurl != '0') : ?><h5><?php echo LOGIN_ALREADY_MEMBER; ?></h5><?php endif; ?> |
<div class="controls"> |
<input id="inputWikiName" class="input-medium" required="required" placeholder="<?php echo LOGIN_WIKINAME; ?>" type="text" name="name" value="<?php if($user) echo htmlspecialchars($user); ?>" /> |
</div> |
<div class="controls"> |
<input id="inputPassword" class="input-medium" required="required" placeholder="<?php echo LOGIN_PASSWORD; ?>" name="password" type="password" /> |
</div> |
<div class="controls"> |
<label class="checkbox" for="remember-dropdown"> |
<input type="checkbox" id="remember-dropdown" name="remember" value="1" /><?php echo LOGIN_REMEMBER_ME; ?> |
</label> |
</div> |
<button type="submit" class="btn btn-block<?php if ($btnclass!='') echo ' '.$btnclass; ?>"><i class="icon-user"></i> <?php echo LOGIN_LOGIN; ?></button> |
<input type="hidden" name="action" value="login" /> |
<input type="hidden" name="incomingurl" value="<?php echo $userpage; ?>" /> |
<input type="hidden" name="remember" value="0" /> |
<?php if ($signupurl != '' && $signupurl != '0') : ?> |
<br /><br /> |
<h5><?php echo LOGIN_NEW_MEMBER; ?></h5> |
<a class="btn btn-block<?php if ($btnclass!='') echo ' '.$btnclass; ?>" href="<?php echo $signupurl; ?>"><i class="icon-plus"></i> <?php echo LOGIN_SIGNUP; ?></a> |
<?php endif; ?> |
</form> <!-- /.login-form --> |
</div> <!-- /.dropdown-menu --> |
<?php endif; ?> |
</div> <!-- /.btn-group --> |
Property changes: |
Added: svn:executable |
+* |
\ No newline at end of property |
/trunk/tools/login/presentation/templates/modal.tpl.html |
---|
New file |
0,0 → 1,64 |
<?php if ($connected) : ?> |
<a href="#LoginModal" role="button" class="btn dropdown-toggle<?php if ($btnclass!='') echo ' '.$btnclass; ?>" data-toggle="modal"> |
<i class="icon-user"></i> <?php echo $user; ?> |
</a> |
<div class="modal hide fade" id="LoginModal" tabindex="-1" role="dialog" aria-labelledby="LoginModalLabel" aria-hidden="true"> |
<div class="modal-header"> |
<button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button> |
<h3 id="LoginModalLabel"><?php echo LOGIN_CONNECTED_AS.' '.$user; ?></h3> |
</div> |
<div class="modal-body"> |
<ul class="login-actions"> |
<?php echo $PageMenuUser; ?> |
<li><a href="<?php echo $profileurl; ?>" title="<?php echo LOGIN_MODIFY_USER; ?>"><?php echo LOGIN_MODIFY_USER; ?></a></li> |
</ul> |
</div> |
<div class="modal-footer"> |
<a href="<?php echo $incomingurl; ?>&action=logout" class="btn btn-danger" title="<?php echo LOGIN_LOGOUT; ?>"><?php echo LOGIN_LOGOUT; ?></a> |
</div> |
</div> <!-- /#LoginModal--> |
<?php else : ?> |
<a href="#LoginModal" role="button" class="btn dropdown-toggle<?php if ($btnclass!='') echo ' '.$btnclass; ?>" data-toggle="modal"> |
<i class="icon-user"></i> <?php echo LOGIN_LOGIN; ?> |
</a> |
<div class="modal hide fade" id="LoginModal" tabindex="-1" role="dialog" aria-labelledby="LoginModalLabel" aria-hidden="true"> |
<div class="modal-header"> |
<button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button> |
<h3 id="LoginModalLabel"><?php echo LOGIN_LOGIN; ?></h3> |
</div> |
<div class="modal-body"> |
<form class="form-horizontal" action="<?php echo $incomingurl; ?>" method="post"> |
<div class="control-group"> |
<label for="inputWikiName" class="control-label"><?php echo LOGIN_WIKINAME; ?></label> |
<div class="controls"> |
<input id="inputWikiName" class="input-medium" required="required" placeholder="<?php echo LOGIN_WIKINAME; ?>" type="text" name="name" value="<?php if($user) echo htmlspecialchars($user); ?>" /> |
</div> |
</div> |
<div class="control-group"> |
<label for="inputPassword" class="control-label"><?php echo LOGIN_PASSWORD; ?></label> |
<div class="controls"> |
<input id="inputPassword" class="input-medium" required="required" placeholder="<?php echo LOGIN_PASSWORD; ?>" name="password" type="password" /> |
</div> |
</div> |
<div class="control-group"> |
<div class="controls"> |
<label class="checkbox" for="remember-modal"> |
<input type="checkbox" id="remember-modal" name="remember" value="1" /><?php echo LOGIN_REMEMBER_ME; ?> |
</label> |
</div> |
</div> |
<div class="control-group"> |
<div class="controls"> |
<button type="submit" class="btn <?php if ($btnclass!='') echo ' '.$btnclass; ?>"><i class="icon-user"></i> <?php echo LOGIN_LOGIN; ?></button> |
</div> |
</div> |
<input type="hidden" name="action" value="login" /> |
<input type="hidden" name="incomingurl" value="<?php echo $userpage; ?>" /> |
<input type="hidden" name="remember" value="0" /> |
</form> <!-- /.login-form --> |
</div> |
<div class="modal-footer"> |
<a class="btn <?php if ($btnclass!='') echo ' '.$btnclass; ?>" href="<?php echo $signupurl; ?>"><i class="icon-plus"></i> <?php echo LOGIN_SIGNUP; ?></a> |
</div> |
</div> <!-- /#LoginModal--> |
<?php endif; ?> |
Property changes: |
Added: svn:executable |
+* |
\ No newline at end of property |
/trunk/tools/login/desc.xml |
---|
New file |
0,0 → 1,6 |
<?xml version="1.0" encoding="ISO-8859-1"?> |
<plugin name="wklogin" version="0.1" active="1"> |
<author>Florian Schmitt</author> |
<label>Formulaire identification simple - OpenID</label> |
<desc>Formulaire identification simple (marche avec Wikini version >= 0.5) - avec possibilité d'utiliser OpenID</desc> |
</plugin> |
Property changes: |
Added: svn:executable |
+* |
\ No newline at end of property |
/trunk/tools/login/index.php |
---|
New file |
0,0 → 1,12 |
<?php |
// index.php |
// Administration de l'extension : initialisations (tables, fichier de configuration) , information etc. : toutes |
// opérations réservées à l'administrateur technique de Wikini. |
// Vérification de sécurité |
if (!defined("TOOLS_MANAGER")) |
{ |
die ("accès direct interdit"); |
} |
?> |
Property changes: |
Added: svn:executable |
+* |
\ No newline at end of property |
/trunk/tools/login/actions/login.php |
---|
New file |
0,0 → 1,192 |
<?php |
/* |
login.php |
Copyright 2010 Florian SCHMITT |
All rights reserved. |
Redistribution and use in source and binary forms, with or without |
modification, are permitted provided that the following conditions |
are met: |
1. Redistributions of source code must retain the above copyright |
notice, this list of conditions and the following disclaimer. |
2. Redistributions in binary form must reproduce the above copyright |
notice, this list of conditions and the following disclaimer in the |
documentation and/or other materials provided with the distribution. |
3. The name of the author may not be used to endorse or promote products |
derived from this software without specific prior written permission. |
THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR |
IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES |
OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. |
IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, |
INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT |
NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, |
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY |
THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF |
THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
*/ |
// Lecture des parametres de l'action |
// url d'inscription |
$signupurl = $this->GetParameter('signupurl'); |
// si pas de pas d'url d'inscription renseignée, on utilise ParametresUtilisateur |
if (empty($signupurl) && $signupurl != "0") { |
$signupurl = $this->href("", "ParametresUtilisateur", ""); |
} |
else { |
if ($this->IsWikiName($signupurl)) { |
$signupurl = $this->href('', $signupurl); |
} |
} |
// url du profil |
$profileurl = $this->GetParameter('profileurl'); |
$incomingurl = 'http'.((!empty($_SERVER['HTTPS']) && $_SERVER['HTTPS'] !== 'off' |
|| $_SERVER['SERVER_PORT'] == 443) ? 's' : '').'://'. |
(($_SERVER['SERVER_PORT']!='80') ? $_SERVER['HTTP_HOST'].':'.$_SERVER['SERVER_PORT'].$_SERVER['SCRIPT_NAME'] : |
$_SERVER['HTTP_HOST'].$_SERVER['SCRIPT_NAME']). |
(($_SERVER['QUERY_STRING']>' ') ? '?'.$_SERVER['QUERY_STRING'] : ''); |
$userpage = $this->GetParameter("userpage"); |
// si pas d'url de page de sortie renseignée, on retourne sur la page courante |
if (empty($userpage)) { |
$userpage = $incomingurl; |
// si l'url de sortie contient le passage de parametres de déconnexion, on l'efface |
if (isset($_REQUEST["action"]) && $_REQUEST["action"] == "logout") { |
$userpage = str_replace('&action=logout', '', $userpage); |
} |
} |
else { |
if ($this->IsWikiName($userpage)) { |
$userpage = $this->href('', $userpage); |
} |
} |
// classes css pour l'action et pour les boutons |
$class = $this->GetParameter("class"); |
$btnclass = $this->GetParameter("btnclass"); |
// template par défaut |
$template = $this->GetParameter("template"); |
if (empty($template) || !file_exists('tools/login/presentation/templates/'.$template) ) { |
$template = "default.tpl.html"; |
} |
$error = ''; |
$PageMenuUser = ''; |
// on initialise la valeur vide si elle n'existe pas |
if (!isset($_REQUEST["action"])) $_REQUEST["action"] = ''; |
// cas de la déconnexion |
if ($_REQUEST["action"] == "logout") { |
$this->LogoutUser(); |
if($this->config['use_sso']) { |
require_once('tools/login/libs/identificationsso.class.php'); |
$sso = new identificationSso($this); |
$sso->deconnecterUtilisateur(str_replace('&action=logout', '', $incomingurl)); |
} |
$this->SetMessage("Vous êtes maintenant déconnecté !"); |
$this->Redirect(str_replace('&action=logout', '', str_replace('&action=logout', '', $incomingurl))); |
exit; |
} |
// cas de l'identification |
if ($_REQUEST["action"] == "login") { |
// login sso |
if($this->config['use_sso']) { |
// identification.php analyse les cookies, header etc... afin de déterminer la présence d'un jeton |
require_once('tools/login/libs/identificationsso.class.php'); |
$sso = new identificationSso($this); |
$sso->connecterUtilisateur($_POST["name"], $_POST["password"], $_POST['incomingurl']); |
} else { |
// login normal |
// si l'utilisateur existe, on vérifie son mot de passe |
if (isset($_POST["name"]) && $existingUser = $this->LoadUser($_POST["name"])) { |
// si le mot de passe est bon, on créée le cookie et on redirige sur la bonne page |
if ($existingUser["password"] == md5($_POST["password"])) { |
$this->SetUser($existingUser, $_POST["remember"]); |
// si l'on veut utiliser la page d'accueil correspondant au nom d'utilisateur |
if ( $userpage=='user' && $this->LoadPage($_POST["name"]) ) { |
$this->Redirect($this->href('', $_POST["name"], '')); |
} |
// on va sur la page d'ou on s'est identifie sinon |
else { |
$this->Redirect($_POST['incomingurl']); |
} |
} |
// on affiche une erreur sur le mot de passe sinon |
else { |
$this->SetMessage("Identification impossible : mauvais mot de passe."); |
$this->Redirect($_POST['incomingurl']); |
} |
} |
// on affiche une erreur sur le NomWiki sinon |
else { |
$this->SetMessage("Identification impossible : NomWiki non reconnu."); |
$this->Redirect($_POST['incomingurl']); |
} |
} |
} |
if($this->config['use_sso']) { |
require_once('tools/login/libs/identificationsso.class.php'); |
$sso = new identificationSso($this); |
$sso->recupererIdentiteConnectee(); |
} |
// cas d'une personne connectée déjà |
if ($user = $this->GetUser()) { |
$connected = true; |
if ($this->LoadPage("PageMenuUser")) { |
$PageMenuUser .= $this->Format("{{include page=\"PageMenuUser\"}}"); |
} |
// si pas de pas d'url de profil renseignée, on utilise ParametresUtilisateur |
if (empty($profileurl)) { |
$profileurl = $this->href("", "ParametresUtilisateur", ""); |
} |
elseif ($profileurl=='WikiName') { |
$profileurl = $this->href("edit", $user['name'], ""); |
} |
else { |
if ($this->IsWikiName($profileurl)) { |
$profileurl = $this->href('', $profileurl); |
} |
} |
} |
// cas d'une personne non connectée |
else { |
$connected = false; |
// si l'authentification passe mais la session n'est pas créée, on a un problème de cookie |
if ($_REQUEST['action'] == 'checklogged') { |
$error = 'Vous devez accepter les cookies pour pouvoir vous connecter.'; |
} |
} |
// on affiche le template |
if (!class_exists('SquelettePhp')) include_once('tools/login/libs/squelettephp.class.php'); |
$squel = new SquelettePhp('tools/login/presentation/templates/'.$template); |
$squel->set(array( |
"connected" => $connected, |
"user" => ((isset($user["name"])) ? $user["name"] : ((isset($_POST["name"])) ? $_POST["name"] : '' )), |
"incomingurl" => $incomingurl, |
"signupurl" => $signupurl, |
"profileurl" => $profileurl, |
"userpage" => $userpage, |
"PageMenuUser" => $PageMenuUser, |
"btnclass" => $btnclass, |
"error" => $error |
)); |
$output = (!empty($class)) ? '<div class="'.$class.'">'."\n".$squel->analyser()."\n".'</div>'."\n" : $squel->analyser() ; |
echo $output; |
?> |
Property changes: |
Added: svn:executable |
+* |
\ No newline at end of property |
/trunk/tools/login/handlers/page/show__.php |
---|
New file |
0,0 → 1,18 |
<?php |
if (!defined("WIKINI_VERSION")) |
{ |
die ("accès direct interdit"); |
} |
//si une page PageLogin existe, on l'affiche |
if ($contenu = $this->LoadPage("PageLogin")) { |
$plugin_output_new = str_replace ("<i>Vous n'êtes pas autorisé à lire cette page</i>", $this->Format($contenu["body"]), $plugin_output_new); |
} |
//sinon on affiche le formulaire d'identification minimal |
else { |
$plugin_output_new = str_replace ("<i>Vous n'êtes pas autorisé à lire cette page</i>", |
'<div class="error_box">Vous n\'êtes pas autorisé à lire cette page, veuillez vous identifier.</div>'."\n".$this->Format('{{login template="minimal.tpl.html"}}'), $plugin_output_new); |
} |
?> |
Property changes: |
Added: svn:executable |
+* |
\ No newline at end of property |
/trunk/tools/login/lang/login_fr.inc.php |
---|
New file |
0,0 → 1,47 |
<?php |
/*vim: set expandtab tabstop=4 shiftwidth=4: */ |
// +------------------------------------------------------------------------------------------------------+ |
// | PHP version 5 | |
// +------------------------------------------------------------------------------------------------------+ |
// | Copyright (C) 2012 Outils-Réseaux (accueil@outils-reseaux.org) | |
// +------------------------------------------------------------------------------------------------------+ |
// | This library is free software; you can redistribute it and/or | |
// | modify it under the terms of the GNU Lesser General Public | |
// | License as published by the Free Software Foundation; either | |
// | version 2.1 of the License, or (at your option) any later version. | |
// | | |
// | This library is distributed in the hope that it will be useful, | |
// | but WITHOUT ANY WARRANTY; without even the implied warranty of | |
// | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | |
// | Lesser General Public License for more details. | |
// | | |
// | You should have received a copy of the GNU Lesser General Public | |
// | License along with this library; if not, write to the Free Software | |
// | Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA | |
// +------------------------------------------------------------------------------------------------------+ |
// |
/** |
* Fichier de traduction en francais de l'extension Login |
* |
*@package templates |
*@author Florian Schmitt <florian@outils-reseaux.org> |
*@copyright 2012 Outils-Réseaux |
*/ |
define ('LOGIN_SIGNUP', 'S\'inscrire'); |
define ('LOGIN_LOGIN', 'Se connecter'); |
if($wiki->config['use_sso']) { |
define ('LOGIN_WIKINAME', 'Courriel ou NomWiki'); |
} else { |
define ('LOGIN_WIKINAME', 'NomWiki'); |
} |
define ('LOGIN_PASSWORD', 'Mot de passe'); |
define ('LOGIN_MODIFY', 'Modifier'); |
define ('LOGIN_MODIFY_USER', 'Modifier mon inscription'); |
define ('LOGIN_REMEMBER_ME', 'Se souvenir de moi'); |
define ('LOGIN_LOGOUT', 'Déconnexion'); |
define ('LOGIN_NEW_MEMBER', 'Nouveau membre'); |
define ('LOGIN_ALREADY_MEMBER', 'Déjà membre'); |
define ('LOGIN_CONNECTED_AS', 'Connecté en tant que'); |
?> |
Property changes: |
Added: svn:executable |
+* |
\ No newline at end of property |