1NAME 2 Authen::Simple::DBI - Simple DBI authentication 3 4SYNOPSIS 5 use Authen::Simple::DBI; 6 7 my $dbi = Authen::Simple::DBI->new( 8 dsn => 'dbi:SQLite:dbname=database.db', 9 statement => 'SELECT password FROM users WHERE username = ?' 10 ); 11 12 if ( $dbi->authenticate( $username, $password ) ) { 13 # successfull authentication 14 } 15 16 # or as a mod_perl Authen handler 17 18 PerlModule Apache::DBI 19 PerlModule Authen::Simple::Apache 20 PerlModule Authen::Simple::DBI 21 22 PerlSetVar AuthenSimpleDBI_dsn "dbi:SQLite:dbname=database.db" 23 PerlSetVar AuthenSimpleDBI_statement "SELECT password FROM users WHERE username = ?" 24 25 <Location /protected> 26 PerlAuthenHandler Authen::Simple::DBI 27 AuthType Basic 28 AuthName "Protected Area" 29 Require valid-user 30 </Location> 31 32DESCRIPTION 33 DBI authentication. 34 35METHODS 36 * new 37 This method takes a hash of parameters. The following options are 38 valid: 39 40 * dsn Database Source Name. Required. 41 42 dsn => 'dbi:SQLite:dbname=database.db' 43 dsn => 'dbi:mysql:database=database;host=localhost;' 44 45 * statement 46 SQL statement. The statement must take a single string 47 argument (username) and return a single value (password). 48 Required. 49 50 statement => 'SELECT password FROM users WHERE username = ?' 51 52 * username 53 Database username. 54 55 username => 'username' 56 57 * password 58 Database password. 59 60 password => 'secret' 61 62 * log Any object that supports "debug", "info", "error" and 63 "warn". 64 65 log => Log::Log4perl->get_logger('Authen::Simple::DBI') 66 67 * authenticate( $username, $password ) 68 Returns true on success and false on failure. 69 70SEE ALSO 71 Authen::Simple. 72 73 Authen::Simple::Password. 74 75 DBI. 76 77AUTHOR 78 Christian Hansen "ch@ngmedia.com" 79 80COPYRIGHT 81 This program is free software, you can redistribute it and/or modify it 82 under the same terms as Perl itself. 83 84