Class: Acs2aws::AwsSts
- Inherits:
-
Object
- Object
- Acs2aws::AwsSts
- Defined in:
- lib/acs2aws/aws_sts.rb
Instance Attribute Summary collapse
-
#encode_saml ⇒ Object
Returns the value of attribute encode_saml.
-
#saml ⇒ Object
Returns the value of attribute saml.
Instance Method Summary collapse
-
#initialize(encode_saml) ⇒ AwsSts
constructor
A new instance of AwsSts.
Constructor Details
#initialize(encode_saml) ⇒ AwsSts
Returns a new instance of AwsSts.
11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 |
# File 'lib/acs2aws/aws_sts.rb', line 11 def initialize(encode_saml) @encode_saml = encode_saml @saml = Nokogiri::XML(Base64.decode64(encode_saml)) role_entitlement = @saml.xpath('//*[@Name="https://aws.amazon.com/SAML/Attributes/Role"]') .children.children.to_s.split(',') # TODO: support customized region. client = Aws::STS::Client.new(region: 'ap-southeast-1', credentials: nil) resp = client.assume_role_with_saml( role_arn: role_entitlement[0], principal_arn: role_entitlement[1], saml_assertion: @encode_saml, # 12 hours duration_seconds: 43200 ) # puts resp system "aws configure --profile default set aws_access_key_id #{resp.credentials.access_key_id}" system "aws configure --profile default set aws_secret_access_key #{resp.credentials.secret_access_key}" system "aws configure --profile default set aws_session_token #{resp.credentials.session_token}" puts "Successfully refresh. Expiration at #{resp.credentials.expiration}".colorize(:green) end |
Instance Attribute Details
#encode_saml ⇒ Object
Returns the value of attribute encode_saml.
9 10 11 |
# File 'lib/acs2aws/aws_sts.rb', line 9 def encode_saml @encode_saml end |
#saml ⇒ Object
Returns the value of attribute saml.
9 10 11 |
# File 'lib/acs2aws/aws_sts.rb', line 9 def saml @saml end |