Marquee Marquee::Plugin::AuthPretty - [EXPERIMENTAL] Pretty authentication form

TABLE OF CONTENTS

NAME

Marquee::Plugin::AuthPretty - [EXPERIMENTAL] Pretty authentication form

SYNOPSIS

$self->plugin(AuthPretty => [
    qr{^/admin/} => 'Secret Area' => sub {
        my ($username, $password) = @_;
        return $username eq 'user' &&  $password eq 'pass';
    },
    qr{^/admin/} => 'Secret Area2' => sub {
        my ($username, $password) = @_;
        return $username eq 'user' &&  $password eq 'pass';
    },
], 'path/to/storage_dir', 3600);

DESCRIPTION

This plugin wraps the whole dispatcher and requires authentication for specific paths with pretty viewed form.

ATTRIBUTES

Marquee::Plugin::AuthPretty inherits all attributes from Marquee::Plugin and implements the following new ones.

realm

Default value of realm which appears to response header. Each entry can override it. Defaults to 'Secret Area'.

$plugin->realm('My secret area');
my $realm = $plugin->realm;

INSTANCE METHODS

Marquee::Plugin::AuthPretty inherits all instance methods from Marquee::Plugin and implements the following new ones.

register

Register the plugin with path entries. $path_entries must be a list of regex, realm, auth callback groups. realm is optional.

$self->register($app, $path_entries);

EXAMPLE

You can port apache htpasswd entries as follows.

my $htpasswd = {
    user1 => 'znq.opIaiH.zs',
    user2 => 'dF45lPM2wMCDA',
};

$self->plugin(AuthPretty => [
    qr{^/admin/} => 'Secret Area' => sub {
        my ($username, $password) = @_;
        if (my $expect = $htpasswd->{$username}) {
            return crypt($password, $expect) eq $expect;
        }
    },
]);

SEE ALSO

Marquee, Mojolicious