NAME

Auth::Login - Authorization Framework for wxPerl - SQL Backend

SYNOPSIS

use Auth::Backend::SQL;
use Auth;
use Auth::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=Auth::Backend::SQL->new($dsn,$user,$pass);
  my $auth=Auth->new($backend);

  my $login=Auth::Login->new($auth,"test application");

  my $ticket=$login->login();
  $ticket->log();

  $ticket=Auth::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

'Auth::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) --> Auth::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, Auth framework, Auth::Login, Auth::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.