CatalystX/OAuth2/Request/RequestAuth.pm

filter: Statementstmt 100% 26 / 26 Branchbran 60.0% 6 / 10 Conditioncond 20.0% 1 / 5 MC/DCmcdc 0.0% 0 / 2 Subroutinesub 100% 5 / 5 Podpod 0.0% 0 / 2 totaltotal 76.0% 38 / 50 SCAR 20.0
CC
7
Cov
80%
_build_query_parameters
8.1
BEGIN
1.0
__ANON__
1.0
CRAP 7.4
« Catalyst/Authentication/Credential/OAuth2.pm ↑ Summary CatalystX/OAuth2/Controller/Role/WithStore.pm »
1 package CatalystX::OAuth2::Request::RequestAuth;
2 10 ▶use Moose;
Subroutine BEGIN: called CC=1 SCAR=0.0
3  
4 # ABSTRACT: Role for the initial request in the oauth2 flow
5  
6 10 with 'CatalystX::OAuth2::Grant';
7  
8 10 has client_secret =>
9 ( isa => 'Str', is => 'ro', predicate => 'has_client_secret' );
10 10 has enable_client_secret => ( isa => 'Bool', is => 'rw', default => 0 );
11  
12 around _params => sub {
13 5 ▶ my $orig = shift;
Subroutine __ANON__: called CC=1 SCAR=0.0
14 5 return $orig->(@_), qw(client_secret)
15 10 };
16  
17 # cargo-culted, a small refactor of the action roles should remove the need to do this
18 5 ▶sub has_approval { 1 }
Subroutine has_approval: called CC=1 SCAR=0.0
Pod undocumented
19  
20 sub _build_query_parameters {
21 3 ▶ my ($self) = @_;
Subroutine _build_query_parameters: called CC=7 SCAR=21.0
22  
23 3 ▶ my %q = $self->has_state ? ( state => $self->state ) : ();
Branch: 1 branch
BranchTrueFalseTotal
$self->has_state ? : 2 1 3
24  
25 3 ▶ $self->response_type eq 'code'
Branch: 1 branch
BranchTrueFalseTotal
$self->response_type eq "code" or return {"error", "unsuported_response_type", "error_description", 'this server does not support "' . $self->response_type . q[' as a method for obtaining an authorization code], %q} 0 3 3
26 or return {
27 error => 'unsuported_response_type',
28 error_description => 'this server does not support "'
29 . $self->response_type
30 . "' as a method for obtaining an authorization code",
31 %q
32 };
33  
34 3 $q{response_type} = $self->response_type;
35  
36 3 my $store = $self->store;
37 3 ▶ my $client = $store->find_client( $self->client_id )
Branch: 1 branch
BranchTrueFalseTotal
my $client = $store->find_client($self->client_id) or return {"error", "unauthorized_client", "error_description", 'the client identified by ' . $self->client_id . ' is not authorized to access this resource'} 0 3 3
38 or return {
39 error => 'unauthorized_client',
40 error_description => 'the client identified by '
41 . $self->client_id
42 . ' is not authorized to access this resource'
43 };
44  
45 3 ▶ $store->verify_client_secret( $self->client_id, $self->client_secret )
Branch: 1 branch
BranchTrueFalseTotal
if $self->enable_client_secret 0 3 3
Condition20%1/5
$self->enable_client_secret && ($store->verify_client_secret($self->client_id, $self->client_secret) || (return {'error', 'unauthorized_client', 'error_description', 'the client identified by ' . $self->client_id . ' is not authorized to access this resource'}))
!ll&&!rl&&r
300
$store->verify_client_secret($self->client_id, $self->client_secret) or return {"error", "unauthorized_client", "error_description", 'the client identified by ' . $self->client_id . ' is not authorized to access this resource'}
l!l
00
MC/DC0%0/2
$self->enable_client_secret && ($store->verify_client_secret($self->client_id, $self->client_secret) || (return {'error', 'unauthorized_client', 'error_description', 'the client identified by ' . $self->client_id . ' is not authorized to access this resource'}))
$self->enable_client_secret $store->verify_client_secret($self->client_id, $self->client_secret)
Truth table33%1/3
A && B
A= $self->enable_client_secretB= $store->verify_client_secret($self->client_id, $self->client_secret)
ABresult
0X0
100
111
46 or return {
47 error => 'unauthorized_client',
48 error_description => 'the client identified by '
49 . $self->client_id
50 . ' is not authorized to access this resource'
51 }
52 if $self->enable_client_secret;
53  
54 3 $q{client_id} = $self->client_id;
55  
56 3 ▶ $client->endpoint eq $self->redirect_uri
Branch: 1 branch
BranchTrueFalseTotal
$client->endpoint eq $self->redirect_uri or return {"error", "invalid_request", "error_description", "redirection_uri does not match the registered client endpoint"} 0 3 3
57 or return {
58 error => 'invalid_request',
59 error_description =>
60 'redirection_uri does not match the registered client endpoint'
61 };
62  
63 3 $q{redirect_uri} = $self->redirect_uri;
64  
65 3 my $code = $store->create_client_code( $self->client_id );
66 3 $q{code} = $code->as_string;
67  
68 3 return \%q;
69 }
70  
71 sub next_action_uri {
72 7 ▶ my ( $self, $controller, $c ) = @_;
Subroutine next_action_uri: called CC=1 SCAR=0.0
Pod undocumented
73 7 $c->uri_for( $controller->_get_auth_token_via_auth_grant_action,
74 $self->query_parameters );
75 }
76  
77 10 1;
78  
79 __END__
80  
81 =pod
82  
83 =head1 NAME
84  
85 CatalystX::OAuth2::Request::RequestAuth - Role for the initial request in the oauth2 flow
86  
87 =head1 VERSION
88  
89 version 0.001006
90  
91 =head1 AUTHOR
92  
93 Eden Cardim <edencardim@gmail.com>
94  
95 =head1 COPYRIGHT AND LICENSE
96  
97 This software is copyright (c) 2017 by Suretec Systems Ltd.
98  
99 This is free software; you can redistribute it and/or modify it under
100 the same terms as the Perl 5 programming language system itself.
101  
102 =cut
« Catalyst/Authentication/Credential/OAuth2.pm ↑ Summary CatalystX/OAuth2/Controller/Role/WithStore.pm »