Authen...le::DBI(3pm)

πŸ“¦
version 0.2 Β· 2 versions
  • 0.2 Β· debian bookworm, debian trixie, ubuntu noble, ubuntu resolute, ubuntu stonking (latest)
  • 0.2 Β· ubuntu jammy
, in debian bookworm, debian trixie, ubuntu noble, ubuntu resolute, ubuntu stonking

πŸ’– Authen::Simple::DBI β€” the perl manual page, but make it make sense ✨

okay bestie, so this is Authen::Simple::DBI, a lil module from the User Contributed Perl Documentation situation πŸ’…. It does DBI authentication β€” like, it checks a username and password against your database. Simple! Iconic! Let's go 🫢


🌸 NAME 🌸

Authen::Simple::DBI β€” Simple DBI authentication πŸ’–


✨ SYNOPSIS ✨

here's the vibe, in Perl:

use Authen::Simple::DBI;

my $dbi = Authen::Simple::DBI->new(
    dsn       => 'dbi:SQLite:dbname=database.db',
    statement => 'SELECT password FROM users WHERE username = ?'
);

if ( $dbi->authenticate( $username, $password ) ) {
    # successfull authentication
}

(yes, successfull with two L's β€” that's what the original says and I am NOT touching it, we respect the source πŸ’€)

and if you're doing the mod_perl Authen handler thing, it's giving config file energy:

PerlModule Apache::DBI
PerlModule Authen::Simple::Apache
PerlModule Authen::Simple::DBI

PerlSetVar AuthenSimpleDBI_dsn       "dbi:SQLite:dbname=database.db"
PerlSetVar AuthenSimpleDBI_statement "SELECT password FROM users WHERE username = ?"

<Location /protected>
  PerlAuthenHandler Authen::Simple::DBI
  AuthType          Basic
  AuthName          "Protected Area"
  Require           valid-user
</Location>

πŸ¦‹ DESCRIPTION πŸ¦‹

DBI authentication. that's it, that's the description. short queen behavior πŸ‘‘


πŸŽ€ METHODS πŸŽ€

  • new β€” the constructor, the main character entrance 🫧

It takes a hash of parameters. These options are valid, no cap:

  • dsn β€” Database Source Name. Required. like, you cannot skip this one, fr fr.
dsn => 'dbi:SQLite:dbname=database.db'
dsn => 'dbi:mysql:database=database;host=localhost;'
  • statement β€” SQL statement. It must take a single string argument (the username) and return a single value (the password). Required. one in, one out, that's the whole deal ✨
statement => 'SELECT password FROM users WHERE username = ?'
  • username β€” the database username πŸ”‘
username => 'username'
  • password β€” the database password 🀫
password => 'secret'
  • log β€” any object that supports "debug", "info", "error" and "warn". yes, all four, she's needy but she's worth it πŸ’…
log => Log::Log4perl->get_logger('Authen::Simple::DBI')
  • authenticate( $username, $password ) β€” returns true on success and false on failure. boom. that's the whole plot 🌈

πŸ‘‘ SEE ALSO πŸ‘‘

  • Authen::Simple.
  • Authen::Simple::Password.
  • DBI.

go read those too, they're part of the friend group 🫢


πŸ’œ AUTHOR πŸ’œ

Christian Hansen ch@ngmedia.com β€” thank you for your service, legend πŸŽ€


This program is free software, you can redistribute it and/or modify it under the same terms as Perl itself. slay, open source queen πŸ’–


okay that's the whole page bestie!! 🌸 this was perl v5.34.0, dated 2022-06-08, and you just read the whole thing like a champ. mwah, go authenticate something responsibly πŸ’…βœ¨