blib/lib/Google/Auth.pm

filter: Statementstmt 91.1% 31 / 34 Branchbran 25.0% 1 / 4 Conditioncond 37.5% 3 / 8 MC/DCmcdc 0.0% 0 / 4 Subroutinesub 100% 9 / 9 Podpod 100% 1 / 1 totaltotal 75.0% 45 / 60 CC 6 SCAR 17.4
CC
6
Cov
76%
default
12.0
BEGIN
1.0
BEGIN
1.0
CRAP 5.7
« blib/lib/Google/Auth/IDTokens/KeySources.pm ↑ Summary blib/lib/Google/Auth/CloudSDK.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;
16  
17 12 ▶use 5.006;
Subroutine BEGIN: called CC=1 SCAR=0.0
18 12 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
19 12 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
20  
21 12 ▶use Google::Auth::EnvironmentVars;
Subroutine BEGIN: called CC=1 SCAR=0.0
22 12 ▶use Google::Auth::DefaultCredentials;
Subroutine BEGIN: called CC=1 SCAR=0.0
23 12 ▶use Google::Auth::ComputeEngine;
Subroutine BEGIN: called CC=1 SCAR=0.0
24 12 ▶use Google::Auth::Exceptions;
Subroutine BEGIN: called CC=1 SCAR=0.0
25 12 ▶use XSLoader;
Subroutine BEGIN: called CC=1 SCAR=0.0
26  
27 12 our $VERSION = '0.12';
28 12 XSLoader::load('Google::Auth', $VERSION);
29  
30 =head1 NAME
31  
32 Application default credentials.
33  
34 Google::Auth - Implements application default credentials and project ID detection.
35  
36  
37 =head1 VERSION
38  
39 Version 0.12
40  
41 =cut
42  
43 =head1 SYNOPSIS
44  
45 Quick summary of what the module does.
46  
47 Perhaps a little code snippet.
48  
49 use Google::Auth;
50  
51 my $gauth = Google::Auth->new();
52 ...
53  
54 =head1 EXPORT
55  
56 A list of functions that can be exported. You can delete this section
57 if you don't export anything, such as for a purely object-oriented module.
58  
59 =head1 SUBROUTINES/METHODS
60  
61 =head2 default( $scopes, $options )
62  
63 Gets the default credentials for the current environment.
64  
65 =cut
66  
67 #[%- Perl::Critic::Policy::Subroutines::ProhibitBuiltinHomonyms %]
68 4 ▶sub default {
Subroutine default: called CC=6 SCAR=24.8
Pod documented
69 4 my ($self, $scopes, $options) = @_;
70 4 ▶ $options //= {};
Condition50%1/2
$options //= {}
l!l
04
MC/DC0%0/1
$options //= {}
$options
Truth table50%1/2
A
A= $options
Aresult
11
00
71  
72 4 my $dc = Google::Auth::DefaultCredentials->new();
73  
74 4 ▶ my $creds =
Condition33%2/6
$dc->from_env($scopes, %$options) || $dc->from_well_known_path($scopes, %$options) || $dc->from_system_default_path($scopes, %$options)
l!l&&r!l&&!r
100
$dc->from_env($scopes, %$options) or $dc->from_well_known_path($scopes, %$options)
l!l&&r!l&&!r
100
MC/DC0%0/3
$dc->from_env($scopes, %$options) || $dc->from_well_known_path($scopes, %$options) || $dc->from_system_default_path($scopes, %$options)
$dc->from_env($scopes, %$options) $dc->from_well_known_path($scopes, %$options) $dc->from_system_default_path($scopes, %$options)
Truth table25%1/4
A or B || C
A= $dc->from_env($scopes, %$options)B= $dc->from_well_known_path($scopes, %$options)C= $dc->from_system_default_path($scopes, %$options)
ABCresult
1XX1
01X1
0011
0000
75 $dc->from_env($scopes, %$options)
76 || $dc->from_well_known_path($scopes, %$options)
77 || $dc->from_system_default_path($scopes, %$options);
78  
79 1 ▶ return $creds if $creds;
Branch: 1 branch
BranchTrueFalseTotal
if $creds 1 0 1
80  
81 0 ▶ if (Google::Auth::ComputeEngine->on_gce(%$options)) {
Branch: 1 branch
BranchTrueFalseTotal
if ("Google::Auth::ComputeEngine"->on_gce(%$options)) 0 0 0
82 0 return Google::Auth::ComputeEngine->new(scope => $scopes, %$options);
83 }
84  
85 Google::Auth::DefaultCredentialsError->throw(
86 0 'Your credentials were not found. To set up Application Default ' .
87 'Credentials for your environment, see ' .
88 'https://cloud.google.com/docs/authentication/external/set-up-adc');
89 }
90  
91 # I have no idea why my perlcritic throws this
92 #[%- Perl::Critic::Policy::Modules::RequireEndWithOne %]
93 # End of Google::Auth
94 12 1;
95  
96 =head1 CONFIGURATION AND ENVIRONMENT
97  
98 =over 4
99  
100 =item GOOGLE_EXTERNAL_ACCOUNT_ALLOW_EXECUTABLES
101  
102 Set to '1' to allow Pluggable Credentials to execute external commands. Default is '0' (disabled).
103  
104 =item GOOGLE_EXTERNAL_ACCOUNT_ALLOW_CUSTOM_UNIVERSES
105  
106 Set to '1' to allow custom universes in credentials files loaded from JSON. Default is '0' (disabled).
107  
108 =back
109  
110 =head1 AUTHOR
111  
112 C.J. Collier, C<< <cjac at google.com> >>
113  
114 =head1 BUGS AND SUPPORT
115  
116 Please report any bugs or feature requests to the GitHub issue tracker at
117 L<https://github.com/GoogleCloudPlatform/google-auth-library-perl/issues> or via RT at
118 L<https://rt.cpan.org/Dist/Display.html?Name=Google-Auth>.
119  
120 You can also look for information at:
121  
122 =over 4
123  
124 =item * GitHub Issue Tracker
125  
126 L<https://github.com/GoogleCloudPlatform/google-auth-library-perl/issues>
127  
128 =item * RT: CPAN's Request Tracker
129  
130 L<https://rt.cpan.org/Dist/Display.html?Name=Google-Auth>
131  
132 =item * MetaCPAN
133  
134 L<https://metacpan.org/release/Google-Auth>
135  
136 =back
137  
138  
139 =head1 ACKNOWLEDGEMENTS
140  
141  
142 =head1 LICENSE AND COPYRIGHT
143  
144 Copyright 2020 Google LLC and contributors
145  
146 This program is released under the following license: Apache 2.0
147  
148  
149 =cut
150  
« blib/lib/Google/Auth/IDTokens/KeySources.pm ↑ Summary blib/lib/Google/Auth/CloudSDK.pm »