NAME
Mojolicious::Plugin::BasicAuth - Basic HTTP Auth Helper
DESCRIPTION
Mojolicous::Plugin::BasicAuth is a helper for basic http authentication.
Note This version (0.03) is for Mojolicious versions 0.999930 and above; please use version 0.02 with older versions of Mojolicious.
USAGE
Callback
use Mojolicious::Lite;
plugin 'basic_auth';
get '/' => sub {
my $self = shift;
my $callback = sub {
return 1
if $_[0] eq 'username'
and $_[1] eq 'password';
};
$self->render_text('denied')
if ! $self->basic_auth( realm => $callback );
$self->render_text('ok!');
};
app->start;
Alternate usage
$self->render_text('denied')
unless $self->basic_auth( realm => user => 'pass' );
# Username is optional:
# $self->basic_auth( realm => 'password' );
METHODS
Mojolicious::Plugin::BasicAuth inherits all methods from Mojolicious::Plugin and implements the following new ones.
register
$plugin->register;
Register condition in Mojolicious application.
SEE ALSO
DEVELOPMENT
http://github.com/tempire/mojolicious-plugin-basicauth
VERSION
0.03
AUTHOR
Glen Hinkle tempire@cpan.org