Auth/Provider.pm

filter: Statementstmt 62.5% 10 / 16 Branchbran 25.0% 1 / 4 Conditioncond 16.6% 1 / 6 MC/DCmcdc 0.0% 0 / 4 Subroutinesub 33.3% 2 / 6 Podpod 0.0% 0 / 5 totaltotal 34.1% 14 / 41 CC 5 SCAR 16.9
CC
5
Cov
46%
apply_timeout
12.0
log
3.7
validate_user
2.0
CRAP 5.4
« Auth/Provider/DBIx.pm ↑ Summary Auth.pm »
1 package Mojolicious::Plugin::Fondation::Auth::Provider;
2 2 $Mojolicious::Plugin::Fondation::Auth::Provider::VERSION = '0.04';
3 2 ▶use Mojo::Base -base, -signatures;
Subroutine BEGIN: called CC=1 SCAR=0.0
4  
5 2 has 'app';
6 2 has 'name'; # provider name (ex: 'file', 'dbix')
7 2 has 'timeout_sessions';
8  
9 # Methods that each concrete provider must implement
10 0 ▶sub validate_user { die "Method 'validate_user' must be implemented by provider" }
Subroutine validate_user: not called CC=1 SCAR=6.9
Pod undocumented
11 0 ▶sub load_user { die "Method 'load_user' must be implemented by provider" }
Subroutine load_user: not called CC=1 SCAR=6.9
Pod undocumented
12  
13 # Helper to log easily from any provider
14 # sub log ($self, $level, $message) {
15 # return unless $self->app && $self->app->can('log');
16 # $self->app->log->$level("Auth::Multi::$self->name: $message");
17 # }
18  
19 8 ▶sub log ($self) {
Subroutine log: called CC=3 SCAR=13.1
Pod undocumented
20 8 ▶ return unless $self->app && $self->app->can('log');
Branch: 1 branch
BranchTrueFalseTotal
unless $self->app and $self->app->can("log") 0 8 8
Condition33%1/3
$self->app and $self->app->can("log")
!ll&&!rl&&r
008
MC/DC0%0/2
$self->app and $self->app->can("log")
$self->app $self->app->can("log")
Truth table33%1/3
A and B
A= $self->appB= $self->app->can("log")
ABresult
0X0
100
111
21 8 $self->app->log;
22 }
23  
24 0 ▶sub apply_timeout ($self) {
Subroutine apply_timeout: not called CC=3 SCAR=24.8
Pod undocumented
25 0 ▶ return unless $self->timeout_sessions && $self->app;
Branch: 1 branch
BranchTrueFalseTotal
unless $self->timeout_sessions and $self->app 0 0 0
Condition0%0/3
$self->timeout_sessions and $self->app
!ll&&!rl&&r
000
MC/DC0%0/2
$self->timeout_sessions and $self->app
$self->timeout_sessions $self->app
Truth table0%0/3
A and B
A= $self->timeout_sessionsB= $self->app
ABresult
0X0
100
111
26 0 $self->app->sessions->default_expiration($self->timeout_sessions);
27 0 $self->log->info("Session timeout applied: $self->timeout_sessions seconds");
28 }
29  
30 0 ▶sub auth_form ($self) {
Subroutine auth_form: not called CC=1 SCAR=6.9
Pod undocumented
31 # Provides a minimal generic HTML form by default
32 0 return <<'HTML';
33 <form method="post">
34 <p>Login form not implemented for this provider</p>
35 </form>
36 HTML
37 }
38  
39 2 1;
40  
41 =pod
42  
43 =encoding UTF-8
44  
45 =head1 NAME
46  
47 Mojolicious::Plugin::Fondation::Auth::Provider
48  
49 =head1 VERSION
50  
51 version 0.04
52  
53 =head1 SYNOPSIS
54  
55 package Mojolicious::Plugin::Fondation::Auth::Provider::File;
56 use Mojo::Base 'Mojolicious::Plugin::Fondation::Auth::Provider', -signatures;
57  
58 # Then implement validate_user() and load_user()
59  
60 =head1 NAME
61  
62 Mojolicious::Plugin::Fondation::Auth::Provider - Base class for authentication providers
63  
64 =head1 AUTHOR
65  
66 Daniel Brosseau <dab@cpan.org>
67  
68 =head1 COPYRIGHT AND LICENSE
69  
70 This software is copyright (c) 2026 by Daniel Brosseau.
71  
72 This is free software; you can redistribute it and/or modify it under
73 the same terms as the Perl 5 programming language system itself.
74  
75 =cut
76  
77 __END__
« Auth/Provider/DBIx.pm ↑ Summary Auth.pm »