NAME
Mojolicious::Plugin::BasicAuth - Basic HTTP Auth Helper
SYNOPSIS
## Simple usage ##
# Mojolicious
package MyApp;
sub startup {
my $self = shift;
$self->plugin('basic_auth');
...
}
package MyApp::Controller;
sub index {
my $self = shift;
return unless $self->helper( basic_auth => realm => username => 'password' );
$self->render_text( 'authenticated' );
}
# Mojolicious::Lite
plugin 'basic_auth'
get '/' => sub {
my $self = shift;
return unless $self->helper( basic_auth => realm => username => 'password' );
# Username is optional:
# $self->helper( basic_auth => realm => 'password' );
$self->render_text( 'authenticated' );
}
# or, for more wordy configuration:
get '/' => sub {
my $self = shift;
return unless
$self->helper( basic_auth => {
realm => 'realm',
username => 'username',
password => 'password'
} );
$self->render_text( 'authenticated' );
}
## Advanced usage ## Verify credentials within the controller with callback
get '/' => sub {
my $self = shift;
return unless $self->helper( basic_auth => realm => sub {
my ($username, $password) = @_;
return 1 if $username eq 'username' and $password eq 'password';
} );
$self->render_text( 'authenticated' );
};
DESCRIPTION
Mojolicous::Plugin::BasicAuth is a helper for basic http authentication.
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.01
AUTHOR
Glen Hinkle glen@empireenterprises.com