« blib/lib/Google/Auth/ImpersonatedServiceAccountCredentials.pm
↑ Summary
blib/lib/Google/Auth/IDTokens/KeySources.pm »
| 1 | # Copyright 2022 Google LLC and contributors | ||||||||||||||||||||||||||||
| 2 | # | ||||||||||||||||||||||||||||
| 3 | # Licensed under the Apache License, Version 2.0 (the "License"); | ||||||||||||||||||||||||||||
| 4 | # you may not use this file except in compliance with the License. | ||||||||||||||||||||||||||||
| 5 | # You may obtain a copy of the License at | ||||||||||||||||||||||||||||
| 6 | # | ||||||||||||||||||||||||||||
| 7 | # http://www.apache.org/licenses/LICENSE-2.0 | ||||||||||||||||||||||||||||
| 8 | # | ||||||||||||||||||||||||||||
| 9 | # Unless required by applicable law or agreed to in writing, software | ||||||||||||||||||||||||||||
| 10 | # distributed under the License is distributed on an "AS IS" BASIS, | ||||||||||||||||||||||||||||
| 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||||||||||||||||||||||||||||
| 12 | # See the License for the specific language governing permissions and | ||||||||||||||||||||||||||||
| 13 | # limitations under the License. | ||||||||||||||||||||||||||||
| 14 | |||||||||||||||||||||||||||||
| 15 | package Google::Auth::ClientId; | ||||||||||||||||||||||||||||
| 16 | |||||||||||||||||||||||||||||
| 17 | 2 | ▶ | use Moo; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 18 | 2 | ▶ | use JSON::MaybeXS; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 19 | 2 | ▶ | use Google::Auth::Exceptions; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 20 | |||||||||||||||||||||||||||||
| 21 | 2 | has id => ( | |||||||||||||||||||||||||||
| 22 | is => 'ro', | ||||||||||||||||||||||||||||
| 23 | required => 1, | ||||||||||||||||||||||||||||
| 24 | ); | ||||||||||||||||||||||||||||
| 25 | |||||||||||||||||||||||||||||
| 26 | 2 | has secret => ( | |||||||||||||||||||||||||||
| 27 | is => 'ro', | ||||||||||||||||||||||||||||
| 28 | required => 1, | ||||||||||||||||||||||||||||
| 29 | ); | ||||||||||||||||||||||||||||
| 30 | |||||||||||||||||||||||||||||
| 31 | 2 | ▶ | sub from_hash { | ||||||||||||||||||||||||||
|
Subroutine
from_hash: called CC=5 SCAR=24.7
Pod
undocumented
| |||||||||||||||||||||||||||||
| 32 | 2 | my ($class, $hash) = @_; | |||||||||||||||||||||||||||
| 33 | |||||||||||||||||||||||||||||
| 34 | 2 | ▶ | my $config = $hash->{installed} // $hash->{web}; | ||||||||||||||||||||||||||
|
Condition33%1/3
$hash->{"installed"} // $hash->{"web"}
MC/DC0%0/2
$hash->{"installed"} // $hash->{"web"}
$hash->{"installed"}
$hash->{"web"}
Truth table33%1/3
A // B
A= $hash->{"installed"}B= $hash->{"web"}
| |||||||||||||||||||||||||||||
| 35 | |||||||||||||||||||||||||||||
| 36 | 2 | ▶ | if ($config) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 37 | return $class->new( | ||||||||||||||||||||||||||||
| 38 | id => $config->{client_id}, | ||||||||||||||||||||||||||||
| 39 | secret => $config->{client_secret}, | ||||||||||||||||||||||||||||
| 40 | 2 | ); | |||||||||||||||||||||||||||
| 41 | } | ||||||||||||||||||||||||||||
| 42 | |||||||||||||||||||||||||||||
| 43 | 0 | ▶ | if ($hash->{client_id} && $hash->{client_secret}) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
$hash->{"client_id"} and $hash->{"client_secret"}
MC/DC0%0/2
$hash->{"client_id"} and $hash->{"client_secret"}
$hash->{"client_id"}
$hash->{"client_secret"}
Truth table0%0/3
A and B
A= $hash->{"client_id"}B= $hash->{"client_secret"}
| |||||||||||||||||||||||||||||
| 44 | return $class->new( | ||||||||||||||||||||||||||||
| 45 | id => $hash->{client_id}, | ||||||||||||||||||||||||||||
| 46 | secret => $hash->{client_secret}, | ||||||||||||||||||||||||||||
| 47 | 0 | ); | |||||||||||||||||||||||||||
| 48 | } | ||||||||||||||||||||||||||||
| 49 | |||||||||||||||||||||||||||||
| 50 | 0 | Google::Auth::Error->throw("Invalid format for client ID configuration"); | |||||||||||||||||||||||||||
| 51 | } | ||||||||||||||||||||||||||||
| 52 | |||||||||||||||||||||||||||||
| 53 | 2 | ▶ | sub from_file { | ||||||||||||||||||||||||||
|
Subroutine
from_file: called CC=3 SCAR=11.2
Pod
undocumented
| |||||||||||||||||||||||||||||
| 54 | 2 | my ($class, $file) = @_; | |||||||||||||||||||||||||||
| 55 | |||||||||||||||||||||||||||||
| 56 | 2 | ▶ | open my $fh, '<', $file or die "Cannot open $file: $!"; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 57 | 2 | local $/; | |||||||||||||||||||||||||||
| 58 | 2 | my $json = <$fh>; | |||||||||||||||||||||||||||
| 59 | 2 | ▶ | close $fh or die "Cannot close $file: $!"; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 60 | |||||||||||||||||||||||||||||
| 61 | 2 | my $hash = decode_json($json); | |||||||||||||||||||||||||||
| 62 | 2 | return $class->from_hash($hash); | |||||||||||||||||||||||||||
| 63 | } | ||||||||||||||||||||||||||||
| 64 | |||||||||||||||||||||||||||||
| 65 | 2 | 1; | |||||||||||||||||||||||||||