aws-google 0.1.5 → 0.1.6

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 0ea7ae0f33a7dafe59e62cb045d143ed0fdc0a0a017d3e2a17d380cf1f46a49e
4
- data.tar.gz: b5bc47171255473122de1cf179828f869a32cd7d6fb5cf5343d85204e7e96c26
3
+ metadata.gz: 00e6b5cf021f6b08503bc04f4359fa58028ebd227d0e12e66308af77f5613ba4
4
+ data.tar.gz: 971a4987281b9e2971574b590edba32a8522f061997cc20098ffa83e42216dac
5
5
  SHA512:
6
- metadata.gz: 7801674b5be60e16e4e32608162b5c79baa06b794ddc4c494f6c04a46b2ad630b6a0ef7d6a552ff9f56091a6f4079cd95942a28a8b35d1a337f7cf335d4a4ba3
7
- data.tar.gz: 405d08b37bb3167508fc705d458a9472067ddb53c4dcd02fc831a8c33155623c11c414d7bd2181d93a68a5cad0443cd325ea27451f416eeefd2d6e395e47a740
6
+ metadata.gz: 71812e0486feddadacbff23840630334a9fb29466427542c0da9d2fd36184e3694bea4681ac708c2822fcf43c2ce1829adc530311ede86523359a96c78519205
7
+ data.tar.gz: d14acf9b9493d55e4ef4b10465a17f6e9cda6fd0bdaef5886a757e078a434ccac9f3faef51689bdc037cb8b5828a947788f0f24640e18039f4365597d1a2805a
data/README.md CHANGED
@@ -48,21 +48,23 @@ your Google Client ID (`accounts.google.com:aud`) and a specific set of Google A
48
48
  }
49
49
  ```
50
50
 
51
- - In your Ruby code, construct an `Aws::Google` object by passing in the AWS role, client id and client secret:
51
+ - In your Ruby code, construct an `Aws::Google` object by passing the AWS `role_arn`, Google `client_id` and `client_secret`, either as constructor arguments or via the `Aws::Google.config` global defaults:
52
52
  ```ruby
53
53
  require 'aws/google'
54
54
 
55
- aws_role = 'arn:aws:iam::[AccountID]:role/[Role]'
56
- client_id = '123456789012-abcdefghijklmnopqrstuvwzyz0123456.apps.googleusercontent.com'
57
- client_secret = '01234567890abcdefghijklmn'
55
+ options = {
56
+ aws_role: 'arn:aws:iam::[AccountID]:role/[Role]',
57
+ client_id: '123456789012-abcdefghijklmnopqrstuvwzyz0123456.apps.googleusercontent.com',
58
+ client_secret: '01234567890abcdefghijklmn'
59
+ }
58
60
 
59
- role_credentials = Aws::Google.new(
60
- role_arn: aws_role,
61
- google_client_id: client_id,
62
- google_client_secret: client_secret
63
- )
61
+ # Pass constructor arguments:
62
+ credentials = Aws::Google.new(options)
63
+ puts Aws::STS::Client.new(credentials: credentials).get_caller_identity
64
64
 
65
- puts Aws::STS::Client.new(credentials: role_credentials).get_caller_identity
65
+ # Set global defaults:
66
+ Aws::Google.config = options
67
+ puts Aws::STS::Client.new.get_caller_identity
66
68
  ```
67
69
 
68
70
  - Or, add the properties to your AWS config profile ([`~/.aws/config`](https://docs.aws.amazon.com/cli/latest/userguide/cli-configure-files.html#cli-configure-files-where)) to use Google as the AWS credential provider without any changes to your application code:
@@ -27,8 +27,10 @@ module Aws
27
27
  include ::Aws::Google::CachedCredentials
28
28
 
29
29
  class << self
30
+ # Use `Aws::Google.config` to set default options for any instance of this provider.
30
31
  attr_accessor :config
31
32
  end
33
+ self.config = {}
32
34
 
33
35
  # @option options [required, String] :role_arn
34
36
  # @option options [String] :policy
@@ -43,6 +45,7 @@ module Aws
43
45
  # @option options [String] :client_id Google client ID
44
46
  # @option options [String] :client_secret Google client secret
45
47
  def initialize(options = {})
48
+ options = options.merge(self.class.config)
46
49
  @oauth_attempted = false
47
50
  @assume_role_params = options.slice(
48
51
  *Aws::STS::Client.api.operation(:assume_role_with_web_identity).
@@ -24,9 +24,11 @@ module Aws
24
24
  def google_credentials_from_config(opts = {})
25
25
  p = opts[:profile] || @profile_name
26
26
  if @config_enabled && @parsed_config
27
- entry = @parsed_config.fetch(p, {})
28
- if (google_opts = entry['google'])
29
- Google.new(google_opts.transform_keys(&:to_sym))
27
+ google_opts = @parsed_config.
28
+ fetch(p, {}).fetch('google', {}).
29
+ transform_keys(&:to_sym)
30
+ if google_opts.merge(::Aws::Google.config).has_key?(:role_arn)
31
+ Google.new(google_opts)
30
32
  end
31
33
  end
32
34
  end
@@ -1,5 +1,5 @@
1
1
  module Aws
2
2
  class Google
3
- VERSION = '0.1.5'.freeze
3
+ VERSION = '0.1.6'.freeze
4
4
  end
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: aws-google
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.5
4
+ version: 0.1.6
5
5
  platform: ruby
6
6
  authors:
7
7
  - Will Jordan
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2020-10-06 00:00:00.000000000 Z
11
+ date: 2020-10-08 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: aws-sdk-core