MOD #138 : Stockage des passwords hashés
authorGreg Burri <greg.burri@gmail.com>
Mon, 21 Sep 2009 12:39:30 +0000 (14:39 +0200)
committerGreg Burri <greg.burri@gmail.com>
Mon, 21 Sep 2009 12:39:30 +0000 (14:39 +0200)
index.php
php/controller.php
php/pages/bienvenue.php
php/panel.php
php/participant.php
php/update_db.php

index e41a32e..eb24013 100644 (file)
--- a/index.php
+++ b/index.php
@@ -28,7 +28,7 @@ $panel = new Panel($participant);
 
 if ($controller->nouvel_inscrit)
    $page = "bienvenue";
-   
+
 echo '<?xml version="1.0" encoding="UTF-8"?>';
 
 ?>
index f3fd468..cad4352 100644 (file)
@@ -48,7 +48,7 @@ class Controller
                array(
                   $id,
                   $_POST['pseudo'],
-                  $_POST['pass1'],
+                  sha1($_POST['pass1']),
                   $_POST['clan_nom'],
                   $_POST['clan_tag'],
                   $_POST['nom'],
@@ -78,7 +78,7 @@ class Controller
          {
             pg_query("BEGIN");
             pg_query_params("UPDATE participants SET pseudo = $1 WHERE id = $2", array($_POST['pseudo'], $this->participant->info->id));
-            pg_query_params("UPDATE participants SET password = $1 WHERE id = $2", array($_POST['pass1'], $this->participant->info->id));
+            pg_query_params("UPDATE participants SET password = $1 WHERE id = $2", array(sha1($_POST['pass1']), $this->participant->info->id));
             pg_query_params("UPDATE participants SET clan_nom = $1 WHERE id = $2", array($_POST['clan_nom'], $this->participant->info->id));
             pg_query_params("UPDATE participants SET clan_tag = $1 WHERE id = $2", array($_POST['clan_tag'], $this->participant->info->id));
             pg_query_params("UPDATE participants SET nom = $1 WHERE id = $2", array($_POST['nom'], $this->participant->info->id));
index b808985..7e14f00 100644 (file)
@@ -1,7 +1,7 @@
 <?php # coding: utf-8 ?>
 
 <p><em>Toute l'équipe de la Corcelles-LAN vous souhaite la bienvenue !!</em></p>
-<p>Votre inscription a été enregistré, voici quelques liens utiles :
+<p>Votre inscription a été enregistrée, voici quelques liens utiles :
 <ul>
    <li><a href="inscription.html">Modification des informations personnelles</a></li>
    <li><a href="jeux_joues.html">Voter pour un ou plusieurs jeux</a></li>
index 54b1b53..d07bb6c 100644 (file)
@@ -55,7 +55,7 @@ class Panel
          <p>login / pass</p>
          <p><input type="hidden" name="log" value="1" /></p>
          <p><input type="text" name="pseudo" size="10" maxlength="30" /></p>
-         <p><input type="password" name="password" size="10" maxlength="10" /></p>
+         <p><input type="password" name="password" size="10" maxlength="15" /></p>
          <p><input type="submit" value="oki" class="submitInvisible" /></p>
          </form>
          ';
index ef92a06..e2b47be 100644 (file)
@@ -16,6 +16,7 @@ class Participant
      * 1) $v1 = NULL, $v2 = NULL : participant non-valide
      * 2) $v1 = id, $v2 = NULL : la participant existe et est chargé à partir de son id
      * 3) $v1 = pseudo, $v2 = password : le participant existe et est chargé à partir de son pseudo et de son password
+     * Le mot de passe est donné en clair.
      */
    public function Participant($v1=NULL, $v2=NULL)
    {      
@@ -25,7 +26,7 @@ class Participant
 
                if (is_string($v1) && is_string($v2)) # Aucun des arguments n'est vide alors c'est le pseudo et le password qui ont été transmis
       {
-                       $res = pg_query_params("SELECT id FROM participants WHERE pseudo = $1 AND password = $2", array($v1, $v2));
+                       $res = pg_query_params("SELECT id FROM participants WHERE pseudo = $1 AND password = $2", array($v1, sha1($v2)));
       }
                else # Sinon c'est l'id
                        $res = pg_query_params("SELECT id FROM participants WHERE id = $1", array($v1));
index be2c041..a2d9ffe 100644 (file)
@@ -34,13 +34,14 @@ function creer_db()
         UNIQUE (nom)
       );
    ");
+   // participants.password est un hash calculé à l'aide de sha1().
    pg_query("
       CREATE TABLE participants (
         id int NOT NULL,
         pseudo varchar(50) DEFAULT NULL,
         clan_nom varchar(30) DEFAULT NULL,
         clan_tag varchar(10) DEFAULT NULL,
-        password varchar(10) DEFAULT NULL,
+        password char(40) DEFAULT NULL,
         nom varchar(30) DEFAULT NULL,
         prenom varchar(30) DEFAULT NULL,
         age varchar(30) DEFAULT NULL,