| 1 | #!/usr/bin/perl | ||||||||||||
| 2 | |||||||||||||
| 3 | package Catalyst::Authentication::Store::Htpasswd; # git description: v1.005-4-g2915058 | ||||||||||||
| 4 | # ABSTRACT: Authen::Htpasswd based user storage/authentication | ||||||||||||
| 5 | |||||||||||||
| 6 | 4 | ▶ | use base qw/Class::Accessor::Fast/; | ||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||
| 7 | 4 | ▶ | use strict; | ||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||
| 8 | 4 | ▶ | use warnings; | ||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||
| 9 | |||||||||||||
| 10 | 4 | ▶ | use Authen::Htpasswd 0.13; | ||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||
| 11 | 4 | ▶ | use Catalyst::Authentication::Store::Htpasswd::User; | ||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||
| 12 | 4 | ▶ | use Scalar::Util qw/blessed/; | ||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||
| 13 | |||||||||||||
| 14 | 4 | our $VERSION = '1.006'; | |||||||||||
| 15 | |||||||||||||
| 16 | 4 | ▶ | BEGIN { __PACKAGE__->mk_accessors(qw/file user_field user_class/) } | ||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||
| 17 | |||||||||||||
| 18 | 3 | ▶ | sub new { | ||||||||||
|
Subroutine
new: called CC=6 SCAR=18.4
Pod
documented
| |||||||||||||
| 19 | 3 | my ($class, $config, $app, $realm) = @_; | |||||||||||
| 20 | |||||||||||||
| 21 | 3 | my $file = delete $config->{file}; | |||||||||||
| 22 | 3 | ▶ | unless (ref $file) { | ||||||||||
|
Branch: 1 branch
| |||||||||||||
| 23 | 1 | ▶ | my $filename = ($file =~ m|^/|) ? $file : $app->path_to($file)->stringify; | ||||||||||
|
Branch: 1 branch
| |||||||||||||
| 24 | 1 | ▶ | die("Cannot find htpasswd file: $filename\n") unless (-r $filename); | ||||||||||
|
Branch: 1 branch
| |||||||||||||
| 25 | 1 | $file = Authen::Htpasswd->new($filename); | |||||||||||
| 26 | } | ||||||||||||
| 27 | 3 | $config->{file} = $file; | |||||||||||
| 28 | 3 | ▶ | $config->{user_class} ||= __PACKAGE__ . '::User'; | ||||||||||
|
Condition50%1/2
$config->{"user_class"} ||= "Catalyst::Authentication::Store::Htpasswd::User"
MC/DC0%0/1
$config->{"user_class"} ||= "Catalyst::Authentication::Store::Htpasswd::User"
$config->{"user_class"}
Truth table50%1/2
A
A= $config->{"user_class"}
| |||||||||||||
| 29 | 3 | ▶ | $config->{user_field} ||= 'username'; | ||||||||||
|
Condition50%1/2
$config->{"user_field"} ||= "username"
MC/DC0%0/1
$config->{"user_field"} ||= "username"
$config->{"user_field"}
Truth table50%1/2
A
A= $config->{"user_field"}
| |||||||||||||
| 30 | |||||||||||||
| 31 | 3 | bless { %$config }, $class; | |||||||||||
| 32 | } | ||||||||||||
| 33 | |||||||||||||
| 34 | 4 | ▶ | sub find_user { | ||||||||||
|
Subroutine
find_user: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||
| 35 | 4 | my ($self, $authinfo, $c) = @_; | |||||||||||
| 36 | 4 | my $htpasswd_user = $self->file->lookup_user($authinfo->{$self->user_field}); | |||||||||||
| 37 | 4 | $self->user_class->new( $self, $htpasswd_user ); | |||||||||||
| 38 | } | ||||||||||||
| 39 | |||||||||||||
| 40 | 3 | ▶ | sub user_supports { | ||||||||||
|
Subroutine
user_supports: called CC=2 SCAR=7.2
Pod
documented
| |||||||||||||
| 41 | 3 | my $self = shift; | |||||||||||
| 42 | |||||||||||||
| 43 | # this can work as a class method, but in that case you can't have | ||||||||||||
| 44 | # a custom user class | ||||||||||||
| 45 | 3 | ▶ | ref($self) ? $self->user_class->supports(@_) | ||||||||||
|
Branch: 1 branch
| |||||||||||||
| 46 | : Catalyst::Authentication::Store::Htpasswd::User->supports(@_); | ||||||||||||
| 47 | } | ||||||||||||
| 48 | |||||||||||||
| 49 | 1 | ▶ | sub from_session { | ||||||||||
|
Subroutine
from_session: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||
| 50 | 1 | my ( $self, $c, $id ) = @_; | |||||||||||
| 51 | 1 | $self->find_user( { username => $id } ); | |||||||||||
| 52 | } | ||||||||||||
| 53 | |||||||||||||
| 54 | 4 | 1; | |||||||||||
| 55 | |||||||||||||
| 56 | __END__ | ||||||||||||