Class: TwoFactorAuth::AuthenticationRequest

Inherits:
Object
  • Object
show all
Includes:
Adamantium
Defined in:
app/models/two_factor_auth/authentication_request.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(app_id, key_handle, challenge = nil) ⇒ AuthenticationRequest

Returns a new instance of AuthenticationRequest.



9
10
11
12
13
# File 'app/models/two_factor_auth/authentication_request.rb', line 9

def initialize app_id, key_handle, challenge=nil
  @app_id = app_id
  @key_handle = key_handle
  @challenge = challenge
end

Instance Attribute Details

#app_idObject (readonly)

Returns the value of attribute app_id.



7
8
9
# File 'app/models/two_factor_auth/authentication_request.rb', line 7

def app_id
  @app_id
end

#key_handleObject (readonly)

Returns the value of attribute key_handle.



7
8
9
# File 'app/models/two_factor_auth/authentication_request.rb', line 7

def key_handle
  @key_handle
end

Instance Method Details

#challengeObject



15
16
17
# File 'app/models/two_factor_auth/authentication_request.rb', line 15

def challenge
  @challenge || TwoFactorAuth::random_encoded_challenge
end

#serializedObject

this matches te browser’s u2f api



21
22
23
24
25
26
27
28
# File 'app/models/two_factor_auth/authentication_request.rb', line 21

def serialized
  {
    appId: app_id,
    keyHandle: TwoFactorAuth.websafe_base64_encode(key_handle),
    challenge: challenge,
    version: U2F_VERSION,
  }.to_json
end