NAME

Mojolicious::Plugin::BasicAuth - Basic HTTP Auth Helper

DESCRIPTION

Mojolicous::Plugin::BasicAuth is a helper for basic http authentication.

USAGE

Callback

use Mojolicious::Lite;

plugin 'basic_auth';

get '/' => sub {
	my $self = shift;

	my $callback = sub {
		my $username = shift || '';
		my $password = shift || '';
		return 1 $username eq 'username' and $password eq 'password';
	};

	return $self->render_text('denied') 
		unless $self->basic_auth( realm => $callback );

	$self->render_text('ok!');
};

app->start;

Alternate usage

return $self->render_text('denied')
	unless $self->basic_auth( realm => username => 'password' );

# 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

Mojolicious

DEVELOPMENT

http://github.com/tempire/mojolicious-plugin-basicauth

VERSION

0.032

AUTHOR

Glen Hinkle tempire@cpan.org