@attr_reader [String] base_32_string_seed The Base32 seed defined as
specified in RFC3548. Only accessible on newly created devices. This value is Base64-encoded.
@attr_reader [Blob] qr_code_png A QR code PNG image that encodes
otpauth://totp/$virtualMFADeviceName@$AccountName? secret=$Base32String where $virtualMFADeviceName is one of the create call arguments, AccountName is the user name if set (accountId otherwise), and Base32String is the seed in Base32 format. Only accessible on newly created devices. This value is Base64-encoded.
@attr_reader [DateTime] enable_date When this device was enabled.
Returns nil if this device has not been enabled.
@return [String] Returns the virtual MFA device serial number (ARN).
@return [String] Returns the virtual MFA device serial number (ARN).
@private
# File lib/aws/iam/virtual_mfa_device.rb, line 36 def initialize serial_number, options = {} @serial_number = serial_number super end
Deactivates the MFA device and removes it from association with the user for which it was originally enabled. @return [nil]
# File lib/aws/iam/virtual_mfa_device.rb, line 95 def deactivate client_opts = {} client_opts[:user_name] = user.name client_opts[:serial_number] = serial_number client.deactivate_mfa_device(client_opts) nil end
Deletes this virtual MFA device. @return [nil]
# File lib/aws/iam/virtual_mfa_device.rb, line 106 def delete client.delete_virtual_mfa_device(resource_options) nil end
Enables the MFA device and associates it with the specified user. When enabled, the MFA device is required for every subsequent login by the user name associated with the device. @param [User,String] user The user (or user name string) you want
to enable this device for.
@param [String] code1 An authentication code emitted by the device. @param [String] code2 A subsequent authentication code emitted by
the device.
# File lib/aws/iam/virtual_mfa_device.rb, line 72 def enable user, code1, code2 user_name = user.is_a?(User) ? user.name : user client.enable_mfa_device( :user_name => user_name, :serial_number => serial_number, :authentication_code_1 => format_auth_code(code1), :authentication_code_2 => format_auth_code(code2)) nil end
@return [Boolean] Returns true if this device has been enabled
for a user.
# File lib/aws/iam/virtual_mfa_device.rb, line 88 def enabled? !!enable_date end
@return [User,nil] Returns the user this device was enabled
for, or nil if this device has not been enabled.
# File lib/aws/iam/virtual_mfa_device.rb, line 58 def user if details = user_details User.new(details.user_name, :config => config) end end
# File lib/aws/iam/virtual_mfa_device.rb, line 122 def format_auth_code(code) sprintf("%06d", code) end
# File lib/aws/iam/virtual_mfa_device.rb, line 127 def get_resource attr_name client.list_virtual_mfa_devices end
# File lib/aws/iam/virtual_mfa_device.rb, line 132 def resource_identifiers [[:serial_number, serial_number]] end