Class: Aws::Session::Credentials::MfaDevice::YubikeyMfaDevice
- Inherits:
-
Object
- Object
- Aws::Session::Credentials::MfaDevice::YubikeyMfaDevice
- Defined in:
- lib/aws/session/credentials/mfa_device/yubikey_mfa_device.rb
Overview
Gets MFA codes from a Yubikey using YubiOATH
Instance Attribute Summary collapse
-
#device_arn ⇒ Object
readonly
Returns the value of attribute device_arn.
Instance Method Summary collapse
- #code ⇒ Object
-
#initialize(options = {}) ⇒ YubikeyMfaDevice
constructor
A new instance of YubikeyMfaDevice.
Constructor Details
#initialize(options = {}) ⇒ YubikeyMfaDevice
Returns a new instance of YubikeyMfaDevice.
9 10 11 12 13 |
# File 'lib/aws/session/credentials/mfa_device/yubikey_mfa_device.rb', line 9 def initialize( = {}) @yubikey_name = .fetch(:yubikey_name) { 'Yubikey' } @oath_credential = [:oath_credential] @device_arn = [:device_arn] end |
Instance Attribute Details
#device_arn ⇒ Object (readonly)
Returns the value of attribute device_arn.
7 8 9 |
# File 'lib/aws/session/credentials/mfa_device/yubikey_mfa_device.rb', line 7 def device_arn @device_arn end |
Instance Method Details
#code ⇒ Object
15 16 17 18 19 20 21 22 23 24 25 26 |
# File 'lib/aws/session/credentials/mfa_device/yubikey_mfa_device.rb', line 15 def code card_names.each do |card_name| card(card_name) do |crd| oath = YubiOATH.new(crd) codes = oath.calculate_all(timestamp: Time.now) # Credential names are returned as ASCII-8BIT codes.transform_keys! { |key| key.force_encoding('UTF-8') } return codes[@oath_credential] end end nil end |