Sha256: 44a0fb59bfd86571acea1655b59a6ee035558f298ae14c58698713301b9584c0

Contents?: true

Size: 1.68 KB

Versions: 31

Compression:

Stored size: 1.68 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,
            'WebIdentityToken'  => web_identity_token,
            '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

31 entries across 31 versions & 1 rubygems

Version Path
fog-aws-3.30.0 lib/fog/aws/requests/sts/assume_role_with_web_identity.rb
fog-aws-3.29.0 lib/fog/aws/requests/sts/assume_role_with_web_identity.rb
fog-aws-3.28.0 lib/fog/aws/requests/sts/assume_role_with_web_identity.rb
fog-aws-3.27.0 lib/fog/aws/requests/sts/assume_role_with_web_identity.rb
fog-aws-3.26.0 lib/fog/aws/requests/sts/assume_role_with_web_identity.rb
fog-aws-3.25.0 lib/fog/aws/requests/sts/assume_role_with_web_identity.rb
fog-aws-3.24.0 lib/fog/aws/requests/sts/assume_role_with_web_identity.rb
fog-aws-3.23.0 lib/fog/aws/requests/sts/assume_role_with_web_identity.rb
fog-aws-3.22.0 lib/fog/aws/requests/sts/assume_role_with_web_identity.rb
fog-aws-3.21.1 lib/fog/aws/requests/sts/assume_role_with_web_identity.rb
fog-aws-3.21.0 lib/fog/aws/requests/sts/assume_role_with_web_identity.rb
fog-aws-3.20.0 lib/fog/aws/requests/sts/assume_role_with_web_identity.rb
fog-aws-3.19.0 lib/fog/aws/requests/sts/assume_role_with_web_identity.rb
fog-aws-3.18.0 lib/fog/aws/requests/sts/assume_role_with_web_identity.rb
fog-aws-3.17.0 lib/fog/aws/requests/sts/assume_role_with_web_identity.rb
fog-aws-3.16.0 lib/fog/aws/requests/sts/assume_role_with_web_identity.rb
fog-aws-3.15.0 lib/fog/aws/requests/sts/assume_role_with_web_identity.rb
fog-aws-3.14.0 lib/fog/aws/requests/sts/assume_role_with_web_identity.rb
fog-aws-3.13.0 lib/fog/aws/requests/sts/assume_role_with_web_identity.rb
fog-aws-3.12.0 lib/fog/aws/requests/sts/assume_role_with_web_identity.rb