root/trunk/wifidog-auth/wifidog/classes/Authenticator.php @ 708

Revision 708, 3.7 KB (checked in by benoitg, 8 years ago)

2005-09-01 Benoit Gr�goire <bock@…>

WARNING: DO NOT use the CVS auth server in production until further notice.
Massive internal changes are underway.
Use the release tagged 1.0m1 in production.

  • Network abstraction mostly complete, including UI. All that is missing is new network creation, network stakeholder UI and testing.
  • Cleanup the config file of all the now unneeded constants. Note that the install script is currently broken. There can now be multiple networks on the server. The install script will have to make sure that there is at least one, with one super-admin
  • Property svn:eol-style set to native
  • Property svn:executable set to *
  • Property svn:keywords set to Author Date Id Revision
Line 
1<?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>,
23 * Technologies Coeus inc.
24 */
25require_once 'AuthenticatorLocalUser.php';
26require_once 'AuthenticatorRadius.php';
27
28/** Abstract class to represent an authentication source */
29abstract class Authenticator
30{
31        private $mAccountOrigin;
32
33        function __construct($account_orgin)
34        {
35                $this->mAccountOrigin = $account_orgin;
36        }
37       
38        public function getAccountOrigin()
39        {
40                return $this->mAccountOrigin; 
41        }
42
43        /** Attempts to login a user against the authentication source.  If successfull, returns a User object */
44        function login()
45        {
46        }
47
48        /** Logs out the user */
49        function logout()
50        {
51        }
52
53        /** Start accounting traffic for the user */
54        function acctStart($info)
55        {
56                global $db;
57                $auth_response = $info['account_status'];
58                /* Login the user */
59                $mac = $db->EscapeString($_REQUEST['mac']);
60                $ip = $db->EscapeString($_REQUEST['ip']);
61                $sql = "UPDATE connections SET "."token_status='".TOKEN_INUSE."',"."user_mac='$mac',"."user_ip='$ip',"."last_updated=NOW()"."WHERE conn_id='{$info['conn_id']}';\n";
62                $db->ExecSqlUpdate($sql, false);
63
64                /* Logging in with a new token implies that all other active tokens should expire */
65                $token = $db->EscapeString($_REQUEST['token']);
66                $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";
67                $db->ExecSqlUpdate($sql, false);
68                /* Delete all unused tokens for this user, so we don't fill the database with them */
69                $sql = "DELETE FROM connections "."WHERE token_status='".TOKEN_UNUSED."' AND user_id = '{$info['user_id']}';\n";
70                $db->ExecSqlUpdate($sql, false);
71        }
72
73        /** Update traffic counters */
74        function acctUpdate($info, $incoming, $outgoing)
75        {
76                // Write traffic counters to database
77                global $db;
78                $db->ExecSqlUpdate("UPDATE connections SET "."incoming='$incoming',"."outgoing='$outgoing',"."last_updated=NOW() "."WHERE conn_id='{$info['conn_id']}'");
79        }
80
81        /** Final update and stop accounting */
82        function acctStop($info)
83        {
84                // Stop traffic counters update
85                global $db;
86                $db->ExecSqlUpdate("UPDATE connections SET "."timestamp_out=NOW(),"."token_status='".TOKEN_USED."' "."WHERE conn_id='{$info['conn_id']}';\n", false);
87        }
88       
89        /**
90         * Property method that tells if the class allows registration
91         */
92        function isRegistrationPermitted()
93        {
94                return false;
95        }
96
97} // End class
98?>
Note: See TracBrowser for help on using the browser.