Class: WebAuthn::Context
- Inherits:
-
Object
show all
- Defined in:
- lib/web_authn/context.rb,
lib/web_authn/context/registration.rb,
lib/web_authn/context/authentication.rb
Defined Under Namespace
Classes: Authentication, Registration
Instance Attribute Summary collapse
Class Method Summary
collapse
Instance Method Summary
collapse
Constructor Details
#initialize(client_data_json) ⇒ Context
Returns a new instance of Context.
5
6
7
|
# File 'lib/web_authn/context.rb', line 5
def initialize(client_data_json)
self.client_data_json = client_data_json
end
|
Instance Attribute Details
#client_data_json ⇒ Object
Returns the value of attribute client_data_json.
3
4
5
|
# File 'lib/web_authn/context.rb', line 3
def client_data_json
@client_data_json
end
|
Class Method Details
.for(encoded_client_data_json, origin:, challenge:) ⇒ Object
24
25
26
27
28
29
30
31
32
33
34
35
36
37
|
# File 'lib/web_authn/context.rb', line 24
def for(encoded_client_data_json, origin:, challenge:)
client_data_json = ClientDataJSON.decode encoded_client_data_json
context = case client_data_json.type
when 'webauthn.create'
Registration.new(client_data_json)
when 'webauthn.get'
Authentication.new(client_data_json)
else
raise 'Unknown Client Data JSON Type'
end
context.verify_session!(origin: origin, challenge: challenge)
end
|
Instance Method Details
#authentication? ⇒ Boolean
19
20
21
|
# File 'lib/web_authn/context.rb', line 19
def authentication?
false
end
|
#registration? ⇒ Boolean
15
16
17
|
# File 'lib/web_authn/context.rb', line 15
def registration?
false
end
|
#verify_session!(origin:, challenge:) ⇒ Object
9
10
11
12
13
|
# File 'lib/web_authn/context.rb', line 9
def verify_session!(origin:, challenge:)
raise 'Invalid Client Data JSON Origin' unless client_data_json.origin == origin
raise 'Invalid Client Data JSON Session' unless client_data_json.challenge == challenge
self
end
|