Sha256: 43894a653914a01698536b407db7e36aeb9c0891bea610f8902d5b7112c23d8c

Contents?: true

Size: 1.61 KB

Versions: 47

Compression:

Stored size: 1.61 KB

Contents

module Fog
  module AWS
    class STS
      class Real
        require 'fog/aws/parsers/sts/assume_role_with_web_identity'

        def assume_role_with_web_identity(role_arn, web_identity_token, role_session_name, options={})
          request_unsigned(
            'Action'          => 'AssumeRoleWithWebIdentity',
            'RoleArn'         => role_arn,
            'RoleSessionName' => role_session_name,
            'DurationSeconds' => options[:duration] || 3600,
            :idempotent       => true,
            :parser           => Fog::Parsers::AWS::STS::AssumeRoleWithWebIdentity.new
          )
        end
      end

      class Mock
        def assume_role_with_web_identity(role_arn, web_identity_token, role_session_name, options={})
          role = options[:iam].data[:roles].values.detect { |r| r[:arn] == role_arn }

          Excon::Response.new.tap do |response|
            response.body = {
              'AssumedRoleUser' => {
                'Arn'           => role[:arn],
                'AssumedRoleId' => role[:role_id]
              },
              'Audience'    => 'fog',
              'Credentials' => {
                'AccessKeyId'     => Fog::AWS::Mock.key_id(20),
                'Expiration'      => options[:expiration] || Time.now + 3600,
                'SecretAccessKey' => Fog::AWS::Mock.key_id(40),
                'SessionToken'    => Fog::Mock.random_hex(8)
              },
              'Provider'                    => 'fog',
              'SubjectFromWebIdentityToken' => Fog::Mock.random_hex(8)
            }
            response.status = 200
          end
        end
      end
    end
  end
end

Version data entries

47 entries across 45 versions & 3 rubygems

Version Path
fog-aws-3.5.2 lib/fog/aws/requests/sts/assume_role_with_web_identity.rb
fog-aws-3.5.1 lib/fog/aws/requests/sts/assume_role_with_web_identity.rb
fog-aws-3.5.0 lib/fog/aws/requests/sts/assume_role_with_web_identity.rb
fog-aws-3.4.0 lib/fog/aws/requests/sts/assume_role_with_web_identity.rb
fog-aws-3.3.0 lib/fog/aws/requests/sts/assume_role_with_web_identity.rb
fog-aws-3.2.0 lib/fog/aws/requests/sts/assume_role_with_web_identity.rb
fog-aws-3.1.0 lib/fog/aws/requests/sts/assume_role_with_web_identity.rb
vagrant-packet-0.1.1 vendor/bundle/ruby/2.3.0/gems/fog-aws-2.0.1/lib/fog/aws/requests/sts/assume_role_with_web_identity.rb
vagrant-packet-0.1.1 vendor/bundle/ruby/2.5.0/gems/fog-aws-2.0.1/lib/fog/aws/requests/sts/assume_role_with_web_identity.rb
vagrant-packet-0.1.1 vendor/bundle/ruby/2.4.0/gems/fog-aws-2.0.1/lib/fog/aws/requests/sts/assume_role_with_web_identity.rb
fog-aws-3.0.0 lib/fog/aws/requests/sts/assume_role_with_web_identity.rb
fog-aws-2.0.1 lib/fog/aws/requests/sts/assume_role_with_web_identity.rb
fog-aws-2.0.0 lib/fog/aws/requests/sts/assume_role_with_web_identity.rb
fog-aws-1.4.1 lib/fog/aws/requests/sts/assume_role_with_web_identity.rb
fog-aws-1.4.0 lib/fog/aws/requests/sts/assume_role_with_web_identity.rb
fog-aws-1.3.0 lib/fog/aws/requests/sts/assume_role_with_web_identity.rb
fog-aws-1.2.1 lib/fog/aws/requests/sts/assume_role_with_web_identity.rb
fog-aws-1.2.0 lib/fog/aws/requests/sts/assume_role_with_web_identity.rb
fog-aws-1.1.0 lib/fog/aws/requests/sts/assume_role_with_web_identity.rb
fog-aws-1.0.0 lib/fog/aws/requests/sts/assume_role_with_web_identity.rb