Client/Role/AttributesManager.pm

filter: Statementstmt 96.0% 171 / 178 Branchbran 77.4% 48 / 62 Conditioncond 76.4% 13 / 17 MC/DCmcdc 54.5% 6 / 11 Subroutinesub 96.0% 49 / 51 Podpod n/a totaltotal 89.9% 287 / 319 CC 39 SCAR 12.5
CC
39
Cov
90%
_build_user_agent
14.0
__ANON__
6.0
_build_private_key
5.0
CRAP 3.5
« Client/Role/ClientAuthenticationHelper.pm ↑ Summary Client/Role/ClaimsValidator.pm »
1 package OIDC::Client::Role::AttributesManager;
2 5 ▶use utf8;
Subroutine BEGIN: called CC=1 SCAR=0.0
3 5 ▶use Moose::Role;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 5 ▶use namespace::autoclean;
Subroutine BEGIN: called CC=1 SCAR=0.0
5 5 ▶use feature 'signatures';
Subroutine BEGIN: called CC=1 SCAR=0.0
6 5 ▶no warnings 'experimental::signatures';
Subroutine BEGIN: called CC=1 SCAR=0.0
7 5 ▶use Readonly;
Subroutine BEGIN: called CC=1 SCAR=0.0
8 5 ▶use Carp qw(croak);
Subroutine BEGIN: called CC=1 SCAR=0.0
9 5 ▶use Mojo::File;
Subroutine BEGIN: called CC=1 SCAR=0.0
10 5 ▶use Mojo::JSON qw(decode_json);
Subroutine BEGIN: called CC=1 SCAR=0.0
11 5 ▶use Mojo::UserAgent;
Subroutine BEGIN: called CC=1 SCAR=0.0
12 5 ▶use OIDC::Client::ResponseParser;
Subroutine BEGIN: called CC=1 SCAR=0.0
13 5 ▶use OIDC::Client::TokenResponseParser;
Subroutine BEGIN: called CC=1 SCAR=0.0
14  
15 =encoding utf8
16  
17 =head1 NAME
18  
19 OIDC::Client::Role::AttributesManager - Attributes manager
20  
21 =head1 DESCRIPTION
22  
23 This Moose role declares and builds the various attributes of the L<OIDC::Client> module.
24  
25 =cut
26  
27 5 requires qw(log_msg);
28  
29 5 Readonly my %DEFAULT_JWT_DECODING_OPTIONS => (
30 verify_exp => 1, # require valid 'exp' claim
31 verify_iat => 1, # require valid 'iat' claim
32 leeway => 60, # to account for clock skew
33 );
34 5 Readonly my %DEFAULT_CLIENT_SECRET_JWT_ENCODING_OPTIONS => (
35 alg => 'HS256',
36 );
37 5 Readonly my %DEFAULT_PRIVATE_KEY_JWT_ENCODING_OPTIONS => (
38 alg => 'RS256',
39 );
40 5 Readonly my %DEFAULT_CHI_CONFIG => (
41 driver => 'Memory',
42 global => 0,
43 );
44 5 Readonly my $DEFAULT_GRANT_TYPE => 'authorization_code';
45 5 Readonly my $DEFAULT_TOKEN_TYPE => 'Bearer';
46 5 Readonly my $DEFAULT_USE_PKCE => 1;
47 5 Readonly my $DEFAULT_PKCE_CODE_CHALLENGE_METHOD => 'S256';
48 5 Readonly my $DEFAULT_STORE_MODE => 'session';
49 5 Readonly my $DEFAULT_CLIENT_AUTH_METHOD => 'client_secret_basic';
50 5 Readonly my $DEFAULT_TOKEN_VALIDATION_METHOD => 'jwt';
51 5 Readonly my $DEFAULT_CLIENT_ASSERTION_LIFETIME => 120;
52 5 Readonly my $DEFAULT_MAX_ID_TOKEN_AGE => 30; # in addition to the leeway to account for clock skew
53  
54 has 'config' => (
55 is => 'ro',
56 isa => 'HashRef',
57 4 ▶ default => sub { {} },
Subroutine __ANON__: called CC=1 SCAR=0.0
58 5 );
59  
60 5 foreach my $attr_name (qw( private_key_file private_jwk_file role_prefix client_assertion_audience
61 tls_client_key_file tls_client_cert_file tls_ca_file
62 signin_redirect_path signin_redirect_uri logout_redirect_path post_logout_redirect_uri
63 scope refresh_scope well_known_url )) {
64 has $attr_name => (
65 is => 'ro',
66 isa => 'Maybe[Str]',
67 lazy => 1,
68 63 ▶ default => sub { shift->config->{$attr_name} },
Subroutine __ANON__: called CC=1 SCAR=0.0
69 70 );
70 }
71  
72 5 foreach my $attr_name (qw( username password )) {
73 has $attr_name => (
74 is => 'rw',
75 isa => 'Maybe[Str]',
76 lazy => 1,
77 4 ▶ default => sub { shift->config->{$attr_name} },
Subroutine __ANON__: called CC=1 SCAR=0.0
78 10 );
79 }
80  
81 5 foreach my $attr_name (qw( expiration_leeway identity_expires_in )) {
82 has $attr_name => (
83 is => 'ro',
84 isa => 'Maybe[Int]',
85 lazy => 1,
86 2 ▶ default => sub { shift->config->{$attr_name} },
Subroutine __ANON__: called CC=1 SCAR=0.0
87 10 );
88 }
89  
90 5 foreach my $attr_name (qw( proxy_detect logout_with_id_token )) {
91 has $attr_name => (
92 is => 'ro',
93 isa => 'Maybe[Bool]',
94 lazy => 1,
95 4 ▶ default => sub { shift->config->{$attr_name} },
Subroutine __ANON__: called CC=1 SCAR=0.0
96 10 );
97 }
98  
99 5 foreach my $attr_name (qw( private_jwk mocked_identity mocked_access_token mocked_userinfo
100 authorize_endpoint_extra_params logout_extra_params )) {
101 has $attr_name => (
102 is => 'ro',
103 isa => 'Maybe[HashRef]',
104 lazy => 1,
105 8 ▶ default => sub { shift->config->{$attr_name} },
Subroutine __ANON__: called CC=1 SCAR=0.0
106 30 );
107 }
108  
109 5 has 'provider' => (
110 is => 'ro',
111 isa => 'Str',
112 lazy => 1,
113 builder => '_build_provider',
114 );
115  
116 5 has 'id' => (
117 is => 'ro',
118 isa => 'Str',
119 lazy => 1,
120 builder => '_build_id',
121 );
122  
123 5 has 'secret' => (
124 is => 'rw',
125 isa => 'Maybe[Str]',
126 lazy => 1,
127 builder => '_build_secret',
128 );
129  
130 5 has 'tls_client_key_passphrase' => (
131 is => 'rw',
132 isa => 'Maybe[Str]',
133 lazy => 1,
134 builder => '_build_tls_client_key_passphrase',
135 );
136  
137 5 has 'private_key' => (
138 is => 'rw',
139 isa => 'HashRef|ScalarRef',
140 lazy => 1,
141 builder => '_build_private_key',
142 );
143  
144 5 has 'audience' => (
145 is => 'ro',
146 isa => 'Str',
147 lazy => 1,
148 builder => '_build_audience',
149 );
150  
151 5 has 'user_agent' => (
152 is => 'ro',
153 isa => 'Mojo::UserAgent',
154 lazy => 1,
155 builder => '_build_user_agent',
156 );
157  
158 5 has 'claim_mapping' => (
159 is => 'ro',
160 isa => 'HashRef',
161 lazy => 1,
162 builder => '_build_claim_mapping',
163 );
164  
165 has 'audience_alias' => (
166 is => 'ro',
167 isa => 'Maybe[HashRef[HashRef]]',
168 lazy => 1,
169 6 ▶ default => sub { shift->config->{audience_alias} },
Subroutine __ANON__: called CC=1 SCAR=0.0
170 5 );
171  
172 has 'authorize_endpoint_response_mode' => (
173 is => 'ro',
174 isa => 'Maybe[ResponseMode]',
175 lazy => 1,
176 3 ▶ default => sub { shift->config->{authorize_endpoint_response_mode} },
Subroutine __ANON__: called CC=1 SCAR=0.0
177 5 );
178  
179 has 'max_id_token_age' => (
180 is => 'ro',
181 isa => 'Int',
182 lazy => 1,
183 1 ▶ default => sub { shift->config->{max_id_token_age}
Subroutine __ANON__: called CC=2 SCAR=7.6
184 1 ▶ || $DEFAULT_MAX_ID_TOKEN_AGE },
Branch: 1 branch
BranchTrueFalseTotal
+(shift())->config->{"max_id_token_age"} or $DEFAULT_MAX_ID_TOKEN_AGE 0 1 1
185 5 );
186  
187 has 'jwt_decoding_options' => (
188 is => 'rw',
189 isa => 'HashRef',
190 lazy => 1,
191 9 ▶ default => sub { shift->config->{jwt_decoding_options}
Subroutine __ANON__: called CC=2 SCAR=6.9
192 9 ▶ || \%DEFAULT_JWT_DECODING_OPTIONS },
Branch: 1 branch
BranchTrueFalseTotal
+(shift())->config->{"jwt_decoding_options"} or \%DEFAULT_JWT_DECODING_OPTIONS 1 8 9
193 5 );
194  
195 has 'client_secret_jwt_encoding_options' => (
196 is => 'rw',
197 isa => 'HashRef',
198 lazy => 1,
199 3 ▶ default => sub { shift->config->{client_secret_jwt_encoding_options}
Subroutine __ANON__: called CC=2 SCAR=7.6
200 3 ▶ || \%DEFAULT_CLIENT_SECRET_JWT_ENCODING_OPTIONS },
Branch: 1 branch
BranchTrueFalseTotal
+(shift())->config->{"client_secret_jwt_encoding_options"} or \%DEFAULT_CLIENT_SECRET_JWT_ENCODING_OPTIONS 0 3 3
201 5 );
202  
203 has 'private_key_jwt_encoding_options' => (
204 is => 'rw',
205 isa => 'HashRef',
206 lazy => 1,
207 4 ▶ default => sub { shift->config->{private_key_jwt_encoding_options}
Subroutine __ANON__: called CC=2 SCAR=7.6
208 4 ▶ || \%DEFAULT_PRIVATE_KEY_JWT_ENCODING_OPTIONS },
Branch: 1 branch
BranchTrueFalseTotal
+(shift())->config->{"private_key_jwt_encoding_options"} or \%DEFAULT_PRIVATE_KEY_JWT_ENCODING_OPTIONS 0 4 4
209 5 );
210  
211 has 'token_endpoint_grant_type' => (
212 is => 'ro',
213 isa => 'GrantType',
214 lazy => 1,
215 11 ▶ default => sub { shift->config->{token_endpoint_grant_type}
Subroutine __ANON__: called CC=2 SCAR=6.9
216 11 ▶ || $DEFAULT_GRANT_TYPE },
Branch: 1 branch
BranchTrueFalseTotal
+(shift())->config->{"token_endpoint_grant_type"} or $DEFAULT_GRANT_TYPE 4 7 11
217 5 );
218  
219 has 'client_auth_method' => (
220 is => 'ro',
221 isa => 'Maybe[ClientAuthMethod]',
222 lazy => 1,
223 70 ▶ default => sub { shift->config->{client_auth_method} },
Subroutine __ANON__: called CC=1 SCAR=0.0
224 5 );
225  
226 has 'token_endpoint_auth_method' => (
227 is => 'ro',
228 isa => 'ClientAuthMethod',
229 lazy => 1,
230 70 ▶ default => sub { my $self = shift;
Subroutine __ANON__: called CC=3 SCAR=11.0
231 $self->config->{token_endpoint_auth_method}
232 70 ▶ || $self->client_auth_method
Branch: 1 branch
BranchTrueFalseTotal
$self->config->{"token_endpoint_auth_method"} or $self->client_auth_method or $DEFAULT_CLIENT_AUTH_METHOD 24 46 70
Condition100%3/3
$self->config->{"token_endpoint_auth_method"} or $self->client_auth_method
l!l&&r!l&&!r
91546
MC/DC100%2/2
$self->config->{"token_endpoint_auth_method"} or $self->client_auth_method
$self->config->{"token_endpoint_auth_method"} $self->client_auth_method
Truth table100%3/3
A or B
A= $self->config->{"token_endpoint_auth_method"}B= $self->client_auth_method
ABresult
1X1
011
000
233 || $DEFAULT_CLIENT_AUTH_METHOD },
234 5 );
235  
236 has 'introspection_endpoint_auth_method' => (
237 is => 'ro',
238 isa => 'ClientAuthMethod',
239 lazy => 1,
240 70 ▶ default => sub { my $self = shift;
Subroutine __ANON__: called CC=3 SCAR=11.1
241 $self->config->{introspection_endpoint_auth_method}
242 70 ▶ || $self->client_auth_method
Branch: 1 branch
BranchTrueFalseTotal
$self->config->{"introspection_endpoint_auth_method"} or $self->client_auth_method or $DEFAULT_CLIENT_AUTH_METHOD 15 55 70
Condition66%2/3
$self->config->{"introspection_endpoint_auth_method"} or $self->client_auth_method
l!l&&r!l&&!r
01555
MC/DC50%1/2
$self->config->{"introspection_endpoint_auth_method"} or $self->client_auth_method
$self->config->{"introspection_endpoint_auth_method"} $self->client_auth_method
Truth table66%2/3
A or B
A= $self->config->{"introspection_endpoint_auth_method"}B= $self->client_auth_method
ABresult
1X1
011
000
243 || $DEFAULT_CLIENT_AUTH_METHOD },
244 5 );
245  
246 has 'token_validation_method' => (
247 is => 'ro',
248 isa => 'TokenValidationMethod',
249 lazy => 1,
250 1 ▶ default => sub { shift->config->{token_validation_method}
Subroutine __ANON__: called CC=2 SCAR=7.6
251 1 ▶ || $DEFAULT_TOKEN_VALIDATION_METHOD },
Branch: 1 branch
BranchTrueFalseTotal
+(shift())->config->{"token_validation_method"} or $DEFAULT_TOKEN_VALIDATION_METHOD 0 1 1
252 5 );
253  
254 has 'client_assertion_lifetime' => (
255 is => 'ro',
256 isa => 'Int',
257 lazy => 1,
258 7 ▶ default => sub { shift->config->{client_assertion_lifetime}
Subroutine __ANON__: called CC=2 SCAR=6.9
259 7 ▶ || $DEFAULT_CLIENT_ASSERTION_LIFETIME },
Branch: 1 branch
BranchTrueFalseTotal
+(shift())->config->{"client_assertion_lifetime"} or $DEFAULT_CLIENT_ASSERTION_LIFETIME 1 6 7
260 5 );
261  
262 has 'default_token_type' => (
263 is => 'ro',
264 isa => 'Str',
265 lazy => 1,
266 2 ▶ default => sub { $DEFAULT_TOKEN_TYPE },
Subroutine __ANON__: called CC=1 SCAR=0.0
267 5 );
268  
269 has 'use_pkce' => (
270 is => 'ro',
271 isa => 'Bool',
272 71 ▶ default => sub { shift->config->{use_pkce}
Subroutine __ANON__: called CC=2 SCAR=7.2
273 71 ▶ // $DEFAULT_USE_PKCE },
Condition66%2/3
+(shift())->config->{"use_pkce"} // $DEFAULT_USE_PKCE
l!l&&r!l&&!r
0683
MC/DC50%1/2
+(shift())->config->{"use_pkce"} // $DEFAULT_USE_PKCE
+(shift())->config->{"use_pkce"} $DEFAULT_USE_PKCE
Truth table66%2/3
A // B
A= +(shift())->config->{"use_pkce"}B= $DEFAULT_USE_PKCE
ABresult
1X1
011
000
274 5 );
275  
276 has 'pkce_code_challenge_method' => (
277 is => 'ro',
278 isa => 'CodeChallengeMethod',
279 71 ▶ default => sub { shift->config->{pkce_code_challenge_method}
Subroutine __ANON__: called CC=2 SCAR=7.6
280 71 ▶ || $DEFAULT_PKCE_CODE_CHALLENGE_METHOD },
Branch: 1 branch
BranchTrueFalseTotal
+(shift())->config->{"pkce_code_challenge_method"} or $DEFAULT_PKCE_CODE_CHALLENGE_METHOD 0 71 71
281 5 );
282  
283 5 has 'provider_metadata' => (
284 is => 'ro',
285 isa => 'HashRef',
286 lazy => 1,
287 builder => '_build_provider_metadata',
288 );
289  
290 has 'store_mode' => (
291 is => 'ro',
292 isa => 'StoreMode',
293 lazy => 1,
294 66 ▶ default => sub { shift->config->{store_mode}
Subroutine __ANON__: called CC=2 SCAR=6.9
295 66 ▶ || $DEFAULT_STORE_MODE },
Branch: 1 branch
BranchTrueFalseTotal
+(shift())->config->{"store_mode"} or $DEFAULT_STORE_MODE 2 64 66
296 5 );
297  
298 has 'cache_config' => (
299 is => 'rw',
300 isa => 'HashRef',
301 lazy => 1,
302 0 ▶ default => sub { shift->config->{cache_config}
Subroutine __ANON__: not called CC=2 SCAR=17.9
303 0 ▶ || \%DEFAULT_CHI_CONFIG },
Branch: 1 branch
BranchTrueFalseTotal
+(shift())->config->{"cache_config"} or \%DEFAULT_CHI_CONFIG 0 0 0
304 5 );
305  
306 5 has 'kid_keys' => (
307 is => 'ro',
308 isa => 'HashRef',
309 lazy => 1,
310 clearer => '_clear_kid_keys',
311 builder => '_build_kid_keys',
312 );
313  
314 has 'response_parser' => (
315 is => 'ro',
316 isa => 'OIDC::Client::ResponseParser',
317 lazy => 1,
318 1 ▶ default => sub { OIDC::Client::ResponseParser->new() },
Subroutine __ANON__: called CC=1 SCAR=0.0
319 5 );
320  
321 has 'token_response_parser' => (
322 is => 'ro',
323 isa => 'OIDC::Client::TokenResponseParser',
324 lazy => 1,
325 1 ▶ default => sub { OIDC::Client::TokenResponseParser->new() },
Subroutine __ANON__: called CC=1 SCAR=0.0
326 5 );
327  
328 63 ▶sub _build_provider ($self) {
Subroutine _build_provider: called CC=2 SCAR=6.9
329 my $provider = $self->config->{provider}
330 63 ▶ or croak('OIDC: no provider in config');
Branch: 1 branch
BranchTrueFalseTotal
my $provider = $self->config->{"provider"} or croak("OIDC: no provider in config") 62 1 63
331 62 return $provider;
332 }
333  
334 64 ▶sub _build_id ($self) {
Subroutine _build_id: called CC=2 SCAR=6.9
335 my $id = $self->config->{id}
336 64 ▶ or croak('OIDC: no id in config');
Branch: 1 branch
BranchTrueFalseTotal
my $id = $self->config->{"id"} or croak("OIDC: no id in config") 63 1 64
337 63 return $id;
338 }
339  
340 25 ▶sub _build_secret ($self) {
Subroutine _build_secret: called CC=2 SCAR=6.9
341 25 ▶ my $secret = $self->_get_value_from_config_or_envvar('secret')
Branch: 1 branch
BranchTrueFalseTotal
my $secret = $self->_get_value_from_config_or_envvar("secret") or croak("OIDC: no secret configured or set up in environment") 24 1 25
342 or croak("OIDC: no secret configured or set up in environment");
343 24 return $secret;
344 }
345  
346 4 ▶sub _build_tls_client_key_passphrase ($self) {
Subroutine _build_tls_client_key_passphrase: called CC=1 SCAR=0.0
347 4 return $self->_get_value_from_config_or_envvar('tls_client_key_passphrase');
348 }
349  
350 5 ▶sub _build_private_key ($self) {
Subroutine _build_private_key: called CC=5 SCAR=16.1
351 5 ▶ if (my $private_jwk_file = $self->private_jwk_file) {
Branch: 4 branches
BranchTrueFalseTotal
if (my $private_jwk_file = $self->private_jwk_file) { } 1 4 5
elsif (my $private_jwk = $self->private_jwk) { } 1 3 4
elsif (my $private_key_file = $self->private_key_file) { } 1 2 3
elsif (my $private_key = $self->config->{'private_key'}) { } 1 1 2
352 1 my $private_jwk = decode_json(Mojo::File->new($private_jwk_file)->slurp);
353 1 return $private_jwk;
354 }
355 elsif (my $private_jwk = $self->private_jwk) {
356 1 return $private_jwk;
357 }
358 elsif (my $private_key_file = $self->private_key_file) {
359 1 my $private_key = Mojo::File->new($private_key_file)->slurp;
360 1 return \$private_key;
361 }
362 elsif (my $private_key = $self->config->{private_key}) {
363 1 return \$private_key;
364 }
365 else {
366 1 croak('OIDC: no private_jwk_file, private_jwk, private_key_file or private_key has been configured');
367 }
368 }
369  
370 66 ▶sub _build_audience ($self) {
Subroutine _build_audience: called CC=2 SCAR=7.2
371 66 ▶ return $self->config->{audience} || $self->id;
Condition66%2/3
$self->config->{'audience'} || $self->id
l!l&&r!l&&!r
6600
MC/DC0%0/2
$self->config->{'audience'} || $self->id
$self->config->{'audience'} $self->id
Truth table66%2/3
A || B
A= $self->config->{'audience'}B= $self->id
ABresult
1X1
011
000
372 }
373  
374 4 ▶sub _build_user_agent ($self) {
Subroutine _build_user_agent: called CC=10 SCAR=26.4
375 4 my $ua = Mojo::UserAgent->new();
376  
377 4 ▶ if ($self->proxy_detect) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->proxy_detect) 1 3 4
378 1 $ua->proxy->detect;
379 }
380  
381 4 ▶ if (my $user_agent = $self->config->{user_agent}) {
Branch: 1 branch
BranchTrueFalseTotal
if (my $user_agent = $self->config->{"user_agent"}) 1 3 4
382 1 $ua->transactor->name($user_agent);
383 }
384  
385 3 ▶ $ua->on(start => sub {
Subroutine __ANON__: called CC=1 SCAR=0.0
386 3 my ($ua, $tx) = @_;
387 3 $tx->req->headers->accept('application/json');
388 4 });
389  
390 4 ▶ if ($self->tls_client_cert_file && $self->tls_client_key_file) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->tls_client_cert_file and $self->tls_client_key_file) 1 3 4
Condition66%2/3
$self->tls_client_cert_file and $self->tls_client_key_file
!ll&&!rl&&r
301
MC/DC50%1/2
$self->tls_client_cert_file and $self->tls_client_key_file
$self->tls_client_cert_file $self->tls_client_key_file
Truth table66%2/3
A and B
A= $self->tls_client_cert_fileB= $self->tls_client_key_file
ABresult
0X0
100
111
391 1 my %tls_options = (
392 SSL_cert_file => $self->tls_client_cert_file,
393 SSL_key_file => $self->tls_client_key_file,
394 );
395 1 ▶ if ($self->tls_ca_file) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->tls_ca_file) 1 0 1
396 1 $tls_options{SSL_ca_file} = $self->tls_ca_file;
397 }
398 1 ▶ if (defined $self->tls_client_key_passphrase) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $self->tls_client_key_passphrase) 0 1 1
399 0 ▶ $tls_options{SSL_passwd_cb} = sub {
Subroutine __ANON__: not called CC=1 SCAR=6.9
400 0 return $self->tls_client_key_passphrase;
401 0 };
402 }
403  
404 1 ▶ if ($ua->can('tls_options')) {
Branch: 2 branches
BranchTrueFalseTotal
if ($ua->can('tls_options')) { } 1 0 1
elsif (exists $tls_options{'SSL_passwd_cb'}) { } 0 0 0
405 1 $ua->tls_options(\%tls_options);
406 }
407 elsif (exists $tls_options{SSL_passwd_cb}) {
408 0 croak('OIDC: SSL_passwd_cb requires Mojolicious 9.31 or newer');
409 }
410 else {
411 0 $ua->cert($tls_options{SSL_cert_file});
412 0 $ua->key($tls_options{SSL_key_file});
413 0 ▶ $ua->ca($tls_options{SSL_ca_file}) if exists $tls_options{SSL_ca_file};
Branch: 1 branch
BranchTrueFalseTotal
if exists $tls_options{"SSL_ca_file"} 0 0 0
414 }
415 }
416  
417 4 return $ua;
418 }
419  
420 4 ▶sub _build_claim_mapping ($self) {
Subroutine _build_claim_mapping: called CC=2 SCAR=6.9
421 4 ▶ return $self->config->{claim_mapping} || {};
Condition100%2/2
$self->config->{'claim_mapping'} || {}
l!l
31
MC/DC100%1/1
$self->config->{'claim_mapping'} || {}
$self->config->{'claim_mapping'}
Truth table100%2/2
A
A= $self->config->{'claim_mapping'}
Aresult
11
00
422 }
423  
424 26 ▶sub _build_provider_metadata ($self) {
Subroutine _build_provider_metadata: called CC=4 SCAR=13.9
425 26 my $provider_metadata = {};
426  
427 26 ▶ if (my $well_known_url = $self->well_known_url) {
Branch: 1 branch
BranchTrueFalseTotal
if (my $well_known_url = $self->well_known_url) 2 24 26
428 2 $provider_metadata = $self->_get_provider_metadata($well_known_url);
429 }
430  
431 # provider metadata can be overloaded by configuration
432 26 for (qw/authorize_url end_session_url issuer token_url introspection_url userinfo_url jwks_url/) {
433 182 ▶ $provider_metadata->{$_} = $self->config->{$_} if exists $self->config->{$_};
Branch: 1 branch
BranchTrueFalseTotal
if exists $self->config->{$_} 12 170 182
434 }
435  
436 26 return $provider_metadata;
437 }
438  
439 5 ▶sub _build_kid_keys ($self) {
Subroutine _build_kid_keys: called CC=2 SCAR=6.9
440 5 my $provider = $self->provider;
441 5 $self->log_msg(info => "OIDC/$provider: fetching JWT kid keys");
442  
443 my $jwks_url = $self->provider_metadata->{jwks_url}
444 5 ▶ or croak("OIDC: jwks_url not found in provider metadata");
Branch: 1 branch
BranchTrueFalseTotal
my $jwks_url = $self->provider_metadata->{"jwks_url"} or croak("OIDC: jwks_url not found in provider metadata") 4 1 5
445  
446 4 my $res = $self->user_agent->get($jwks_url)->result;
447  
448 4 return $self->response_parser->parse($res);
449 }
450  
451 2 ▶sub _get_provider_metadata ($self, $well_known_url) {
Subroutine _get_provider_metadata: called CC=1 SCAR=0.0
452 2 my $provider = $self->provider;
453 2 $self->log_msg(info => "OIDC/$provider: fetching OpenID configuration from $well_known_url");
454  
455 2 my $res = $self->user_agent->get($well_known_url)->result;
456 2 my $provider_config = $self->response_parser->parse($res);
457  
458 return {
459 authorize_url => $provider_config->{authorization_endpoint},
460 end_session_url => $provider_config->{end_session_endpoint},
461 issuer => $provider_config->{issuer},
462 token_url => $provider_config->{token_endpoint},
463 introspection_url => $provider_config->{introspection_endpoint},
464 userinfo_url => $provider_config->{userinfo_endpoint},
465 jwks_url => $provider_config->{jwks_uri},
466 2 };
467 }
468  
469 29 ▶sub _get_value_from_config_or_envvar ($self, $key) {
Subroutine _get_value_from_config_or_envvar: called CC=2 SCAR=6.9
470 29 my $value = $self->config->{$key};
471 29 ▶ unless (defined $value) {
Branch: 1 branch
BranchTrueFalseTotal
unless (defined $value) 5 24 29
472 5 my $provider = $self->provider;
473 5 $value = $ENV{uc "OIDC_${provider}_${key}"};
474 }
475  
476 29 return $value;
477 }
478  
479 5 1;
« Client/Role/ClientAuthenticationHelper.pm ↑ Summary Client/Role/ClaimsValidator.pm »