Show
Ignore:
Timestamp:
03/29/05 17:13:28 (8 years ago)
Author:
fproulx
Message:

2005-03-28 Fran�ois Proulx <francois.proulx@…>

  • schema_validate.php : Modified schema : dropped e-mail + account unique index, dropped email not empty constraint
  • Schema is now at version 3
  • Coded RADIUS authentication
  • Modified templates to show a select box when more than one server is configured
  • Coded RADIUS accounting and backward compatibility accounting
  • Modified many statistics SQL queries to match new Users table
  • modified statistics templates to match user_id and account_origin
  • TODO : Fix lost_username and lost_password ( issue since we dropped the unique constraint on emails... )
  • TODO : Heavy testing possibly with remote RADIUS servers
Files:
1 modified

Legend:

Unmodified
Added
Removed
  • trunk/wifidog-auth/wifidog/classes/Authenticator.php

    r513 r516  
    11<?php 
    2   /********************************************************************\ 
    3    * This program is free software; you can redistribute it and/or    * 
    4    * modify it under the terms of the GNU General Public License as   * 
    5    * published by the Free Software Foundation; either version 2 of   * 
    6    * the License, or (at your option) any later version.              * 
    7    *                                                                  * 
    8    * This program is distributed in the hope that it will be useful,  * 
    9    * but WITHOUT ANY WARRANTY; without even the implied warranty of   * 
    10    * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the    * 
    11    * GNU General Public License for more details.                     * 
    12    *                                                                  * 
    13    * You should have received a copy of the GNU General Public License* 
    14    * along with this program; if not, contact:                        * 
    15    *                                                                  * 
    16    * Free Software Foundation           Voice:  +1-617-542-5942       * 
    17    * 59 Temple Place - Suite 330        Fax:    +1-617-542-2652       * 
    18    * Boston, MA  02111-1307,  USA       gnu@gnu.org                   * 
    19    *                                                                  * 
    20    \********************************************************************/ 
    21   /**@file Authenticator.php 
    22    * @author Copyright (C) 2005 Benoit Gr�goire <bock@step.polymtl.ca>, Technologies Coeus inc. 
    23    */ 
     2 
     3 
     4/********************************************************************\ 
     5 * This program is free software; you can redistribute it and/or    * 
     6 * modify it under the terms of the GNU General Public License as   * 
     7 * published by the Free Software Foundation; either version 2 of   * 
     8 * the License, or (at your option) any later version.              * 
     9 *                                                                  * 
     10 * This program is distributed in the hope that it will be useful,  * 
     11 * but WITHOUT ANY WARRANTY; without even the implied warranty of   * 
     12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the    * 
     13 * GNU General Public License for more details.                     * 
     14 *                                                                  * 
     15 * You should have received a copy of the GNU General Public License* 
     16 * along with this program; if not, contact:                        * 
     17 *                                                                  * 
     18 * Free Software Foundation           Voice:  +1-617-542-5942       * 
     19 * 59 Temple Place - Suite 330        Fax:    +1-617-542-2652       * 
     20 * Boston, MA  02111-1307,  USA       gnu@gnu.org                   * 
     21 *                                                                  * 
     22 \********************************************************************/ 
     23/**@file Authenticator.php 
     24 * @author Copyright (C) 2005 Benoit Gr�goire <bock@step.polymtl.ca>, 
     25 * Technologies Coeus inc. 
     26 */ 
    2427 
    2528/** Abstract class to represent an authentication source */ 
    26 abstract class Authenticator { 
    27 private mAccountOrigin; 
     29abstract class Authenticator 
     30{ 
     31        protected $mAccountOrigin; 
    2832 
    29  function __construct($account_orgin) 
    30  { 
    31    $this->mAccountOrigin=$account_orgin; 
    32  } 
    33   
    34 /** Attempts to login a user against the authentication source.  If successfull, returns a User object */ 
    35   function login() 
    36   { 
    37   } 
     33        function __construct($account_orgin) 
     34        { 
     35                $this->mAccountOrigin = $account_orgin; 
     36        } 
    3837 
    39 /** Logs out the user */ 
    40   function logout() 
    41   { 
    42   } 
     38        /** Attempts to login a user against the authentication source.  If successfull, returns a User object */ 
     39        function login() 
     40        { 
     41        } 
    4342 
    44 /** Start accounting traffic for the user */ 
    45   function acctStart() 
    46   { 
    47   } 
     43        /** Logs out the user */ 
     44        function logout() 
     45        { 
     46        } 
    4847 
    49 /** Update traffic counters */ 
    50   function acctUpdate() 
    51   { 
    52   } 
     48        /** Start accounting traffic for the user */ 
     49        function acctStart($info) 
     50        { 
     51                global $db; 
     52                $auth_response = $info['account_status']; 
     53                /* Login the user */ 
     54                $mac = $db->EscapeString($_REQUEST['mac']); 
     55                $ip = $db->EscapeString($_REQUEST['ip']); 
     56                $sql = "UPDATE connections SET "."token_status='".TOKEN_INUSE."',"."user_mac='$mac',"."user_ip='$ip',"."last_updated=NOW()"."WHERE conn_id='{$info['conn_id']}';\n"; 
     57                $db->ExecSqlUpdate($sql, false); 
    5358 
    54 /** Final update and stop accounting */ 
    55   function acctStop() 
    56   { 
    57   } 
     59                /* Logging in with a new token implies that all other active tokens should expire */ 
     60                $token = $db->EscapeString($_REQUEST['token']); 
     61                $sql = "UPDATE connections SET "."timestamp_out=NOW(), token_status='".TOKEN_USED."' "."WHERE user_id = '{$info['user_id']}' AND token_status='".TOKEN_INUSE."' AND token!='$token';\n"; 
     62                $db->ExecSqlUpdate($sql, false); 
     63                /* Delete all unused tokens for this user, so we don't fill the database with them */ 
     64                $sql = "DELETE FROM connections "."WHERE token_status='".TOKEN_UNUSED."' AND user_id = '{$info['user_id']}';\n"; 
     65                $db->ExecSqlUpdate($sql, false); 
     66        } 
    5867 
    59 }// End class 
     68        /** Update traffic counters */ 
     69        function acctUpdate($info, $incoming, $outgoing) 
     70        { 
     71                // Write traffic counters to database 
     72                global $db; 
     73                $db->ExecSqlUpdate("UPDATE connections SET "."incoming='$incoming',"."outgoing='$outgoing',"."last_updated=NOW() "."WHERE conn_id='{$info['conn_id']}'"); 
     74        } 
     75 
     76        /** Final update and stop accounting */ 
     77        function acctStop($info) 
     78        { 
     79                // Stop traffic counters update 
     80                global $db; 
     81                $db->ExecSqlUpdate("UPDATE connections SET "."timestamp_out=NOW(),"."token_status='".TOKEN_USED."' "."WHERE conn_id='{$info['conn_id']}';\n"); 
     82        } 
     83 
     84} // End class 
    6085?> 
     86 
     87