Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Basic http authentication plugin for mojolicious
Perl
Branch: master
Pull request Compare This branch is 1 commit ahead, 5 commits behind tempire:master.

Fetching latest commit…

Cannot retrieve the latest commit at this time

Failed to load latest commit information.
lib/Mojolicious/Plugin
t
Changes
Mojolicious-Plugin-BasicAuth-0.06.tar.gz
README.pod
dist.ini

README.pod

NAME

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

DESCRIPTION

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

USAGE

    use Mojolicious::Lite;

    plugin 'basic_auth';

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

        return $self->render_text('ok')
          if $self->basic_auth(
                  realm => sub { return 1 if "@_" eq 'username password' }
          );
    };

    app->start;

Example of authed index page with Mojolicious

    # MyApp.pm
    use Mojo::Base 'Mojolicious';
    sub startup {
        my $self = shift;
        $self->plugin('basic_auth');

        my $r = $self->routes;

        # a means authentication required routes
        $a = $r->bridge('/')->to('Root#auth');

        $a->get('/')->to('Root#auth');
    }

    # MyApp/Root.pm
    use Mojo::Base 'Mojolicious::Controller';

    sub auth {
        my $self = shift;

        return 1 if $self->basic_auth(
                realm => sub {
                    return 1 if "@_" eq 'username password'
                }
            );
    }

    sub index {
        my $self = shift;

        $self->render('hello world');
    }

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.06

CREDITS

Kirill Miazine

AUTHOR

Glen Hinkle <tempire@cpan.org>

Something went wrong with that request. Please try again.