line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Net::Amazon::S3::Authorization::IAM; |
2
|
|
|
|
|
|
|
$Net::Amazon::S3::Authorization::IAM::VERSION = '0.99'; |
3
|
|
|
|
|
|
|
# ABSTRACT: IAM authorization information |
4
|
|
|
|
|
|
|
|
5
|
1
|
|
|
1
|
|
7
|
use Moose 0.85; |
|
1
|
|
|
|
|
24
|
|
|
1
|
|
|
|
|
12
|
|
6
|
1
|
|
|
1
|
|
8293
|
use MooseX::StrictConstructor 0.16; |
|
1
|
|
|
|
|
31
|
|
|
1
|
|
|
|
|
15
|
|
7
|
|
|
|
|
|
|
|
8
|
|
|
|
|
|
|
extends 'Net::Amazon::S3::Authorization::Basic'; |
9
|
|
|
|
|
|
|
|
10
|
|
|
|
|
|
|
has '+aws_access_key_id' => ( |
11
|
|
|
|
|
|
|
lazy => 1, |
12
|
|
|
|
|
|
|
default => sub { $_[0]->_credentials->accessKeyId }, |
13
|
|
|
|
|
|
|
); |
14
|
|
|
|
|
|
|
|
15
|
|
|
|
|
|
|
has '+aws_secret_access_key' => ( |
16
|
|
|
|
|
|
|
lazy => 1, |
17
|
|
|
|
|
|
|
default => sub { $_[0]->_credentials->secretAccessKey }, |
18
|
|
|
|
|
|
|
); |
19
|
|
|
|
|
|
|
|
20
|
|
|
|
|
|
|
has aws_session_token => ( |
21
|
|
|
|
|
|
|
is => 'ro', |
22
|
|
|
|
|
|
|
lazy => 1, |
23
|
|
|
|
|
|
|
default => sub { $_[0]->_credentials->sessionToken }, |
24
|
|
|
|
|
|
|
); |
25
|
|
|
|
|
|
|
|
26
|
|
|
|
|
|
|
has _credentials => ( |
27
|
|
|
|
|
|
|
is => 'ro', |
28
|
|
|
|
|
|
|
init_arg => undef, |
29
|
|
|
|
|
|
|
lazy => 1, |
30
|
|
|
|
|
|
|
builder => '_build_credentials', |
31
|
|
|
|
|
|
|
); |
32
|
|
|
|
|
|
|
|
33
|
|
|
|
|
|
|
sub _build_credentials { |
34
|
0
|
0
|
|
0
|
|
|
eval "require VM::EC2::Security::CredentialCache" or die $@; |
35
|
0
|
|
|
|
|
|
my $creds = VM::EC2::Security::CredentialCache->get(); |
36
|
0
|
0
|
|
|
|
|
defined($creds) || die("Unable to retrieve IAM role credentials"); |
37
|
|
|
|
|
|
|
|
38
|
0
|
|
|
|
|
|
return $creds; |
39
|
|
|
|
|
|
|
} |
40
|
|
|
|
|
|
|
|
41
|
|
|
|
|
|
|
around authorization_headers => sub { |
42
|
|
|
|
|
|
|
my ($orig, $self) = @_; |
43
|
|
|
|
|
|
|
|
44
|
|
|
|
|
|
|
return +( |
45
|
|
|
|
|
|
|
$self->$orig, |
46
|
|
|
|
|
|
|
'x-amz-security-token' => $self->aws_session_token, |
47
|
|
|
|
|
|
|
); |
48
|
|
|
|
|
|
|
}; |
49
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
1; |
51
|
|
|
|
|
|
|
|
52
|
|
|
|
|
|
|
__END__ |
53
|
|
|
|
|
|
|
|
54
|
|
|
|
|
|
|
=pod |
55
|
|
|
|
|
|
|
|
56
|
|
|
|
|
|
|
=encoding UTF-8 |
57
|
|
|
|
|
|
|
|
58
|
|
|
|
|
|
|
=head1 NAME |
59
|
|
|
|
|
|
|
|
60
|
|
|
|
|
|
|
Net::Amazon::S3::Authorization::IAM - IAM authorization information |
61
|
|
|
|
|
|
|
|
62
|
|
|
|
|
|
|
=head1 VERSION |
63
|
|
|
|
|
|
|
|
64
|
|
|
|
|
|
|
version 0.99 |
65
|
|
|
|
|
|
|
|
66
|
|
|
|
|
|
|
=head1 SYNOPSIS |
67
|
|
|
|
|
|
|
|
68
|
|
|
|
|
|
|
use Net::Amazon::S3; |
69
|
|
|
|
|
|
|
use Net::Amazon::S3::Authorization::IAM; |
70
|
|
|
|
|
|
|
|
71
|
|
|
|
|
|
|
# obtain instance credentials |
72
|
|
|
|
|
|
|
use VM::EC2::Security::CredentialCache; |
73
|
|
|
|
|
|
|
my $s3 = Net::Amazon::S3->new ( |
74
|
|
|
|
|
|
|
authorization_context => Net::Amazon::S3::Authorization::IAM->new, |
75
|
|
|
|
|
|
|
... |
76
|
|
|
|
|
|
|
); |
77
|
|
|
|
|
|
|
|
78
|
|
|
|
|
|
|
# or just provide your values |
79
|
|
|
|
|
|
|
my $s3 = Net::Amazon::S3->new ( |
80
|
|
|
|
|
|
|
authorization_context => Net::Amazon::S3::Authorization::IAM->new ( |
81
|
|
|
|
|
|
|
aws_access_key_id => ..., |
82
|
|
|
|
|
|
|
aws_secret_access_key => ..., |
83
|
|
|
|
|
|
|
aws_session_token => ..., |
84
|
|
|
|
|
|
|
), |
85
|
|
|
|
|
|
|
... |
86
|
|
|
|
|
|
|
); |
87
|
|
|
|
|
|
|
|
88
|
|
|
|
|
|
|
=head1 DESCRIPTION |
89
|
|
|
|
|
|
|
|
90
|
|
|
|
|
|
|
Authorization context using instance session credentials. |
91
|
|
|
|
|
|
|
|
92
|
|
|
|
|
|
|
Unless specified authorization context obtains credentials via L<< VM::EC2::Security::CredentialCache >>. |
93
|
|
|
|
|
|
|
It is not listed as a L<< Net::Amazon::S3 >> dependency. |
94
|
|
|
|
|
|
|
|
95
|
|
|
|
|
|
|
=head1 INCOMPATIBILITY WARNING |
96
|
|
|
|
|
|
|
|
97
|
|
|
|
|
|
|
This module with its dependencies will be moved out and distributed separately |
98
|
|
|
|
|
|
|
without dependency from L<Net::Amazon::S3>. |
99
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
If you use IAM, please consider to add proper C<use> statement into your code. |
101
|
|
|
|
|
|
|
|
102
|
|
|
|
|
|
|
=head1 AUTHOR |
103
|
|
|
|
|
|
|
|
104
|
|
|
|
|
|
|
Branislav Zahradník <barney@cpan.org> |
105
|
|
|
|
|
|
|
|
106
|
|
|
|
|
|
|
=head1 COPYRIGHT AND LICENSE |
107
|
|
|
|
|
|
|
|
108
|
|
|
|
|
|
|
This software is copyright (c) 2021 by Amazon Digital Services, Leon Brocard, Brad Fitzpatrick, Pedro Figueiredo, Rusty Conover, Branislav Zahradník. |
109
|
|
|
|
|
|
|
|
110
|
|
|
|
|
|
|
This is free software; you can redistribute it and/or modify it under |
111
|
|
|
|
|
|
|
the same terms as the Perl 5 programming language system itself. |
112
|
|
|
|
|
|
|
|
113
|
|
|
|
|
|
|
=cut |