pg-aws_rds_iam 0.4.0 → 0.4.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.github/workflows/{pull-request.yml → ci.yml} +21 -53
- data/.rubocop.yml +2 -0
- data/.ruby-version +1 -1
- data/CHANGELOG.md +17 -2
- data/Gemfile.lock +33 -31
- data/README.md +1 -1
- data/bin/version-matrix +19 -3
- data/lib/pg/aws_rds_iam/active_record_postgresql_database_tasks/psql_env.rb +15 -0
- data/lib/pg/aws_rds_iam/active_record_postgresql_database_tasks/set_psql_env.rb +15 -0
- data/lib/pg/aws_rds_iam/active_record_postgresql_database_tasks.rb +16 -0
- data/lib/pg/aws_rds_iam/auth_token_injector.rb +20 -19
- data/lib/pg/aws_rds_iam/connection.rb +2 -2
- data/lib/pg/aws_rds_iam/connection_info/active_record_configuration_hash.rb +29 -0
- data/lib/pg/aws_rds_iam/connection_info/uri.rb +3 -1
- data/lib/pg/aws_rds_iam/connection_info.rb +6 -1
- data/lib/pg/aws_rds_iam/version.rb +1 -1
- data/lib/pg/aws_rds_iam.rb +6 -0
- metadata +9 -5
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: e30706e0bd824304eea8f942c41a9a4b7d9ef3d1de045bb5e584c0dd59c0e820
|
4
|
+
data.tar.gz: fa2c711695830b43c1a1e58722f69f7e27fb57c9514d572ff300e68c0e9000cd
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 0b6e875a21ec9d67ca170ba07236ed9482679f61ffd79cd2df888814b5a463bb72ce9f908d0e44c425ca3dbd5fe258415af9598e265c28cbbdbf6358b33a6d23
|
7
|
+
data.tar.gz: 674a9f7bfa03cfb3b6b8200ee60de00b0cdaa79dae92827f38242ba33042ee6323c3597863b9ca4ce7834d14e6f6daab339696029a1de3284c648b66cf87157a
|
@@ -1,31 +1,24 @@
|
|
1
|
-
name:
|
1
|
+
name: CI
|
2
2
|
|
3
|
-
on:
|
4
|
-
- pull_request
|
3
|
+
on: pull_request
|
5
4
|
|
6
5
|
jobs:
|
7
|
-
|
8
|
-
name:
|
6
|
+
lint:
|
7
|
+
name: Lint
|
9
8
|
|
10
9
|
runs-on: ubuntu-latest
|
11
10
|
|
12
|
-
container:
|
13
|
-
image: ruby:alpine
|
14
|
-
|
15
11
|
steps:
|
16
|
-
- name: Install dependencies
|
17
|
-
run: apk add git
|
18
|
-
|
19
12
|
- name: Check out source code
|
20
13
|
uses: actions/checkout@v3
|
21
14
|
|
22
|
-
- name: Install
|
23
|
-
|
15
|
+
- name: Install Ruby and gems
|
16
|
+
uses: ruby/setup-ruby@v1
|
17
|
+
with:
|
18
|
+
bundler-cache: true
|
24
19
|
|
25
|
-
- name:
|
26
|
-
run: bin/
|
27
|
-
env:
|
28
|
-
BUNDLE_FROZEN: true
|
20
|
+
- name: Run RuboCop
|
21
|
+
run: bin/rake rubocop
|
29
22
|
|
30
23
|
version-matrix:
|
31
24
|
name: Generate version matrix
|
@@ -36,9 +29,6 @@ jobs:
|
|
36
29
|
matrix: ${{ steps.version-matrix.outputs.matrix }}
|
37
30
|
|
38
31
|
steps:
|
39
|
-
- name: Check if secrets are available
|
40
|
-
run: test -n "${{ secrets.AVAILABLE }}"
|
41
|
-
|
42
32
|
- name: Check out source code
|
43
33
|
uses: actions/checkout@v3
|
44
34
|
|
@@ -56,53 +46,28 @@ jobs:
|
|
56
46
|
|
57
47
|
runs-on: ubuntu-latest
|
58
48
|
|
59
|
-
container:
|
60
|
-
image: ruby:${{ matrix.ruby }}-alpine
|
61
|
-
|
62
49
|
env:
|
63
50
|
BUNDLE_PATH: ${{ github.workspace }}/vendor/bundle
|
64
51
|
ACTIVERECORD_VERSION: ${{ matrix.activerecord }}
|
65
52
|
PG_VERSION: ${{ matrix.pg }}
|
66
53
|
|
67
54
|
steps:
|
68
|
-
- name: Install dependencies
|
69
|
-
run: apk add build-base git postgresql-dev tar
|
70
|
-
|
71
55
|
- name: Check out source code
|
72
56
|
uses: actions/checkout@v3
|
73
57
|
|
74
|
-
- name: Install
|
75
|
-
|
58
|
+
- name: Install Ruby
|
59
|
+
uses: ruby/setup-ruby@v1
|
60
|
+
with:
|
61
|
+
ruby-version: ${{ matrix.ruby }}
|
76
62
|
|
77
63
|
- name: Update Gemfile.lock
|
78
64
|
run: bin/bundle lock --update activerecord pg
|
79
65
|
|
80
|
-
- name: Compute cache key
|
81
|
-
id: cache-key
|
82
|
-
run: |
|
83
|
-
source /etc/os-release
|
84
|
-
postgresql_version=$(apk info --installed postgresql-dev --verbose)
|
85
|
-
printf \
|
86
|
-
"::set-output name=cache-key::alpine-%s-ruby-%s-%s\n" \
|
87
|
-
"${VERSION_ID}" \
|
88
|
-
"${RUBY_VERSION}" \
|
89
|
-
"${postgresql_version}"
|
90
|
-
|
91
|
-
- name: Cache gems
|
92
|
-
uses: actions/cache@v3
|
93
|
-
with:
|
94
|
-
key: ${{ steps.cache-key.outputs.cache-key }}-gems-${{ hashFiles('Gemfile.lock') }}
|
95
|
-
path: vendor/bundle
|
96
|
-
|
97
66
|
- name: Install gems
|
98
|
-
|
99
|
-
|
100
|
-
|
101
|
-
|
102
|
-
BUNDLE_RETRY: 3
|
103
|
-
|
104
|
-
- name: Run RuboCop
|
105
|
-
run: bin/rake rubocop
|
67
|
+
uses: ruby/setup-ruby@v1
|
68
|
+
with:
|
69
|
+
ruby-version: ${{ matrix.ruby }}
|
70
|
+
bundler-cache: true
|
106
71
|
|
107
72
|
- name: Run unit tests
|
108
73
|
run: bin/rake test:unit
|
@@ -117,9 +82,12 @@ jobs:
|
|
117
82
|
SECURITY_GROUP_ID: ${{ secrets.SECURITY_GROUP_ID }}
|
118
83
|
|
119
84
|
test-results:
|
85
|
+
name: Check test results
|
86
|
+
|
120
87
|
if: always()
|
121
88
|
|
122
89
|
needs:
|
90
|
+
- version-matrix
|
123
91
|
- test
|
124
92
|
|
125
93
|
runs-on: ubuntu-latest
|
data/.rubocop.yml
CHANGED
@@ -31,6 +31,8 @@ Naming/VariableNumber:
|
|
31
31
|
|
32
32
|
Style/Documentation:
|
33
33
|
Exclude:
|
34
|
+
- lib/pg/aws_rds_iam/active_record_postgresql_database_tasks.rb
|
35
|
+
- lib/pg/aws_rds_iam/active_record_postgresql_database_tasks/**/*.rb
|
34
36
|
- lib/pg/aws_rds_iam/auth_token_injector.rb
|
35
37
|
- lib/pg/aws_rds_iam/connection_info.rb
|
36
38
|
- lib/pg/aws_rds_iam/connection_info/**/*.rb
|
data/.ruby-version
CHANGED
@@ -1 +1 @@
|
|
1
|
-
ruby-3.
|
1
|
+
ruby-3.2.0
|
data/CHANGELOG.md
CHANGED
@@ -8,11 +8,24 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
|
|
8
8
|
|
9
9
|
No notable changes.
|
10
10
|
|
11
|
+
## [0.4.2] - 2023-01-10
|
12
|
+
|
13
|
+
### Changed
|
14
|
+
* Test against Ruby 3.2 ([#442](https://github.com/haines/pg-aws_rds_iam/pull/442))
|
15
|
+
|
16
|
+
### Fixed
|
17
|
+
* Handle empty host in connection URIs ([#442](https://github.com/haines/pg-aws_rds_iam/pull/442))
|
18
|
+
|
19
|
+
## [0.4.1] - 2022-07-20
|
20
|
+
|
21
|
+
### Fixed
|
22
|
+
* Generate auth token for Active Record structure load ([#374](https://github.com/haines/pg-aws_rds_iam/pull/374))
|
23
|
+
|
11
24
|
## [0.4.0] - 2022-06-22
|
12
25
|
|
13
26
|
### Changed
|
14
27
|
* Test against Ruby 3.1 ([#305](https://github.com/haines/pg-aws_rds_iam/pull/305))
|
15
|
-
* Require Ruby ≥ 2.
|
28
|
+
* Require Ruby ≥ 2.7 and Active Record ≥ 6.0 ([#360](https://github.com/haines/pg-aws_rds_iam/pull/360))
|
16
29
|
|
17
30
|
### Fixed
|
18
31
|
* Compatibility with `pg` ≥ 1.4 ([#356](https://github.com/haines/pg-aws_rds_iam/pull/356))
|
@@ -52,7 +65,9 @@ No notable changes.
|
|
52
65
|
* A plugin for the [`pg` gem](https://rubygems.org/gems/pg) that adds support for [IAM authentication](https://docs.aws.amazon.com/AmazonRDS/latest/UserGuide/UsingWithRDS.IAMDBAuth.html) when connecting to PostgreSQL databases hosted in Amazon RDS. ([#1](https://github.com/haines/pg-aws_rds_iam/pull/1))
|
53
66
|
* ActiveRecord support. ([#3](https://github.com/haines/pg-aws_rds_iam/pull/3))
|
54
67
|
|
55
|
-
[Unreleased]: https://github.com/haines/pg-aws_rds_iam/compare/v0.4.
|
68
|
+
[Unreleased]: https://github.com/haines/pg-aws_rds_iam/compare/v0.4.2...HEAD
|
69
|
+
[0.4.2]: https://github.com/haines/pg-aws_rds_iam/compare/v0.4.1...v0.4.2
|
70
|
+
[0.4.1]: https://github.com/haines/pg-aws_rds_iam/compare/v0.4.0...v0.4.1
|
56
71
|
[0.4.0]: https://github.com/haines/pg-aws_rds_iam/compare/v0.3.2...v0.4.0
|
57
72
|
[0.3.2]: https://github.com/haines/pg-aws_rds_iam/compare/v0.3.1...v0.3.2
|
58
73
|
[0.3.1]: https://github.com/haines/pg-aws_rds_iam/compare/v0.3.0...v0.3.1
|
data/Gemfile.lock
CHANGED
@@ -1,19 +1,19 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
pg-aws_rds_iam (0.4.
|
4
|
+
pg-aws_rds_iam (0.4.2)
|
5
5
|
aws-sdk-rds (~> 1.0)
|
6
6
|
pg (>= 0.18, < 2.0)
|
7
7
|
|
8
8
|
GEM
|
9
9
|
remote: https://rubygems.org/
|
10
10
|
specs:
|
11
|
-
activemodel (7.0.3)
|
12
|
-
activesupport (= 7.0.3)
|
13
|
-
activerecord (7.0.3)
|
14
|
-
activemodel (= 7.0.3)
|
15
|
-
activesupport (= 7.0.3)
|
16
|
-
activesupport (7.0.3)
|
11
|
+
activemodel (7.0.3.1)
|
12
|
+
activesupport (= 7.0.3.1)
|
13
|
+
activerecord (7.0.3.1)
|
14
|
+
activemodel (= 7.0.3.1)
|
15
|
+
activesupport (= 7.0.3.1)
|
16
|
+
activesupport (7.0.3.1)
|
17
17
|
concurrent-ruby (~> 1.0, >= 1.0.2)
|
18
18
|
i18n (>= 1.6, < 2)
|
19
19
|
minitest (>= 5.1)
|
@@ -21,65 +21,67 @@ GEM
|
|
21
21
|
ansi (1.5.0)
|
22
22
|
ast (2.4.2)
|
23
23
|
aws-eventstream (1.2.0)
|
24
|
-
aws-partitions (1.
|
25
|
-
aws-sdk-core (3.
|
24
|
+
aws-partitions (1.689.0)
|
25
|
+
aws-sdk-core (3.168.4)
|
26
26
|
aws-eventstream (~> 1, >= 1.0.2)
|
27
|
-
aws-partitions (~> 1, >= 1.
|
28
|
-
aws-sigv4 (~> 1.
|
27
|
+
aws-partitions (~> 1, >= 1.651.0)
|
28
|
+
aws-sigv4 (~> 1.5)
|
29
29
|
jmespath (~> 1, >= 1.6.1)
|
30
|
-
aws-sdk-ec2 (1.
|
31
|
-
aws-sdk-core (~> 3, >= 3.
|
30
|
+
aws-sdk-ec2 (1.356.0)
|
31
|
+
aws-sdk-core (~> 3, >= 3.165.0)
|
32
32
|
aws-sigv4 (~> 1.1)
|
33
|
-
aws-sdk-rds (1.
|
34
|
-
aws-sdk-core (~> 3, >= 3.
|
33
|
+
aws-sdk-rds (1.169.0)
|
34
|
+
aws-sdk-core (~> 3, >= 3.165.0)
|
35
35
|
aws-sigv4 (~> 1.1)
|
36
|
-
aws-sigv4 (1.5.
|
36
|
+
aws-sigv4 (1.5.2)
|
37
37
|
aws-eventstream (~> 1, >= 1.0.2)
|
38
38
|
builder (3.2.4)
|
39
39
|
coderay (1.1.3)
|
40
|
-
commonmarker (0.23.
|
40
|
+
commonmarker (0.23.6)
|
41
41
|
concurrent-ruby (1.1.10)
|
42
|
-
i18n (1.
|
42
|
+
i18n (1.11.0)
|
43
43
|
concurrent-ruby (~> 1.0)
|
44
|
-
jmespath (1.6.
|
44
|
+
jmespath (1.6.2)
|
45
|
+
json (2.6.3)
|
45
46
|
method_source (1.0.0)
|
46
|
-
minitest (5.
|
47
|
+
minitest (5.17.0)
|
47
48
|
minitest-reporters (1.5.0)
|
48
49
|
ansi
|
49
50
|
builder
|
50
51
|
minitest (>= 5.0)
|
51
52
|
ruby-progressbar
|
52
53
|
parallel (1.22.1)
|
53
|
-
parser (3.1.
|
54
|
+
parser (3.1.3.0)
|
54
55
|
ast (~> 2.4.1)
|
55
|
-
pg (1.4.
|
56
|
+
pg (1.4.5)
|
56
57
|
pry (0.14.1)
|
57
58
|
coderay (~> 1.1)
|
58
59
|
method_source (~> 1.0)
|
59
60
|
rainbow (3.1.1)
|
60
61
|
rake (13.0.6)
|
61
|
-
regexp_parser (2.
|
62
|
+
regexp_parser (2.6.1)
|
62
63
|
rexml (3.2.5)
|
63
|
-
rubocop (1.
|
64
|
+
rubocop (1.42.0)
|
65
|
+
json (~> 2.3)
|
64
66
|
parallel (~> 1.10)
|
65
|
-
parser (>= 3.1.
|
67
|
+
parser (>= 3.1.2.1)
|
66
68
|
rainbow (>= 2.2.2, < 4.0)
|
67
69
|
regexp_parser (>= 1.8, < 3.0)
|
68
70
|
rexml (>= 3.2.5, < 4.0)
|
69
|
-
rubocop-ast (>= 1.
|
71
|
+
rubocop-ast (>= 1.24.1, < 2.0)
|
70
72
|
ruby-progressbar (~> 1.7)
|
71
73
|
unicode-display_width (>= 1.4.0, < 3.0)
|
72
|
-
rubocop-ast (1.
|
74
|
+
rubocop-ast (1.24.1)
|
73
75
|
parser (>= 3.1.1.0)
|
74
|
-
rubocop-minitest (0.
|
76
|
+
rubocop-minitest (0.25.1)
|
75
77
|
rubocop (>= 0.90, < 2.0)
|
76
78
|
rubocop-rake (0.6.0)
|
77
79
|
rubocop (~> 1.0)
|
78
80
|
ruby-progressbar (1.11.0)
|
79
|
-
timecop (0.9.
|
81
|
+
timecop (0.9.6)
|
80
82
|
tzinfo (2.0.4)
|
81
83
|
concurrent-ruby (~> 1.0)
|
82
|
-
unicode-display_width (2.
|
84
|
+
unicode-display_width (2.3.0)
|
83
85
|
webrick (1.7.0)
|
84
86
|
yard (0.9.28)
|
85
87
|
webrick (~> 1.7.0)
|
@@ -105,4 +107,4 @@ DEPENDENCIES
|
|
105
107
|
yard
|
106
108
|
|
107
109
|
BUNDLED WITH
|
108
|
-
2.3
|
110
|
+
2.4.3
|
data/README.md
CHANGED
@@ -2,7 +2,7 @@
|
|
2
2
|
|
3
3
|
[![Gem](https://img.shields.io/gem/v/pg-aws_rds_iam?style=flat-square)](https://rubygems.org/gems/pg-aws_rds_iam)
|
4
4
|
 
|
5
|
-
[![Docs](https://img.shields.io/badge/yard-docs-blue?style=flat-square)](https://
|
5
|
+
[![Docs](https://img.shields.io/badge/yard-docs-blue?style=flat-square)](https://www.rubydoc.info/gems/pg-aws_rds_iam)
|
6
6
|
|
7
7
|
`PG::AWS_RDS_IAM` is a plugin for the [`pg` gem](https://rubygems.org/gems/pg) that adds support for [IAM authentication](https://docs.aws.amazon.com/AmazonRDS/latest/UserGuide/UsingWithRDS.IAMDBAuth.html) when connecting to PostgreSQL databases hosted in Amazon RDS.
|
8
8
|
|
data/bin/version-matrix
CHANGED
@@ -11,7 +11,15 @@ end
|
|
11
11
|
ruby_activerecord_requirements = {
|
12
12
|
"2.7" => ">= 6.0",
|
13
13
|
"3.0" => ">= 6.0",
|
14
|
-
"3.1" => ">= 6.0"
|
14
|
+
"3.1" => ">= 6.0",
|
15
|
+
"3.2" => ">= 6.0"
|
16
|
+
}
|
17
|
+
|
18
|
+
ruby_pg_requirements = {
|
19
|
+
"2.7" => "> 0",
|
20
|
+
"3.0" => "> 0",
|
21
|
+
"3.1" => "> 0",
|
22
|
+
"3.2" => ">= 1.3"
|
15
23
|
}
|
16
24
|
|
17
25
|
activerecord_pg_requirements = {
|
@@ -22,7 +30,12 @@ activerecord_pg_requirements = {
|
|
22
30
|
|
23
31
|
versions = ruby_activerecord_requirements.flat_map do |ruby_version, activerecord_requirement|
|
24
32
|
minor_versions("activerecord", activerecord_requirement).flat_map do |activerecord_version|
|
25
|
-
|
33
|
+
pg_requirement = [
|
34
|
+
ruby_pg_requirements.fetch(ruby_version),
|
35
|
+
activerecord_pg_requirements.fetch(activerecord_version)
|
36
|
+
].flatten
|
37
|
+
|
38
|
+
minor_versions("pg", pg_requirement).map do |pg_version|
|
26
39
|
{
|
27
40
|
ruby: ruby_version,
|
28
41
|
activerecord: activerecord_version,
|
@@ -34,4 +47,7 @@ end
|
|
34
47
|
|
35
48
|
matrix = { include: versions }
|
36
49
|
|
37
|
-
puts
|
50
|
+
puts JSON.pretty_generate(matrix)
|
51
|
+
|
52
|
+
output_file = ENV.fetch("GITHUB_OUTPUT", false)
|
53
|
+
File.write output_file, "matrix=#{matrix.to_json}" if output_file
|
@@ -0,0 +1,15 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module PG
|
4
|
+
module AWS_RDS_IAM
|
5
|
+
module ActiveRecordPostgreSQLDatabaseTasks
|
6
|
+
private
|
7
|
+
|
8
|
+
def psql_env
|
9
|
+
super.tap do |psql_env|
|
10
|
+
AuthTokenInjector.new.inject_into_psql_env! configuration_hash, psql_env
|
11
|
+
end
|
12
|
+
end
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
@@ -0,0 +1,15 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module PG
|
4
|
+
module AWS_RDS_IAM
|
5
|
+
module ActiveRecordPostgreSQLDatabaseTasks
|
6
|
+
private
|
7
|
+
|
8
|
+
def set_psql_env
|
9
|
+
super
|
10
|
+
hash = respond_to?(:configuration_hash, true) ? configuration_hash : configuration.symbolize_keys
|
11
|
+
AuthTokenInjector.new.inject_into_psql_env! hash, ENV
|
12
|
+
end
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
@@ -0,0 +1,16 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module PG
|
4
|
+
module AWS_RDS_IAM
|
5
|
+
module ActiveRecordPostgreSQLDatabaseTasks
|
6
|
+
end
|
7
|
+
|
8
|
+
private_constant :ActiveRecordPostgreSQLDatabaseTasks
|
9
|
+
end
|
10
|
+
end
|
11
|
+
|
12
|
+
if ActiveRecord::Tasks::PostgreSQLDatabaseTasks.private_instance_methods.include?(:psql_env)
|
13
|
+
require_relative "active_record_postgresql_database_tasks/psql_env"
|
14
|
+
else
|
15
|
+
require_relative "active_record_postgresql_database_tasks/set_psql_env"
|
16
|
+
end
|
@@ -3,38 +3,39 @@
|
|
3
3
|
module PG
|
4
4
|
module AWS_RDS_IAM
|
5
5
|
class AuthTokenInjector
|
6
|
-
def
|
7
|
-
new(connection_string, auth_token_generators: auth_token_generators).call
|
8
|
-
end
|
9
|
-
|
10
|
-
def initialize(connection_string, auth_token_generators:)
|
11
|
-
@connection_string = connection_string
|
12
|
-
@connection_info = ConnectionInfo.new(connection_string)
|
13
|
-
@connection_defaults = PG::Connection.conndefaults_hash
|
6
|
+
def initialize(auth_token_generators: AWS_RDS_IAM.auth_token_generators)
|
14
7
|
@auth_token_generators = auth_token_generators
|
8
|
+
@connection_defaults = PG::Connection.conndefaults_hash
|
15
9
|
end
|
16
10
|
|
17
|
-
def
|
18
|
-
|
11
|
+
def inject_into_connection_string(connection_string)
|
12
|
+
connection_info = ConnectionInfo.from_connection_string(connection_string)
|
13
|
+
return connection_string unless generate_auth_token?(connection_info)
|
14
|
+
|
15
|
+
connection_info.password = generate_auth_token(connection_info)
|
16
|
+
connection_info.to_s
|
17
|
+
end
|
19
18
|
|
20
|
-
|
19
|
+
def inject_into_psql_env!(configuration_hash, psql_env)
|
20
|
+
connection_info = ConnectionInfo.from_active_record_configuration_hash(configuration_hash)
|
21
|
+
return unless generate_auth_token?(connection_info)
|
21
22
|
|
22
|
-
|
23
|
+
psql_env["PGPASSWORD"] = generate_auth_token(connection_info)
|
23
24
|
end
|
24
25
|
|
25
26
|
private
|
26
27
|
|
27
|
-
def generate_auth_token?
|
28
|
-
|
28
|
+
def generate_auth_token?(connection_info)
|
29
|
+
connection_info.auth_token_generator_name
|
29
30
|
end
|
30
31
|
|
31
|
-
def generate_auth_token
|
32
|
+
def generate_auth_token(connection_info)
|
32
33
|
@auth_token_generators
|
33
|
-
.fetch(
|
34
|
+
.fetch(connection_info.auth_token_generator_name)
|
34
35
|
.call(
|
35
|
-
user:
|
36
|
-
host:
|
37
|
-
port:
|
36
|
+
user: connection_info.user || default(:user),
|
37
|
+
host: connection_info.host || default(:host),
|
38
|
+
port: connection_info.port || default(:port)
|
38
39
|
)
|
39
40
|
end
|
40
41
|
|
@@ -8,7 +8,7 @@ module PG
|
|
8
8
|
end
|
9
9
|
|
10
10
|
def conninfo_parse(connection_string)
|
11
|
-
connection_info = ConnectionInfo.
|
11
|
+
connection_info = ConnectionInfo.from_connection_string(connection_string)
|
12
12
|
|
13
13
|
super(connection_info.to_s).tap do |result|
|
14
14
|
result << conndefault_aws_rds_iam_auth_token_generator.merge(val: connection_info.auth_token_generator_name) if connection_info.auth_token_generator_name
|
@@ -16,7 +16,7 @@ module PG
|
|
16
16
|
end
|
17
17
|
|
18
18
|
def parse_connect_args(*args)
|
19
|
-
AuthTokenInjector.
|
19
|
+
AuthTokenInjector.new.inject_into_connection_string(super)
|
20
20
|
end
|
21
21
|
|
22
22
|
private
|
@@ -0,0 +1,29 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module PG
|
4
|
+
module AWS_RDS_IAM
|
5
|
+
module ConnectionInfo
|
6
|
+
class ActiveRecordConfigurationHash
|
7
|
+
def initialize(configuration_hash)
|
8
|
+
@configuration_hash = configuration_hash
|
9
|
+
end
|
10
|
+
|
11
|
+
def auth_token_generator_name
|
12
|
+
@configuration_hash[:aws_rds_iam_auth_token_generator]
|
13
|
+
end
|
14
|
+
|
15
|
+
def user
|
16
|
+
@configuration_hash[:username]
|
17
|
+
end
|
18
|
+
|
19
|
+
def host
|
20
|
+
@configuration_hash[:host]
|
21
|
+
end
|
22
|
+
|
23
|
+
def port
|
24
|
+
@configuration_hash[:port]
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
@@ -1,5 +1,6 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
+
require_relative "connection_info/active_record_configuration_hash"
|
3
4
|
require_relative "connection_info/keyword_value_string"
|
4
5
|
require_relative "connection_info/parse_error"
|
5
6
|
require_relative "connection_info/uri"
|
@@ -7,13 +8,17 @@ require_relative "connection_info/uri"
|
|
7
8
|
module PG
|
8
9
|
module AWS_RDS_IAM
|
9
10
|
module ConnectionInfo
|
10
|
-
def self.
|
11
|
+
def self.from_connection_string(connection_string)
|
11
12
|
if URI.match?(connection_string)
|
12
13
|
URI.new(connection_string)
|
13
14
|
else
|
14
15
|
KeywordValueString.new(connection_string)
|
15
16
|
end
|
16
17
|
end
|
18
|
+
|
19
|
+
def self.from_active_record_configuration_hash(configuration_hash)
|
20
|
+
ActiveRecordConfigurationHash.new(configuration_hash)
|
21
|
+
end
|
17
22
|
end
|
18
23
|
|
19
24
|
private_constant :ConnectionInfo
|
data/lib/pg/aws_rds_iam.rb
CHANGED
@@ -26,5 +26,11 @@ module PG
|
|
26
26
|
end
|
27
27
|
|
28
28
|
PG::Connection.singleton_class.prepend Connection
|
29
|
+
|
30
|
+
if defined?(ActiveRecord)
|
31
|
+
require_relative "aws_rds_iam/active_record_postgresql_database_tasks"
|
32
|
+
|
33
|
+
ActiveRecord::Tasks::PostgreSQLDatabaseTasks.prepend ActiveRecordPostgreSQLDatabaseTasks
|
34
|
+
end
|
29
35
|
end
|
30
36
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: pg-aws_rds_iam
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.4.
|
4
|
+
version: 0.4.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Andrew Haines
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2023-01-10 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: aws-sdk-rds
|
@@ -53,7 +53,7 @@ extensions: []
|
|
53
53
|
extra_rdoc_files: []
|
54
54
|
files:
|
55
55
|
- ".github/dependabot.yml"
|
56
|
-
- ".github/workflows/
|
56
|
+
- ".github/workflows/ci.yml"
|
57
57
|
- ".gitignore"
|
58
58
|
- ".rubocop.yml"
|
59
59
|
- ".ruby-version"
|
@@ -74,11 +74,15 @@ files:
|
|
74
74
|
- bin/version-matrix
|
75
75
|
- bin/yard
|
76
76
|
- lib/pg/aws_rds_iam.rb
|
77
|
+
- lib/pg/aws_rds_iam/active_record_postgresql_database_tasks.rb
|
78
|
+
- lib/pg/aws_rds_iam/active_record_postgresql_database_tasks/psql_env.rb
|
79
|
+
- lib/pg/aws_rds_iam/active_record_postgresql_database_tasks/set_psql_env.rb
|
77
80
|
- lib/pg/aws_rds_iam/auth_token_generator.rb
|
78
81
|
- lib/pg/aws_rds_iam/auth_token_generator_registry.rb
|
79
82
|
- lib/pg/aws_rds_iam/auth_token_injector.rb
|
80
83
|
- lib/pg/aws_rds_iam/connection.rb
|
81
84
|
- lib/pg/aws_rds_iam/connection_info.rb
|
85
|
+
- lib/pg/aws_rds_iam/connection_info/active_record_configuration_hash.rb
|
82
86
|
- lib/pg/aws_rds_iam/connection_info/keyword_value_string.rb
|
83
87
|
- lib/pg/aws_rds_iam/connection_info/parse_error.rb
|
84
88
|
- lib/pg/aws_rds_iam/connection_info/uri.rb
|
@@ -90,7 +94,7 @@ licenses:
|
|
90
94
|
metadata:
|
91
95
|
bug_tracker_uri: https://github.com/haines/pg-aws_rds_iam/issues
|
92
96
|
changelog_uri: https://github.com/haines/pg-aws_rds_iam/blob/main/CHANGELOG.md
|
93
|
-
documentation_uri: https://rubydoc.info/gems/pg-aws_rds_iam/0.4.
|
97
|
+
documentation_uri: https://rubydoc.info/gems/pg-aws_rds_iam/0.4.2
|
94
98
|
homepage_uri: https://github.com/haines/pg-aws_rds_iam
|
95
99
|
source_code_uri: https://github.com/haines/pg-aws_rds_iam
|
96
100
|
rubygems_mfa_required: 'true'
|
@@ -109,7 +113,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
109
113
|
- !ruby/object:Gem::Version
|
110
114
|
version: '0'
|
111
115
|
requirements: []
|
112
|
-
rubygems_version: 3.3
|
116
|
+
rubygems_version: 3.4.3
|
113
117
|
signing_key:
|
114
118
|
specification_version: 4
|
115
119
|
summary: IAM authentication for PostgreSQL on Amazon RDS
|