Class: Assumer::MFA
- Inherits:
-
Object
- Object
- Assumer::MFA
- Defined in:
- lib/mfa.rb
Overview
A class to manage methods of obtaining OTP codes for MFA
Instance Attribute Summary collapse
-
#otp ⇒ Object
readonly
Returns the value of attribute otp.
Instance Method Summary collapse
-
#request_one_time_code ⇒ String
A method to prompt for the user’s OTP MFA code on the CLI.
Instance Attribute Details
#otp ⇒ Object (readonly)
Returns the value of attribute otp.
5 6 7 |
# File 'lib/mfa.rb', line 5 def otp @otp end |
Instance Method Details
#request_one_time_code ⇒ String
A method to prompt for the user’s OTP MFA code on the CLI
9 10 11 12 13 14 15 16 17 18 19 |
# File 'lib/mfa.rb', line 9 def request_one_time_code until @otp =~ /\d{6}/ print 'Enter MFA: ' $stdout.flush @otp = $stdin.gets(7).chomp $stderr.puts 'MFA code should be 6 digits' if @otp !~ /\d{6}/ end @otp # return the MFA code rescue SystemExit, Interrupt exit 0 end |