(RADIATOR) Prepaid cards
Mike McCauley
mikem at open.com.au
Mon Jul 2 11:30:29 CDT 2001
A number of people have asked recently about prepaid card systems.
I have attached an example config file, showing how to implement a simple
prepaid card system using an SQL database.
This example will appear in goodies/prepaid.cfg in the next release.
# prepaid.cfg
#
# Example Radiator configuration file.
# This very simple file will allow you to get started with
# a simple prepaid system. You can then add and change features.
# We suggest you start simple, prove to yourself that it
# works and then develop a more complicated configuration.
#
# This example assumes you have an SQL database of prepaid cards.
# Each card has an row in the SUBSCRIBERS table something like this:
# create table SUBSCRIBERS (
# USERNAME char(50) NOT NULL,
# PASSWORD char(50), # Cleartext password
# TIMELEFT int # Seconds left
#);
#
# The database keeps track of the cards you have issued and the amount
# of prepaid time left on each card. Each time they log in, they get
# a Session-Timeout of the amount of time left (so they cant log on
# for more than the prepaid time). When they log out, the time
# left is reduced by the amount of time just used.
#
# You would populate this table with one row per prepaid card that you
# issue. The USERNAME would be the card number and the PASSWORD
# would be preset to the secret access code for the card
# You would initialise TIMELEFT to be the number of seconds
# of prepaid time on that card.
#
# If the customer 'tops-up' the card, your card managment application
# would increase the value of TIMELEFT.
#
# See radius.cfg for more complete examples of features and
# syntax, and refer to the reference manual for a complete description
# of all the features and syntax.
#
# You should consider this file to be a starting point only
# $Id: simple.cfg,v 1.4 2001/04/25 23:47:13 mikem Exp $
Foreground
LogStdout
LogDir .
DbDir .
# User a lower trace level in production systems:
Trace 4
# You will probably want to add other Clients to suit your site,
# one for each NAS you want to work with
<Client DEFAULT>
Secret mysecret
DupInterval 0
</Client>
<Realm DEFAULT>
<AuthBy SQL>
# Adjust DBSource, DBUsername, DBAuth to suit your DB
DBSource dbi:mysql:radius
DBUsername mikem
DBAuth fred
# Only one session per user at a time
DefaultSimultaneousUse 1
# Let the user in if they have any time left, set
# the Session-timeout to the time left
AuthSelect select PASSWORD, TIMELEFT from SUBSCRIBERS where USERNAME=%0
and TIMELEFT > 0
AuthColumnDef 0,User-Password,check
AuthColumnDef 1,Session-Timeout,reply
# Adjust the time left when they log out
AccountingStopsOnly
AcctSQLStatement update SUBSCRIBERS set
TIMELEFT=TIMELEFT-0%{Acct-Session-Time} where USERNAME='%n'
</AuthBy>
</Realm>
--
Mike McCauley mikem at open.com.au
Open System Consultants Pty. Ltd Unix, Perl, Motif, C++, WWW
24 Bateman St Hampton, VIC 3188 Australia http://www.open.com.au
Phone +61 3 9598-0985 Fax +61 3 9598-0955
Radiator: the most portable, flexible and configurable RADIUS server
anywhere. SQL, proxy, DBM, files, LDAP, NIS+, password, NT, Emerald,
Platypus, Freeside, TACACS+, PAM, external, Active Directory etc etc
on Unix, Win95/8, 2000, NT, MacOS 9, MacOS X
===
Archive at http://www.open.com.au/archives/radiator/
Announcements on radiator-announce at open.com.au
To unsubscribe, email 'majordomo at open.com.au' with
'unsubscribe radiator' in the body of the message.
More information about the radiator
mailing list