NAME
WWW::MLite::AuthSsn - AAA mechanism support via sessions
VERSION
Version 1.00
SYNOPSIS
use WWW::MLite::AuthSsn;
my $ssn = new WWW::MLite::AuthSsn(
-dsn => "driver:sqlite",
-sid => ($q->param("SID") || $q->cookie("SID") || undef),
-key => "SID",
-expire => "+3M",
-args => { DataSource => '/my/folder/sessions.sqlt' },
);
# Authentication && Authorization
$ssn->authn or die("Bad authentication");
$ssn->authz or die("Bad authorization");
...
# Access/Accounting
$ssn->access or die("Access denied");
DESCRIPTION
Authorisation/Authentication/Access (AAA) mechanism support via sessions
METHODS
- new
-
my $ssn = new WWW::MLite::AuthSsn( -dsn => $dsn, # See CGI::Session -sid => $sid || undef), # Session IDentifier -key => "SID", # Key name -expire => "+3M", # Expires -args => { ... args ... }, # See CGI::Session );
Creating AuthSsn object
- init
-
$ssn->init;
Initialising the session. For internal use only. Please do not use it
Method returns status operation: 1 - successfully; 0 - not successfully
- update
-
$ssn->update;
Updating static data of the session. For internal use only. Please do not use it
- authen
-
$ssn->authen; $ssn->authen( $callback, ...arguments... );
AAA Authentication.
The method returns status operation: 1 - successfully; 0 - not successfully
- authz
-
$ssn->authz; $ssn->authz( $callback, ...arguments... );
AAA Authorization.
The method returns status operation: 1 - successfully; 0 - not successfully
- access
-
$ssn->access; $ssn->access( $callback, ...arguments... );
AAA Accounting (AAA Access).
The method returns status operation: 1 - successfully; 0 - not successfully
- get
-
$ssn->get( $key );
Returns user session value by $key
- set
-
$ssn->set( $key, $value );
Sets user session value by $key
- delete
-
$ssn->delete;
Delete the session
- sid, usid
-
$ssn->sid;
Returns current usid value
- expires
-
$ssn->expires;
Returns current expires value
- status
-
$ssn->status; $ssn->status( $newstatus );
Returns status of a previously executed operation. If you specify $newstatus, there will push installation $newstatus
- reason, reason_translate
-
$ssn->reason; $ssn->reason( $newreason ); $ssn->reason_translate;
Returns reason of a previously executed operation. If you specify $newreason, there will push installation $newreason
Now supported following values: DEFAULT, OK, UNAUTHORIZED, ERROR, SERVER_ERROR, NEW, TIMEOUT, LOGIN_INCORRECT, PASSWORD_INCORRECT, DECLINED, AUTH_REQUIRED, FORBIDDEN.
For translating this values to regular form please use method reason_translate like that
- error
-
$ssn->error(); $ssn->error( $newerror );
Returns error of a previously executed operation. If you specify $newerror, there will push installation $newerror
- toexpire
-
$ssn->toexpire( $time );
Returns expiration interval relative to ctime() form.
If used with no arguments, returns the expiration interval if it was ever set. If no expiration was ever set, returns undef.
All the time values should be given in the form of seconds. Following keywords are also supported for your convenience:
+-----------+---------------+ | alias | meaning | +-----------+---------------+ | s | Second | | m | Minute | | h | Hour | | d | Day | | w | Week | | M | Month | | y | Year | +-----------+---------------+
Examples:
$ssn->toexpire("2h"); # expires in two hours $ssn->toexpire(3600); # expires in one hour
Note: all the expiration times are relative to session's last access time, not to its creation time. To expire a session immediately, call delete() method.
- get_atime, get_ctime
-
$ssn->get_atime; $ssn->get_ctime;
Returns current atime and ctime values. Value atime - access time; ctime - create time
- get_data
-
$ssn->get_data;
Returns user data of current session as hash-ref
- get_expires
-
$ssn->get_expires;
Returns expiring interval of current session
CONFIGURATION
Sample in file conf/auth.conf:
<Auth>
expires +3m
#sidkey usid
</Auth>
EXAMPLES
- SQLite
-
my $dbh = DBI->connect("dbi:SQLite:dbname=/tmp/sessions.db", "","", { RaiseError => 1, sqlite_unicode => 1, }); $dbh->do('CREATE TABLE IF NOT EXISTS sessions ( id CHAR(32) NOT NULL PRIMARY KEY, a_session TEXT NOT NULL )'); my $ssn = new WWW::MLite::AuthSsn( -dsn => "driver:sqlite", -sid => ($q->param("SID") || $q->cookie("SID") || undef), -key => "SID", -expire => "+3M", -args => { Handle => $dbh }, );
HISTORY
See CHANGES
file
TO DO
See TODO
file
SEE ALSO
AUTHOR
Serz Minus (Lepenkov Sergey) http://www.serzik.com <minus@mail333.com>
COPYRIGHT
Copyright (C) 1998-2014 D&D Corporation. All Rights Reserved
LICENSE
This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
This program 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 General Public License for more details.
See LICENSE
file