Lite/Provider/Handler/CheckAuth.pm

filter: Statementstmt 50.7% 32 / 63 Branchbran 0.0% 0 / 12 Conditioncond 0.0% 0 / 8 MC/DCmcdc 0.0% 0 / 5 Subroutinesub 69.2% 9 / 13 Podpod 0.0% 0 / 1 totaltotal 40.2% 41 / 102 CC 10 SCAR 36.4
CC
10
Cov
39%
handle_request
90.0
_build_error
6.0
__ANON__
2.0
CRAP 38.0
« Lite/RelyingParty/Discover/Service/Builder.pm ↑ Summary Lite/RelyingParty/Discover/Parser/XRI.pm »
1 package OpenID::Lite::Provider::Handler::CheckAuth;
2  
3 1 ▶use Any::Moose;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 1 ▶use OpenID::Lite::SignatureMethods;
Subroutine BEGIN: called CC=1 SCAR=0.0
5 1 ▶use OpenID::Lite::Message;
Subroutine BEGIN: called CC=1 SCAR=0.0
6 1 ▶use OpenID::Lite::Nonce;
Subroutine BEGIN: called CC=1 SCAR=0.0
7 1 ▶use OpenID::Lite::Provider::Response;
Subroutine BEGIN: called CC=1 SCAR=0.0
8 1 ▶use OpenID::Lite::Constants::ProviderResponseType qw(:all);
Subroutine BEGIN: called CC=1 SCAR=0.0
9 1 ▶use OpenID::Lite::Constants::ModeType qw(ID_RES);
Subroutine BEGIN: called CC=1 SCAR=0.0
10 1 ▶use OpenID::Lite::Constants::Namespace qw(:all);
Subroutine BEGIN: called CC=1 SCAR=0.0
11 1 with 'OpenID::Lite::Role::ErrorHandler';
12  
13 has 'check_nonce' => (
14 is => 'ro',
15 isa => 'CodeRef',
16 0 ▶ default => sub {
Subroutine __ANON__: not called CC=1 SCAR=6.9
17 0 ▶ sub { return 1; }
Subroutine __ANON__: not called CC=1 SCAR=6.9
18 0 }
19 1 );
20  
21 1 has 'assoc_builder' => (
22 is => 'ro',
23 isa => 'OpenID::Lite::Provider::AssociationBuilder',
24 );
25  
26 0 ▶sub handle_request {
Subroutine handle_request: not called CC=9 SCAR=45.0
Pod undocumented
27 0 my ( $self, $req_params ) = @_;
28  
29 0 my $copied = $req_params->copy();
30 0 $copied->set( mode => ID_RES );
31  
32 0 my $ns = $copied->get('ns');
33  
34 0 my $assoc_handle = $copied->get('assoc_handle');
35 0 ▶ return $self->_build_error( $req_params,
Branch: 1 branch
BranchTrueFalseTotal
unless $assoc_handle 0 0 0
36 q{Missing parameter, "assoc_handle".}, $ns )
37 unless $assoc_handle;
38  
39 0 my $sig = $copied->get('sig');
40 0 ▶ return $self->_build_error( $req_params, q{Missing parameter, "sig".}, $ns)
Branch: 1 branch
BranchTrueFalseTotal
unless $sig 0 0 0
41 unless $sig;
42  
43 0 my $is_valid = q{false};
44 0 my $assoc = $self->assoc_builder->build_from_handle(
45 $assoc_handle => { dumb => 1, } );
46 0 ▶ if ( $assoc && !$assoc->is_expired ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($assoc and not $assoc->is_expired) 0 0 0
Condition0%0/3
$assoc and not $assoc->is_expired
!ll&&!rl&&r
000
MC/DC0%0/2
$assoc and not $assoc->is_expired
$assoc not $assoc->is_expired
Truth table0%0/3
A and not(B)
A= $assocB= not $assoc->is_expired
ABresult
0X0
100
111
47 0 my $signature_method
48 = OpenID::Lite::SignatureMethods->select_method( $assoc->type );
49 0 ▶ $is_valid = q{true}
Branch: 1 branch
BranchTrueFalseTotal
if $signature_method->verify($assoc->secret, $copied, $sig) 0 0 0
50 if $signature_method->verify( $assoc->secret, $copied, $sig );
51 }
52  
53 # XXX: what about openid1.X ?
54 # if ( $req_params->is_openid2 )
55 # my $nonce = $req_params->get('response_nonce');
56 # my ($nonce_timestamp, $nonce_str) = OpenID::Lite::Nonce->split_nonce($nonce);
57 # unless ($self->check_nonce->($nonce_str, $nonce_timestamp)) {
58 # return $self->ERROR(q{Invalid nonce.});
59 # }
60 # }
61  
62 0 my $res_params = OpenID::Lite::Message->new;
63 0 $res_params->set( ns => $ns );
64 0 $res_params->set( is_valid => $is_valid );
65  
66 0 my $invalidate_handle = $copied->get('invalidate_handle');
67 0 ▶ if ($invalidate_handle) {
Branch: 1 branch
BranchTrueFalseTotal
if ($invalidate_handle) 0 0 0
68 0 my $assoc
69 = $self->assoc_builder->build_from_handle( $invalidate_handle, { dumb => 0 } );
70 0 ▶ unless ( $assoc && !$assoc->is_expired ) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($assoc and not $assoc->is_expired) 0 0 0
Condition0%0/3
$assoc and not $assoc->is_expired
!ll&&!rl&&r
000
MC/DC0%0/2
$assoc and not $assoc->is_expired
$assoc not $assoc->is_expired
Truth table0%0/3
A and not(B)
A= $assocB= not $assoc->is_expired
ABresult
0X0
100
111
71 0 $res_params->set( invalidate_handle => $invalidate_handle );
72 }
73 }
74  
75 0 return OpenID::Lite::Provider::Response->new(
76 type => DIRECT,
77 req_params => $req_params,
78 res_params => $res_params,
79 );
80 }
81  
82 0 ▶sub _build_error {
Subroutine _build_error: not called CC=2 SCAR=17.9
83 0 my ( $self, $req_params, $msg, $ns ) = @_;
84 0 ▶ $ns ||= SIGNON_2_0;
Condition0%0/2
$ns ||= "http://specs.openid.net/auth/2.0/signon"
l!l
00
MC/DC0%0/1
$ns ||= "http://specs.openid.net/auth/2.0/signon"
$ns
Truth table0%0/2
A
A= $ns
Aresult
11
00
85 0 my $error = OpenID::Lite::Message->new();
86 0 $error->set( ns => $ns );
87 0 $error->set( error => $msg );
88 0 my $res = OpenID::Lite::Provider::Response->new(
89 type => DIRECT,
90 req_params => $req_params,
91 res_params => $error,
92 );
93 0 return $res;
94 }
95  
96 1 ▶no Any::Moose;
Subroutine BEGIN: called CC=1 SCAR=0.0
97 1 __PACKAGE__->meta->make_immutable;
98 1 1;
99  
« Lite/RelyingParty/Discover/Service/Builder.pm ↑ Summary Lite/RelyingParty/Discover/Parser/XRI.pm »