File Coverage

blib/lib/Concierge/Auth/Base.pm
Criterion Covered Total %
statement 19 25 76.0
branch n/a
condition n/a
subroutine 9 15 60.0
pod 13 13 100.0
total 41 53 77.3


line stmt bran cond sub pod time code
1             package Concierge::Auth::Base v0.5.0;
2 6     6   2677 use v5.36;
  6         19  
3              
4             # ABSTRACT: Base class / contract for Concierge::Auth backends
5              
6 6     6   2048 use Concierge::Auth::Generators ();
  6         20  
  6         1114  
7              
8             # Define interface methods that must be implemented by subclasses:
9             # Concierge::Auth::MyBackend->new(%args);
10 0     0 1 0 sub new { die "Subclass must implement new" }
11              
12             # $backend->authenticate($user_id, $credential);
13 0     0 1 0 sub authenticate { die "Subclass must implement authenticate" }
14              
15             # $backend->is_id_known($user_id);
16 0     0 1 0 sub is_id_known { die "Subclass must implement is_id_known" }
17              
18             # $backend->enroll($user_id, $credential, \%opts);
19 0     0 1 0 sub enroll { die "Subclass must implement enroll" }
20              
21             # $backend->change_credentials($user_id, $new_credential);
22 0     0 1 0 sub change_credentials { die "Subclass must implement change_credentials" }
23              
24             # $backend->revoke($user_id);
25 0     0 1 0 sub revoke { die "Subclass must implement revoke" }
26              
27             # Generator methods -- default implementations delegate to the plain
28             # functions in Concierge::Auth::Generators, preserving its wantarray
29             # (value)/(value, message) dual-return convention. Unlike the five
30             # methods above, these are NOT required overrides: a backend that has
31             # no reason to customize ID/token generation gets a working
32             # implementation for free. Any backend may still override one or more
33             # of these with its own logic (e.g. an LDAP backend deferring ID
34             # generation to the directory).
35 1     1 1 263 sub gen_uuid { my $self = shift; return Concierge::Auth::Generators::gen_uuid(@_); }
  1         3  
36 2     2 1 2345 sub gen_random_id { my $self = shift; return Concierge::Auth::Generators::gen_random_id(@_); }
  2         5  
37 1     1 1 1555 sub gen_random_token { my $self = shift; return Concierge::Auth::Generators::gen_random_token(@_); }
  1         3  
38 1     1 1 1473 sub gen_random_string { my $self = shift; return Concierge::Auth::Generators::gen_random_string(@_); }
  1         3  
39 2     2 1 3316 sub gen_word_phrase { my $self = shift; return Concierge::Auth::Generators::gen_word_phrase(@_); }
  2         7  
40             # Does NOT call the original deprecated methods; calls their replacements
41             # But these are still considered deprecated method names
42 1     1 1 1527 sub gen_token { my $self = shift; return Concierge::Auth::Generators::gen_random_token(@_); }
  1         4  
43 1     1 1 1523 sub gen_crypt_token { my $self = shift; return Concierge::Auth::Generators::gen_random_token(@_); }
  1         4  
44              
45             1;
46              
47             __END__