| 1 | package Paws::Credential::ProviderChain; | ||||||||||
| 2 | 1 | ▶ | use Moose; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 3 | |||||||||||
| 4 | has providers => ( | ||||||||||
| 5 | is => 'ro', | ||||||||||
| 6 | isa => 'ArrayRef[Str]', | ||||||||||
| 7 | 0 | ▶ | default => sub { | ||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||
| 8 | 0 | [ 'Paws::Credential::Environment', | |||||||||
| 9 | 'Paws::Credential::File', | ||||||||||
| 10 | 'Paws::Credential::ECSContainerProfile', | ||||||||||
| 11 | 'Paws::Credential::InstanceProfile', | ||||||||||
| 12 | 'Paws::Credential::InstanceProfileV2', | ||||||||||
| 13 | ] | ||||||||||
| 14 | }, | ||||||||||
| 15 | 1 | ); | |||||||||
| 16 | |||||||||||
| 17 | 1 | has selected_provider => ( | |||||||||
| 18 | is => 'rw', | ||||||||||
| 19 | does => 'Paws::Credential', | ||||||||||
| 20 | handles => [ 'access_key', 'secret_key', 'session_token' ], | ||||||||||
| 21 | ); | ||||||||||
| 22 | |||||||||||
| 23 | 1 | ▶ | sub BUILD { | ||||||||
|
Subroutine
BUILD: called CC=3 SCAR=11.4
Pod
undocumented
| |||||||||||
| 24 | 1 | my ($self) = @_; | |||||||||
| 25 | 1 | foreach my $prov (@{ $self->providers }) { | |||||||||
| 26 | 1 | Paws->load_class($prov); | |||||||||
| 27 | 1 | my $creds = $prov->new; | |||||||||
| 28 | 1 | ▶ | if ($creds->are_set) { | ||||||||
|
Branch: 1 branch
| |||||||||||
| 29 | 1 | $self->selected_provider($creds); | |||||||||
| 30 | 1 | return; | |||||||||
| 31 | } | ||||||||||
| 32 | } | ||||||||||
| 33 | # Tried all the providers... none got creds | ||||||||||
| 34 | 0 | die "Can't find any credentials. I tried with " . (join ',', @{ $self->providers }) | |||||||||
| 35 | } | ||||||||||
| 36 | |||||||||||
| 37 | 1 | with 'Paws::Credential'; | |||||||||
| 38 | 1 | 1; | |||||||||
| 39 | ### main pod documentation begin ### | ||||||||||
| 40 | |||||||||||
| 41 | =encoding UTF-8 | ||||||||||
| 42 | |||||||||||
| 43 | =head1 NAME | ||||||||||
| 44 | |||||||||||
| 45 | Paws::Credential::ProviderChain | ||||||||||
| 46 | |||||||||||
| 47 | =head1 SYNOPSIS | ||||||||||
| 48 | |||||||||||
| 49 | use Paws::Credential::ProviderChain; | ||||||||||
| 50 | |||||||||||
| 51 | my $paws = Paws->new(config => { | ||||||||||
| 52 | credentials => Paws::Credential::ProviderChain->new( | ||||||||||
| 53 | providers => [ 'Paws::Credential::Environment', 'Paws::Credential::InstanceProfile' ], | ||||||||||
| 54 | ) | ||||||||||
| 55 | }); | ||||||||||
| 56 | |||||||||||
| 57 | =head1 DESCRIPTION | ||||||||||
| 58 | |||||||||||
| 59 | The ProviderChain is used to call different credential providers, one by one, in order, until one of them returns credentials. | ||||||||||
| 60 | |||||||||||
| 61 | If none return credentials: an exception is raised. | ||||||||||
| 62 | |||||||||||
| 63 | It is the default provider for Paws | ||||||||||
| 64 | |||||||||||
| 65 | =head2 providers: ArrayRef[Str] | ||||||||||
| 66 | |||||||||||
| 67 | Defaults to C<[ 'Paws::Credential::Environment', 'Paws::Credential::File', 'Paws::Credential::InstanceProfile', 'Paws::Credential::InstanceProfileV2' ]> | ||||||||||
| 68 | |||||||||||
| 69 | =cut | ||||||||||