| line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
|
1
|
|
|
|
|
|
|
package Signer::AWSv4::RDS; |
|
2
|
1
|
|
|
1
|
|
71597
|
use Moo; |
|
|
1
|
|
|
|
|
11873
|
|
|
|
1
|
|
|
|
|
5
|
|
|
3
|
|
|
|
|
|
|
extends 'Signer::AWSv4'; |
|
4
|
1
|
|
|
1
|
|
2095
|
use Types::Standard qw/Str Int/; |
|
|
1
|
|
|
|
|
78248
|
|
|
|
1
|
|
|
|
|
10
|
|
|
5
|
|
|
|
|
|
|
|
|
6
|
|
|
|
|
|
|
has '+expires' => (default => 900); |
|
7
|
|
|
|
|
|
|
has '+service' => (default => 'rds-db'); |
|
8
|
|
|
|
|
|
|
has '+method' => (default => 'GET'); |
|
9
|
|
|
|
|
|
|
has '+uri' => (default => '/'); |
|
10
|
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
has host => (is => 'ro', isa => Str, required => 1); |
|
12
|
|
|
|
|
|
|
has user => (is => 'ro', isa => Str, required => 1); |
|
13
|
|
|
|
|
|
|
has port => (is => 'ro', isa => Int, default => 3306); |
|
14
|
|
|
|
|
|
|
|
|
15
|
|
|
|
|
|
|
sub build_params { |
|
16
|
1
|
|
|
1
|
0
|
12
|
my $self = shift; |
|
17
|
|
|
|
|
|
|
{ |
|
18
|
1
|
|
|
|
|
33
|
'Action' => 'connect', |
|
19
|
|
|
|
|
|
|
'DBUser' => $self->user, |
|
20
|
|
|
|
|
|
|
'X-Amz-Algorithm' => $self->aws_algorithm, |
|
21
|
|
|
|
|
|
|
'X-Amz-Credential' => $self->access_key . "/" . $self->credential_scope, |
|
22
|
|
|
|
|
|
|
'X-Amz-Date' => $self->date_timestamp, |
|
23
|
|
|
|
|
|
|
'X-Amz-Expires' => $self->expires, |
|
24
|
|
|
|
|
|
|
'X-Amz-SignedHeaders' => $self->signed_header_list, |
|
25
|
|
|
|
|
|
|
} |
|
26
|
|
|
|
|
|
|
} |
|
27
|
|
|
|
|
|
|
|
|
28
|
|
|
|
|
|
|
sub build_headers { |
|
29
|
1
|
|
|
1
|
0
|
14
|
my $self = shift; |
|
30
|
|
|
|
|
|
|
{ |
|
31
|
1
|
|
|
|
|
21
|
Host => $self->host . ':' . $self->port, |
|
32
|
|
|
|
|
|
|
} |
|
33
|
|
|
|
|
|
|
} |
|
34
|
|
|
|
|
|
|
|
|
35
|
|
|
|
|
|
|
1; |
|
36
|
|
|
|
|
|
|
### main pod documentation begin ### |
|
37
|
|
|
|
|
|
|
|
|
38
|
|
|
|
|
|
|
=encoding UTF-8 |
|
39
|
|
|
|
|
|
|
|
|
40
|
|
|
|
|
|
|
=head1 NAME |
|
41
|
|
|
|
|
|
|
|
|
42
|
|
|
|
|
|
|
Signer::AWSv4::RDS - Generate tokens for signing into MySQL/Aurora RDS servers with IAM credentials |
|
43
|
|
|
|
|
|
|
|
|
44
|
|
|
|
|
|
|
=head1 SYNOPSIS |
|
45
|
|
|
|
|
|
|
|
|
46
|
|
|
|
|
|
|
use Signer::AWSv4::RDS; |
|
47
|
|
|
|
|
|
|
$pass_gen = Signer::AWSv4::RDS->new( |
|
48
|
|
|
|
|
|
|
access_key => 'AKIAIOSFODNN7EXAMPLE', |
|
49
|
|
|
|
|
|
|
secret_key => 'wJalrXUtnFEMI/K7MDENG/bPxRfiCYEXAMPLEKEY', |
|
50
|
|
|
|
|
|
|
host => 'MyRDSEndpoint', |
|
51
|
|
|
|
|
|
|
user => 'iam_user', |
|
52
|
|
|
|
|
|
|
region => 'us-east-1', |
|
53
|
|
|
|
|
|
|
); |
|
54
|
|
|
|
|
|
|
my $password = $pass_gen->signed_qstring; |
|
55
|
|
|
|
|
|
|
|
|
56
|
|
|
|
|
|
|
=head1 DESCRIPTION |
|
57
|
|
|
|
|
|
|
|
|
58
|
|
|
|
|
|
|
Generate tokens for signing into MySQL/Aurora RDS servers with IAM credentials. |
|
59
|
|
|
|
|
|
|
You can find details of the process in L. |
|
60
|
|
|
|
|
|
|
|
|
61
|
|
|
|
|
|
|
=head1 Request Attributes |
|
62
|
|
|
|
|
|
|
|
|
63
|
|
|
|
|
|
|
This module adds two required attributes in the constructor for obtaining a token (to be used |
|
64
|
|
|
|
|
|
|
as a MySQL password): |
|
65
|
|
|
|
|
|
|
|
|
66
|
|
|
|
|
|
|
=head2 host String |
|
67
|
|
|
|
|
|
|
|
|
68
|
|
|
|
|
|
|
The AWS RDS instance endpoint |
|
69
|
|
|
|
|
|
|
|
|
70
|
|
|
|
|
|
|
=head2 user String |
|
71
|
|
|
|
|
|
|
|
|
72
|
|
|
|
|
|
|
The user of the MySQL database |
|
73
|
|
|
|
|
|
|
|
|
74
|
|
|
|
|
|
|
=head2 port Integer |
|
75
|
|
|
|
|
|
|
|
|
76
|
|
|
|
|
|
|
The port the database is running on. Defaults to 3306. |
|
77
|
|
|
|
|
|
|
|
|
78
|
|
|
|
|
|
|
=head1 Signature Attributes |
|
79
|
|
|
|
|
|
|
|
|
80
|
|
|
|
|
|
|
=head2 signed_qstring |
|
81
|
|
|
|
|
|
|
|
|
82
|
|
|
|
|
|
|
This has to be used as the password for the MySQL Server. Please note that all of this needs |
|
83
|
|
|
|
|
|
|
extra setup: correctly configuring your AWS environment AND your MySQL Client. |
|
84
|
|
|
|
|
|
|
|
|
85
|
|
|
|
|
|
|
=head1 SEE ALSO |
|
86
|
|
|
|
|
|
|
|
|
87
|
|
|
|
|
|
|
L |
|
88
|
|
|
|
|
|
|
|
|
89
|
|
|
|
|
|
|
L |
|
90
|
|
|
|
|
|
|
|
|
91
|
|
|
|
|
|
|
=head1 BUGS and SOURCE |
|
92
|
|
|
|
|
|
|
|
|
93
|
|
|
|
|
|
|
The source code is located here: L |
|
94
|
|
|
|
|
|
|
|
|
95
|
|
|
|
|
|
|
Please report bugs to: L |
|
96
|
|
|
|
|
|
|
|
|
97
|
|
|
|
|
|
|
=head1 AUTHOR |
|
98
|
|
|
|
|
|
|
|
|
99
|
|
|
|
|
|
|
Jose Luis Martinez |
|
100
|
|
|
|
|
|
|
CAPSiDE |
|
101
|
|
|
|
|
|
|
jlmartinez@capside.com |
|
102
|
|
|
|
|
|
|
|
|
103
|
|
|
|
|
|
|
=head1 COPYRIGHT and LICENSE |
|
104
|
|
|
|
|
|
|
|
|
105
|
|
|
|
|
|
|
Copyright (c) 2018 by CAPSiDE |
|
106
|
|
|
|
|
|
|
|
|
107
|
|
|
|
|
|
|
This code is distributed under the Apache 2 License. The full text of the license can be found in the LICENSE file included with this module. |
|
108
|
|
|
|
|
|
|
|
|
109
|
|
|
|
|
|
|
=cut |