« blib/lib/Amazon/Credentials/Role/SSOCache.pm
↑ Summary
blib/lib/Amazon/Credentials/Provider/WebIdentity.pm »
| 1 | package Amazon::Credentials::Resolver::Profile; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3 | 9 | ▶ | use strict; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 4 | 9 | ▶ | use warnings; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 5 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 6 | 9 | ▶ | use 5.010; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 7 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 8 | 9 | ▶ | use Amazon::Credentials::Provider::AssumeRole; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 9 | 9 | ▶ | use Amazon::Credentials::Provider::Config; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 10 | 9 | ▶ | use Amazon::Credentials::Provider::Process; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 11 | 9 | ▶ | use Amazon::Credentials::Provider::Container; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 12 | 9 | ▶ | use Amazon::Credentials::Provider::Env; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 13 | 9 | ▶ | use Amazon::Credentials::Provider::InstanceRole; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 14 | 9 | ▶ | use Amazon::Credentials::Provider::WebIdentity; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 15 | 9 | ▶ | use Amazon::Credentials::Provider::SSO; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 16 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 17 | 9 | ▶ | use Carp; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 18 | 9 | ▶ | use Role::Tiny::With; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 19 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 20 | 9 | with 'Amazon::Credentials::Role::File'; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 21 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 22 | ######################################################################## | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 23 | 37 | ▶ | sub new { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
new: called CC=2 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 24 | ######################################################################## | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 25 | 37 | my ( $class, @args ) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 26 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 27 | 37 | ▶ | my $options = ref $args[0] ? { %{ $args[0] } } : {@args}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 28 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 29 | return bless { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 30 | user_agent => $options->{user_agent}, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 31 | imdsv2 => $options->{imdsv2}, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 32 | 37 | }, $class; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 33 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 34 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 35 | ######################################################################## | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 36 | 37 | ▶ | sub resolve { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
resolve: called CC=2 SCAR=7.1
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 37 | ######################################################################## | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 38 | 37 | my ( $self, $profile ) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 39 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 40 | 37 | ▶ | $profile ||= 'default'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition50%1/2
$profile ||= "default"
MC/DC0%0/1
$profile ||= "default"
$profile
Truth table50%1/2
A
A= $profile
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 41 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 42 | 37 | return $self->_resolve_profile( | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 43 | profile => $profile, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 44 | seen => {}, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 45 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 46 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 47 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 48 | ######################################################################## | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 49 | 51 | ▶ | sub _resolve_profile { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_resolve_profile: called CC=18 SCAR=29.2
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 50 | ######################################################################## | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 51 | 51 | my ( $self, @args ) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 52 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 53 | 51 | ▶ | my $options = ref $args[0] ? $args[0] : {@args}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 54 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 55 | 51 | my $profile = $options->{profile}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 56 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 57 | 51 | my $seen = $options->{seen}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 58 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 59 | croak "credential profile cycle detected at '$profile'" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 60 | 51 | ▶ | if $seen->{$profile}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 61 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 62 | 49 | my %seen = %{$seen}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 63 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 64 | 49 | $seen{$profile} = 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 65 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 66 | 49 | my $config = $self->_get_profile($profile); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 67 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 68 | return | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 69 | 49 | ▶ | if !$config || !keys %{$config}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
$config and keys %{$config;}
MC/DC50%1/2
$config and keys %{$config;}
$config
keys %{$config;}
Truth table66%2/3
A and B
A= $configB= keys %{$config;}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 70 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 71 | 43 | ▶ | if ( $config->{web_identity_token_file} ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 72 | croak "profile '$profile' has web_identity_token_file but no role_arn" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 73 | 1 | ▶ | if !$config->{role_arn}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 74 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 75 | my %provider_options = ( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 76 | role_arn => $config->{role_arn}, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 77 | token_file => $config->{web_identity_token_file}, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 78 | 1 | ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 79 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 80 | 1 | ▶ | if ( defined $config->{role_session_name} ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 81 | 0 | $provider_options{role_session_name} = $config->{role_session_name}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 82 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 83 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 84 | 1 | ▶ | if ( defined $config->{region} ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 85 | 1 | $provider_options{region} = $config->{region}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 86 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 87 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 88 | 1 | ▶ | if ( $self->{user_agent} ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 89 | 1 | $provider_options{user_agent} = $self->{user_agent}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 90 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 91 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 92 | 1 | return Amazon::Credentials::Provider::WebIdentity->new(%provider_options); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 93 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 94 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 95 | 42 | ▶ | if ( $config->{role_arn} ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 96 | 24 | return $self->_resolve_assume_role( | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 97 | config => $config, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 98 | profile => $profile, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 99 | seen => \%seen, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 100 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 101 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 102 | 18 | ▶ | if ( $config->{sso_session} | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition77%7/9
$config->{"sso_session"} or $config->{"sso_start_url"} or $config->{"sso_account_id"} or $config->{"sso_role_name"}
$config->{"sso_session"} or $config->{"sso_start_url"} or $config->{"sso_account_id"}
$config->{"sso_session"} or $config->{"sso_start_url"}
MC/DC50%2/4
$config->{"sso_session"} or $config->{"sso_start_url"} or $config->{"sso_account_id"} or $config->{"sso_role_name"}
$config->{"sso_session"}
$config->{"sso_start_url"}
$config->{"sso_account_id"}
$config->{"sso_role_name"}
Truth table60%3/5
A or B or C or D
A= $config->{"sso_session"}B= $config->{"sso_start_url"}C= $config->{"sso_account_id"}D= $config->{"sso_role_name"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 103 | || $config->{sso_start_url} | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 104 | || $config->{sso_account_id} | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 105 | || $config->{sso_role_name} ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 106 | 3 | my %provider_options = ( profile => $profile, ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 107 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 108 | 3 | ▶ | if ( $self->{user_agent} ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 109 | 2 | $provider_options{user_agent} = $self->{user_agent}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 110 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 111 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 112 | 3 | return Amazon::Credentials::Provider::SSO->new(%provider_options); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 113 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 114 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 115 | 15 | ▶ | if ( $config->{credential_process} ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 116 | 4 | my %provider_options = ( profile => $profile, ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 117 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 118 | 4 | ▶ | if ( $self->{user_agent} ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 119 | 3 | $provider_options{user_agent} = $self->{user_agent}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 120 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 121 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 122 | 4 | return Amazon::Credentials::Provider::Process->new(%provider_options); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 123 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 124 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 125 | 11 | return Amazon::Credentials::Provider::Config->new( profile => $profile, ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 126 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 127 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 128 | ######################################################################## | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 129 | 24 | ▶ | sub _resolve_assume_role { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_resolve_assume_role: called CC=16 SCAR=27.7
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 130 | ######################################################################## | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 131 | 24 | my ( $self, @args ) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 132 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 133 | 24 | ▶ | my $options = ref $args[0] ? $args[0] : {@args}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 134 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 135 | 24 | my $config = $options->{config}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 136 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 137 | 24 | my $profile = $options->{profile}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 138 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 139 | 24 | my $source_profile = $config->{source_profile}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 140 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 141 | 24 | my $credential_source = $config->{credential_source}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 142 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 143 | 24 | ▶ | croak "profile '$profile' cannot specify both source_profile and credential_source" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%3/3
$source_profile and $credential_source
MC/DC100%2/2
$source_profile and $credential_source
$source_profile
$credential_source
Truth table100%3/3
A and B
A= $source_profileB= $credential_source
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 144 | if $source_profile && $credential_source; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 145 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 146 | 23 | ▶ | croak "profile '$profile' has role_arn but no credential source" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%3/3
$source_profile or $credential_source
MC/DC100%2/2
$source_profile or $credential_source
$source_profile
$credential_source
Truth table100%3/3
A or B
A= $source_profileB= $credential_source
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 147 | if !$source_profile && !$credential_source; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 148 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 149 | 22 | my $source_provider; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 150 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 151 | 22 | ▶ | if ($source_profile) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 152 | $source_provider = $self->_resolve_profile( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 153 | profile => $source_profile, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 154 | seen => $options->{seen}, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 155 | 14 | ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 156 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 157 | 11 | ▶ | croak "unable to resolve source_profile '$source_profile' for profile '$profile'" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 158 | if !$source_provider; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 159 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 160 | else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 161 | 8 | $source_provider = $self->_resolve_credential_source($credential_source); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 162 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 163 | 6 | ▶ | croak "unable to resolve credential_source '$credential_source' for profile '$profile'" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 164 | if !$source_provider; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 165 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 166 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 167 | my %provider_options = ( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 168 | role_arn => $config->{role_arn}, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 169 | 15 | source_provider => $source_provider, | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 170 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 171 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 172 | 15 | ▶ | if ( defined $config->{mfa_serial} ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 173 | croak "profile '$profile' requires MFA but AMAZON_CREDENTIALS_MFA_TOKEN is not set" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 174 | 2 | ▶ | if !defined $ENV{AMAZON_CREDENTIALS_MFA_TOKEN}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 175 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 176 | 1 | $provider_options{mfa_serial} = $config->{mfa_serial}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 177 | 1 | $provider_options{mfa_token} = $ENV{AMAZON_CREDENTIALS_MFA_TOKEN}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 178 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 179 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 180 | 14 | ▶ | if ( defined $config->{role_session_name} ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 181 | 1 | $provider_options{role_session_name} = $config->{role_session_name}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 182 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 183 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 184 | 14 | ▶ | if ( defined $config->{external_id} ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 185 | 1 | $provider_options{external_id} = $config->{external_id}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 186 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 187 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 188 | 14 | ▶ | if ( defined $config->{duration_seconds} ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 189 | 1 | $provider_options{duration_seconds} = $config->{duration_seconds}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 190 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 191 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 192 | 14 | ▶ | if ( defined $config->{region} ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 193 | 8 | $provider_options{region} = $config->{region}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 194 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 195 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 196 | 14 | ▶ | if ( $self->{user_agent} ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 197 | 14 | $provider_options{user_agent} = $self->{user_agent}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 198 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 199 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 200 | 14 | return Amazon::Credentials::Provider::AssumeRole->new(%provider_options); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 201 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 202 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 203 | ######################################################################## | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 204 | 8 | ▶ | sub _resolve_credential_source { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_resolve_credential_source: called CC=6 SCAR=18.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 205 | ######################################################################## | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 206 | 8 | my ( $self, $source ) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 207 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 208 | 8 | ▶ | if ( $source eq 'Environment' ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 3 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 209 | 2 | return Amazon::Credentials::Provider::Env->new; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 210 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 211 | elsif ( $source eq 'EcsContainer' ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 212 | 1 | my %options; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 213 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 214 | 1 | ▶ | if ( $self->{user_agent} ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 215 | 1 | $options{user_agent} = $self->{user_agent}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 216 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 217 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 218 | 1 | return Amazon::Credentials::Provider::Container->new(%options); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 219 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 220 | elsif ( $source eq 'Ec2InstanceMetadata' ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 221 | 4 | my %options = ( imdsv2 => $self->{imdsv2}, ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 222 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 223 | 4 | ▶ | if ( $self->{user_agent} ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 224 | 4 | $options{user_agent} = $self->{user_agent}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 225 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 226 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 227 | 4 | return Amazon::Credentials::Provider::InstanceRole->new(%options); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 228 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 229 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 230 | 1 | croak "unsupported credential_source '$source'"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 231 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 232 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 233 | 9 | 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||