Sha256: abfa2734f6f7d11f53d611610e9d5ebe2cd14947f0ebff33e5fb7778e793416e

Contents?: true

Size: 741 Bytes

Versions: 9

Compression:

Stored size: 741 Bytes

Contents

# frozen_string_literal: true

require 'aws-sdk-core'
require 'awskeyring'

module Awskeyring
  # Provide a credential provider for use as a library, eg.
  #     require 'awskeyring/credential_provider'
  #     client = Aws::STS::Client.new(
  #       credentials: Awskeyring::CredentialProvider.new("company-acc")
  #     )
  class CredentialProvider
    include Aws::CredentialProvider

    attr_accessor :account

    def initialize(account)
      @account = account
    end

    # returns a new Aws::Credentials object
    def credentials
      cred = Awskeyring.get_valid_creds(account: account)
      Aws::Credentials.new(cred[:key],
                           cred[:secret],
                           cred[:token])
    end
  end
end

Version data entries

9 entries across 9 versions & 1 rubygems

Version Path
awskeyring-1.12.1 lib/awskeyring/credential_provider.rb
awskeyring-1.12.0 lib/awskeyring/credential_provider.rb
awskeyring-1.11.0 lib/awskeyring/credential_provider.rb
awskeyring-1.10.1 lib/awskeyring/credential_provider.rb
awskeyring-1.10.0 lib/awskeyring/credential_provider.rb
awskeyring-1.9.5 lib/awskeyring/credential_provider.rb
awskeyring-1.9.4 lib/awskeyring/credential_provider.rb
awskeyring-1.9.3 lib/awskeyring/credential_provider.rb
awskeyring-1.9.2 lib/awskeyring/credential_provider.rb