This file is indexed.

/usr/share/perl5/Dancer/Plugin/Auth/Extensible/Provider/Example.pm is in libdancer-plugin-auth-extensible-perl 0.40-1.

This file is owned by root:root, with mode 0o644.

The actual contents of the file can be viewed below.

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
package Dancer::Plugin::Auth::Extensible::Provider::Example;

use strict;
use warnings;

use base "Dancer::Plugin::Auth::Extensible::Provider::Base";

# A more sensible provider would be likely to get this information from e.g. a
# database (or LDAP, or...) rather than hardcoding it.  This, however, is an
# example.
sub users {
    return {
        'dave' => {
            name     => 'David Precious',
            password => 'beer',
            roles    => [ qw(Motorcyclist BeerDrinker) ],
        },
        'bob' => {
            name     => 'Bob The Builder',
            password => 'canhefixit',
            roles    => [ qw(Fixer) ],
        },
    };
}

=head1 NAME 

Dancer::Plugin::Auth::Extensible::Example - example authentication provider


=head1 DESCRIPTION

This class is intended as an example of what an authentication provider class
should do.  It is not intended for serious use (clearly).

See L<Dancer::Plugin::Auth::Extensible> for details on how to use the
authentication framework, including how to pick a more useful authentication
provider.

However, if you just want to test the framework, or want an example to work from
to build your own authentication provider class, this may be of use.

=cut

=head1 Class methods

=over

=item authenticate_user

Given the username and password entered by the user, return true if they are
authenticated, or false if not.

=cut

sub authenticate_user {
    my ($self, $username, $password) = @_;
    my $user_details = $self->get_user_details($username) or return;
    return $self->match_password($password, $user_details->{password});
}

=item get_user_details

Given a username, return details about the user.  The details returned will vary
depending on the provider; some providers may be able to return various data
about the user, some may not, depending on the authentication source.

Details should be returned as a hashref.

=cut

sub get_user_details {
    my ($self, $username) = @_;

    return $self->users->{lc $username};
}

=item get_user_roles

Given a username, return a list of roles that user has.

=back

=cut

sub get_user_roles {
    my ($self, $username) = @_;

    my $user_details = $self->get_user_details($username) or return;
    return $user_details->{roles};
}



1;