Class: AwsMfaSecure::Credentials

Inherits:
Base
  • Object
show all
Includes:
Singleton
Defined in:
lib/aws_mfa_secure/credentials.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods inherited from Base

#aws_cli_installed?, #aws_cli_setup?, #aws_config, #aws_mfa_env_set?, #aws_profile, #credentials, #fetch_creds?, #get_session_token, #good_session_creds?, #iam_mfa?, #mfa_prompt, #mfa_serial, #save_creds, #session_creds_path, #shell_get_session_token, #sts

Constructor Details

#initializeCredentials

Returns a new instance of Credentials.



11
12
13
14
# File 'lib/aws_mfa_secure/credentials.rb', line 11

def initialize
  @aws_profile = aws_profile
  setup
end

Instance Attribute Details

#dataObject (readonly)

Returns the value of attribute data.



10
11
12
# File 'lib/aws_mfa_secure/credentials.rb', line 10

def data
  @data
end

Instance Method Details

#set?Boolean

Returns:

  • (Boolean)


27
28
29
# File 'lib/aws_mfa_secure/credentials.rb', line 27

def set?
  !!@data
end

#setupObject



16
17
18
19
20
21
22
23
24
25
# File 'lib/aws_mfa_secure/credentials.rb', line 16

def setup
  return unless iam_mfa?

  if fetch_creds?
    resp = get_session_token(shell: true)
    save_creds(resp.credentials.to_h)
  end

  @data = credentials
end