Skip to content

Commit 27897e9

Browse files
feat!: remove token binding support
1 parent 6fa4831 commit 27897e9

5 files changed

Lines changed: 3 additions & 97 deletions

File tree

lib/webauthn/authenticator_response.rb

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@ class AuthenticatorDataVerificationError < VerificationError; end
1313
class ChallengeVerificationError < VerificationError; end
1414
class OriginVerificationError < VerificationError; end
1515
class RpIdVerificationError < VerificationError; end
16-
class TokenBindingVerificationError < VerificationError; end
1716
class TypeVerificationError < VerificationError; end
1817
class UserPresenceVerificationError < VerificationError; end
1918
class UserVerifiedVerificationError < VerificationError; end
@@ -29,7 +28,6 @@ def verify(expected_challenge, expected_origin = nil, user_presence: nil, user_v
2928
rp_id ||= relying_party.id
3029

3130
verify_item(:type)
32-
verify_item(:token_binding)
3331
verify_item(:challenge, expected_challenge)
3432
verify_item(:origin, expected_origin)
3533
verify_item(:authenticator_data)
@@ -75,10 +73,6 @@ def valid_type?
7573
client_data.type == type
7674
end
7775

78-
def valid_token_binding?
79-
client_data.valid_token_binding_format?
80-
end
81-
8276
def valid_challenge?(expected_challenge)
8377
OpenSSL.secure_compare(client_data.challenge, expected_challenge)
8478
end

lib/webauthn/client_data.rb

Lines changed: 0 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,6 @@ module WebAuthn
99
class ClientDataMissingError < Error; end
1010

1111
class ClientData
12-
VALID_TOKEN_BINDING_STATUSES = ["present", "supported", "not-supported"].freeze
13-
1412
def initialize(client_data_json)
1513
@client_data_json = client_data_json
1614
end
@@ -27,18 +25,6 @@ def origin
2725
data["origin"]
2826
end
2927

30-
def token_binding
31-
data["tokenBinding"]
32-
end
33-
34-
def valid_token_binding_format?
35-
if token_binding
36-
token_binding.is_a?(Hash) && VALID_TOKEN_BINDING_STATUSES.include?(token_binding["status"])
37-
else
38-
true
39-
end
40-
end
41-
4228
def hash
4329
OpenSSL::Digest::SHA256.digest(client_data_json)
4430
end

lib/webauthn/fake_client.rb

Lines changed: 3 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -10,16 +10,14 @@ module WebAuthn
1010
class FakeClient
1111
TYPES = { create: "webauthn.create", get: "webauthn.get" }.freeze
1212

13-
attr_reader :origin, :token_binding, :encoding
13+
attr_reader :origin, :encoding
1414

1515
def initialize(
1616
origin = fake_origin,
17-
token_binding: nil,
1817
authenticator: WebAuthn::FakeAuthenticator.new,
1918
encoding: WebAuthn.configuration.encoding
2019
)
2120
@origin = origin
22-
@token_binding = token_binding
2321
@authenticator = authenticator
2422
@encoding = encoding
2523
end
@@ -127,17 +125,11 @@ def get(challenge: fake_challenge,
127125
attr_reader :authenticator
128126

129127
def data_json_for(method, challenge)
130-
data = {
128+
{
131129
type: type_for(method),
132130
challenge: internal_encoder.encode(challenge),
133131
origin: origin
134-
}
135-
136-
if token_binding
137-
data[:tokenBinding] = token_binding
138-
end
139-
140-
data.to_json
132+
}.to_json
141133
end
142134

143135
def encoder

spec/webauthn/authenticator_assertion_response_spec.rb

Lines changed: 0 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -367,42 +367,6 @@
367367
end
368368
end
369369

370-
describe "tokenBinding validation" do
371-
let(:client) { WebAuthn::FakeClient.new(actual_origin, token_binding: token_binding, encoding: false) }
372-
373-
context "it has stuff" do
374-
let(:token_binding) { { status: "supported" } }
375-
376-
it "verifies" do
377-
expect(
378-
assertion_response.verify(original_challenge, public_key: credential_public_key, sign_count: 0)
379-
).to be_truthy
380-
end
381-
382-
it "is valid" do
383-
expect(
384-
assertion_response.valid?(original_challenge, public_key: credential_public_key, sign_count: 0)
385-
).to be_truthy
386-
end
387-
end
388-
389-
context "has an invalid format" do
390-
let(:token_binding) { "invalid token binding format" }
391-
392-
it "doesn't verify" do
393-
expect {
394-
assertion_response.verify(original_challenge, public_key: credential_public_key, sign_count: 0)
395-
}.to raise_exception(WebAuthn::TokenBindingVerificationError)
396-
end
397-
398-
it "isn't valid" do
399-
expect(
400-
assertion_response.valid?(original_challenge, public_key: credential_public_key, sign_count: 0)
401-
).to be_falsy
402-
end
403-
end
404-
end
405-
406370
describe "rp_id validation" do
407371
before do
408372
WebAuthn.configuration.rp_id = "different-rp_id"

spec/webauthn/authenticator_attestation_response_spec.rb

Lines changed: 0 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -479,36 +479,6 @@
479479
end
480480
end
481481

482-
describe "tokenBinding validation" do
483-
let(:client) { WebAuthn::FakeClient.new(origin, token_binding: token_binding, encoding: false) }
484-
485-
context "it has stuff" do
486-
let(:token_binding) { { status: "supported" } }
487-
488-
it "verifies" do
489-
expect(attestation_response.verify(original_challenge, origin)).to be_truthy
490-
end
491-
492-
it "is valid" do
493-
expect(attestation_response.valid?(original_challenge, origin)).to be_truthy
494-
end
495-
end
496-
497-
context "has an invalid format" do
498-
let(:token_binding) { "invalid token binding format" }
499-
500-
it "doesn't verify" do
501-
expect {
502-
attestation_response.verify(original_challenge, origin)
503-
}.to raise_exception(WebAuthn::TokenBindingVerificationError)
504-
end
505-
506-
it "isn't valid" do
507-
expect(attestation_response.valid?(original_challenge, origin)).to be_falsy
508-
end
509-
end
510-
end
511-
512482
describe "user presence" do
513483
context "when UP is not set" do
514484
let(:public_key_credential) { client.create(challenge: original_challenge, user_present: false) }

0 commit comments

Comments
 (0)