googleauth_aws_container_credential_provider 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: 1463d43d86ed2912c00496309df7f77584064a858bb4fcd910b093151101974f
4
+ data.tar.gz: 3dd2357adf9a5e8ff4e2f96d16913051c28e5ff9d19a0060925489485e3b4ca3
5
+ SHA512:
6
+ metadata.gz: 6260a19409e1990e8bdb993ffa11679eb4501b3428ea2a95cf3f83ff508239b12f9e973136f4ded6879036be84eb6690653c981112c67967525f96fab5cedcfb
7
+ data.tar.gz: ef8c2450f41115c99cd3e37dd3992024ec5a1b48bb41ed3d0d3eaf4d58df529a9c6c9e7eb72efbf6e0a7fa3f7c001e25d70b513277fc32ce2ecf2142d07be69f
data/.rspec ADDED
@@ -0,0 +1,3 @@
1
+ --format documentation
2
+ --color
3
+ --require spec_helper
data/.rubocop.yml ADDED
@@ -0,0 +1,21 @@
1
+ AllCops:
2
+ TargetRubyVersion: 2.6
3
+ SuggestExtensions: false
4
+ NewCops: disable
5
+
6
+ Style/StringLiterals:
7
+ Enabled: true
8
+ EnforcedStyle: double_quotes
9
+
10
+ Style/StringLiteralsInInterpolation:
11
+ Enabled: true
12
+ EnforcedStyle: double_quotes
13
+
14
+ Layout/LineLength:
15
+ Max: 120
16
+
17
+ Style/Documentation:
18
+ Enabled: false
19
+
20
+ Metrics:
21
+ Enabled: false
data/CHANGELOG.md ADDED
@@ -0,0 +1,5 @@
1
+ # Release History
2
+
3
+ ### 0.1.0 (2023-03-22)
4
+
5
+ * Initial release.
data/Gemfile ADDED
@@ -0,0 +1,9 @@
1
+ # frozen_string_literal: true
2
+
3
+ source "https://rubygems.org"
4
+
5
+ gemspec
6
+
7
+ gem "rake", "~> 13.0"
8
+ gem "rspec", "~> 3.0"
9
+ gem "rubocop", "~> 1.21"
data/LICENSE.txt ADDED
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2023 Tomoki Sekiyama
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in
13
+ all copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21
+ THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,31 @@
1
+ # GoogleAuthAWSContainerCredentialProvider
2
+
3
+ [The googleauth gem](https://rubygems.org/gems/googleauth) supports AWS Workload Identity,
4
+ but it cannot handle container credentials provided by ECS, CodeBuild and so on, which is
5
+ passed via the AWS_CONTAINER_CREDENTIALS_RELATIVE_URI environmental variable.
6
+ This gem enables it to use the container credential provider.
7
+
8
+ ## Usage
9
+
10
+ Adding the following the require statement will patch the googleauth to
11
+ make it fetch the container credentials when
12
+ `AWS_CONTAINER_CREDENTIALS_RELATIVE_URI` or `AWS_CONTAINER_CREDENTIALS_FULL_URI`
13
+ environmental variable is defined.
14
+
15
+ ```
16
+ require 'googleauth_aws_container_credential_provider'
17
+ ```
18
+
19
+ ## Development
20
+
21
+ After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake spec` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
22
+
23
+ To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and the created tag, and push the `.gem` file to [rubygems.org](https://rubygems.org).
24
+
25
+ ## Contributing
26
+
27
+ Bug reports and pull requests are welcome on GitHub at https://github.com/aktsk/googleauth_aws_container_credential_provider.
28
+
29
+ ## License
30
+
31
+ The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
data/Rakefile ADDED
@@ -0,0 +1,12 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "bundler/gem_tasks"
4
+ require "rspec/core/rake_task"
5
+
6
+ RSpec::Core::RakeTask.new(:spec)
7
+
8
+ require "rubocop/rake_task"
9
+
10
+ RuboCop::RakeTask.new
11
+
12
+ task default: %i[spec rubocop]
@@ -0,0 +1,30 @@
1
+ # frozen_string_literal: true
2
+
3
+ require_relative "lib/googleauth_aws_container_credential_provider/version"
4
+
5
+ Gem::Specification.new do |spec|
6
+ spec.name = "googleauth_aws_container_credential_provider"
7
+ spec.version = GoogleAuthAWSContainerCredentialProvider::VERSION
8
+ spec.authors = ["Tomoki Sekiyama"]
9
+ spec.email = ["tomoki.sekiyama@aktsk.jp"]
10
+
11
+ spec.summary = "Enable googleauth gem to use container credentials provided by ECS, CodeBuild, and so on."
12
+ spec.description = "The googleauth gem supports AWS Workload Identity, but it cannot handle container " \
13
+ "credentials provided by ECS etc. via AWS_CONTAINER_CREDENTIALS_RELATIVE_URI. " \
14
+ "This gem enables it to use the container credential provider."
15
+ spec.homepage = "https://github.com/aktsk/googleauth_aws_container_credential_provider"
16
+ spec.license = "MIT"
17
+ spec.required_ruby_version = ">= 2.6.0"
18
+
19
+ spec.metadata["source_code_uri"] = "https://github.com/aktsk/googleauth_aws_container_credential_provider"
20
+ spec.metadata["changelog_uri"] = "https://github.com/aktsk/googleauth_aws_container_credential_provider/CHANGELOG.md"
21
+
22
+ spec.files = Dir.chdir(__dir__) do
23
+ `git ls-files -z`.split("\x0").reject do |f|
24
+ (f == __FILE__) || f.match(%r{\A(?:(?:bin|test|spec|features)/|\.(?:git|circleci)|appveyor)})
25
+ end
26
+ end
27
+ spec.require_paths = ["lib"]
28
+
29
+ spec.add_dependency "googleauth", ">= 1.5"
30
+ end
@@ -0,0 +1,5 @@
1
+ # frozen_string_literal: true
2
+
3
+ module GoogleAuthAWSContainerCredentialProvider
4
+ VERSION = "0.1.0"
5
+ end
@@ -0,0 +1,39 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "googleauth"
4
+ require "time"
5
+ require "multi_json"
6
+
7
+ require_relative "googleauth_aws_container_credential_provider/version"
8
+
9
+ module GoogleAuthAWSContainerCredentialProvider
10
+ def fetch_security_credentials
11
+ url = if ENV["AWS_CONTAINER_CREDENTIALS_RELATIVE_URI"]
12
+ "http://169.254.170.2#{ENV["AWS_CONTAINER_CREDENTIALS_RELATIVE_URI"]}"
13
+ elsif ENV["AWS_CONTAINER_CREDENTIALS_FULL_URI"]
14
+ ENV["AWS_CONTAINER_CREDENTIALS_FULL_URI"]
15
+ end
16
+
17
+ if url
18
+ begin
19
+ response = connection.get url
20
+
21
+ raise Faraday::Error, "Status #{r.status}: #{response.body}" unless response.success?
22
+
23
+ credentials = MultiJson.load response.body
24
+
25
+ return {
26
+ access_key_id: credentials["AccessKeyId"],
27
+ secret_access_key: credentials["SecretAccessKey"],
28
+ session_token: credentials["Token"]
29
+ }
30
+ rescue Faraday::Error => e
31
+ warn "Failed to retrieve container credentials: #{e}"
32
+ end
33
+ end
34
+
35
+ super
36
+ end
37
+ end
38
+
39
+ Google::Auth::ExternalAccount::AwsCredentials.prepend(GoogleAuthAWSContainerCredentialProvider)
@@ -0,0 +1,4 @@
1
+ module GoogleAuthAWSContainerCredentialProvider
2
+ VERSION: String
3
+ # See the writing guide of rbs: https://github.com/ruby/rbs#guides
4
+ end
metadata ADDED
@@ -0,0 +1,73 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: googleauth_aws_container_credential_provider
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ platform: ruby
6
+ authors:
7
+ - Tomoki Sekiyama
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2023-03-22 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: googleauth
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - ">="
18
+ - !ruby/object:Gem::Version
19
+ version: '1.5'
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - ">="
25
+ - !ruby/object:Gem::Version
26
+ version: '1.5'
27
+ description: The googleauth gem supports AWS Workload Identity, but it cannot handle
28
+ container credentials provided by ECS etc. via AWS_CONTAINER_CREDENTIALS_RELATIVE_URI.
29
+ This gem enables it to use the container credential provider.
30
+ email:
31
+ - tomoki.sekiyama@aktsk.jp
32
+ executables: []
33
+ extensions: []
34
+ extra_rdoc_files: []
35
+ files:
36
+ - ".rspec"
37
+ - ".rubocop.yml"
38
+ - CHANGELOG.md
39
+ - Gemfile
40
+ - LICENSE.txt
41
+ - README.md
42
+ - Rakefile
43
+ - googleauth_aws_container_credential_provider.gemspec
44
+ - lib/googleauth_aws_container_credential_provider.rb
45
+ - lib/googleauth_aws_container_credential_provider/version.rb
46
+ - sig/googleauth_aws_container_credential_provider.rbs
47
+ homepage: https://github.com/aktsk/googleauth_aws_container_credential_provider
48
+ licenses:
49
+ - MIT
50
+ metadata:
51
+ source_code_uri: https://github.com/aktsk/googleauth_aws_container_credential_provider
52
+ changelog_uri: https://github.com/aktsk/googleauth_aws_container_credential_provider/CHANGELOG.md
53
+ post_install_message:
54
+ rdoc_options: []
55
+ require_paths:
56
+ - lib
57
+ required_ruby_version: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - ">="
60
+ - !ruby/object:Gem::Version
61
+ version: 2.6.0
62
+ required_rubygems_version: !ruby/object:Gem::Requirement
63
+ requirements:
64
+ - - ">="
65
+ - !ruby/object:Gem::Version
66
+ version: '0'
67
+ requirements: []
68
+ rubygems_version: 3.4.1
69
+ signing_key:
70
+ specification_version: 4
71
+ summary: Enable googleauth gem to use container credentials provided by ECS, CodeBuild,
72
+ and so on.
73
+ test_files: []