NAME
Aut::Backend::SQL - Authorization Framework for wxPerl - SQL Backend
SYNOPSIS
use Aut::Backend::SQL;
use Aut;
use Aut::Login;
use DBI;
use Lang::SQL;
use Lang;
package testApp;
use base 'Wx::App';
sub OnInit {
my $dbname="zclass";
my $host="localhost";
my $user="zclass";
my $pass="";
my $dsn="dbi:Pg:dbname=$dbname;host=$host";
Lang::init(new Lang::SQL("dbi:Pg:dbname=$dbname;host=$host",$user,$pass));
my $backend=Aut::Backend::SQL->new($dsn,$user,$pass);
my $auth=Aut->new($backend);
my $login=Aut::Login->new($auth,"test application");
my $ticket=$login->login();
$ticket->log();
$ticket=Aut::Ticket->new(ADMIN => 1);
$ticket->log();
$auth->create_account("admin","test",$ticket);
print "login with admin, pass=test\n";
$ticket=$login->login();
$ticket->log();
$login->Destroy;
return 0;
}
package main;
my $a= new testApp;
$a->MainLoop();
ABSTRACT
'Aut::Backend::SQL' is part of the authorization framework that can be used in conjunction with wxPerl. It provides the an SQL backend for storing and fetching accounts.
DESCRIPTION
new(DSN (see DBI),user,pass)
--> Aut::Backend::SQL
This method initializes the backend (see DBI for more details about perl and databases). This method creates a table auth_accounts
in the database mentioned in the DSN (if it does not exist).
store(account,pass,ticket)
--> void
This method stores an account, pass and ticket in the database. It uses Digest::MD5 to hash the password.
fetch(account)
--> (result, pass, ticket)
This method fetches an account from the database. If account exists in the database, pass (md5 string) and ticket are given back. The result will have value "ok"
.
If account cannot be found, result will be "!found"
. Pass will be ""
and ticket-
valid() --> false>.
If account is not uniq, a valid result will be returned, but result will have the value "!uniq"
.
number_of_accounts()
--> integer
This method returns the number of accounts in the database.
BUGS
This module has only been tested with PostgreSQL.
SEE ALSO
http://wxperl.sf.net, Lang framework, Aut framework, Aut::Login, Aut::Ticket.
AUTHOR
Hans Oesterholt-Dijkema <oesterhol@cpan.org>
COPYRIGHT AND LICENSE
This library is free software; you can redistribute it and/or modify it under LGPL terms.