WWW::MLite::AuthSsn - AAA mechanism support via sessions
Version 1.00
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");
Authorisation/Authentication/Access (AAA) mechanism support via sessions
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
$ssn->init;
Initialising the session. For internal use only. Please do not use it
Method returns status operation: 1 - successfully; 0 - not successfully
$ssn->update;
Updating static data of the session. For internal use only. Please do not use it
$ssn->authen; $ssn->authen( $callback, ...arguments... );
AAA Authentication.
The method returns status operation: 1 - successfully; 0 - not successfully
$ssn->authz; $ssn->authz( $callback, ...arguments... );
AAA Authorization.
$ssn->access; $ssn->access( $callback, ...arguments... );
AAA Accounting (AAA Access).
$ssn->get( $key );
Returns user session value by $key
$ssn->set( $key, $value );
Sets user session value by $key
$ssn->delete;
Delete the session
$ssn->sid;
Returns current usid value
$ssn->expires;
Returns current expires value
$ssn->status; $ssn->status( $newstatus );
Returns status of a previously executed operation. If you specify $newstatus, there will push installation $newstatus
$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
$ssn->error(); $ssn->error( $newerror );
Returns error of a previously executed operation. If you specify $newerror, there will push installation $newerror
$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.
$ssn->get_atime; $ssn->get_ctime;
Returns current atime and ctime values. Value atime - access time; ctime - create time
$ssn->get_data;
Returns user data of current session as hash-ref
$ssn->get_expires;
Returns expiring interval of current session
Sample in file conf/auth.conf:
<Auth> expires +3m #sidkey usid </Auth>
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 }, );
See CGI::Session::Driver::sqlite
See CHANGES file
CHANGES
See TODO file
TODO
WWW::MLite, CGI::Session
Serz Minus (Lepenkov Sergey) http://www.serzik.com <minus@mail333.com>
Copyright (C) 1998-2014 D&D Corporation. All Rights Reserved
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
LICENSE
To install WWW::MLite, copy and paste the appropriate command in to your terminal.
cpanm
cpanm WWW::MLite
CPAN shell
perl -MCPAN -e shell install WWW::MLite
For more information on module installation, please visit the detailed CPAN module installation guide.