Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,13 @@

- Add support for crossOrigin/topOrigin verification during credential registration and authentication. [#486](https://github.com/cedarcode/webauthn-ruby/pull/486) [@nicolastemciuc]

### Removed

- Remove `TokenBinding` verification during credential registration and authentication. [#450](https://github.com/cedarcode/webauthn-ruby/pull/450) [@nicolastemciuc]
Comment thread
nicolastemciuc marked this conversation as resolved.
- BREAKING CHANGE: `WebAuthn::TokenBindingVerificationError` no longer exists. Remove it from any `rescue` clauses.
- BREAKING CHANGE: `WebAuthn::FakeClient.new` no longer accepts `token_binding:`.
- BREAKING CHANGE: `WebAuthn::ClientData` no longer exposes `#token_binding` or `#valid_token_binding_format?`.

## [v3.4.3](https://github.com/cedarcode/webauthn-ruby/compare/v3.4.2...v3.4.3/) - 2025-10-23

### Fixed
Expand Down
6 changes: 0 additions & 6 deletions lib/webauthn/authenticator_response.rb
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ class AuthenticatorDataVerificationError < VerificationError; end
class ChallengeVerificationError < VerificationError; end
class OriginVerificationError < VerificationError; end
class RpIdVerificationError < VerificationError; end
class TokenBindingVerificationError < VerificationError; end
class TopOriginVerificationError < VerificationError; end
class TypeVerificationError < VerificationError; end
class UserPresenceVerificationError < VerificationError; end
Expand All @@ -31,7 +30,6 @@ def verify(expected_challenge, expected_origin = nil, user_presence: nil, user_v
rp_id ||= relying_party.id

verify_item(:type)
verify_item(:token_binding)
verify_item(:challenge, expected_challenge)
verify_item(:origin, expected_origin)
verify_item(:top_origin) if needs_top_origin_verification?
Expand Down Expand Up @@ -82,10 +80,6 @@ def valid_type?
client_data.type == type
end

def valid_token_binding?
client_data.valid_token_binding_format?
end

def valid_top_origin?
return false unless client_data.cross_origin

Expand Down
14 changes: 0 additions & 14 deletions lib/webauthn/client_data.rb
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,6 @@ module WebAuthn
class ClientDataMissingError < Error; end

class ClientData
VALID_TOKEN_BINDING_STATUSES = ["present", "supported", "not-supported"].freeze

def initialize(client_data_json)
@client_data_json = client_data_json
end
Expand All @@ -27,10 +25,6 @@ def origin
data["origin"]
end

def token_binding
data["tokenBinding"]
end

def cross_origin
data["crossOrigin"]
end
Expand All @@ -39,14 +33,6 @@ def top_origin
data["topOrigin"]
end

def valid_token_binding_format?
if token_binding
token_binding.is_a?(Hash) && VALID_TOKEN_BINDING_STATUSES.include?(token_binding["status"])
else
true
end
end

def hash
OpenSSL::Digest::SHA256.digest(client_data_json)
end
Expand Down
8 changes: 1 addition & 7 deletions lib/webauthn/fake_client.rb
Original file line number Diff line number Diff line change
Expand Up @@ -10,20 +10,18 @@ module WebAuthn
class FakeClient
TYPES = { create: "webauthn.create", get: "webauthn.get" }.freeze

attr_reader :origin, :cross_origin, :top_origin, :token_binding, :encoding
attr_reader :origin, :cross_origin, :top_origin, :encoding

def initialize(
origin = fake_origin,
cross_origin: nil,
top_origin: nil,
token_binding: nil,
authenticator: WebAuthn::FakeAuthenticator.new,
encoding: WebAuthn.configuration.encoding
)
@origin = origin
@cross_origin = cross_origin
@top_origin = top_origin
@token_binding = token_binding
@authenticator = authenticator
@encoding = encoding
end
Expand Down Expand Up @@ -137,10 +135,6 @@ def data_json_for(method, challenge)
origin: origin
}

if token_binding
data[:tokenBinding] = token_binding
end

if cross_origin
data[:crossOrigin] = cross_origin
end
Expand Down
16 changes: 0 additions & 16 deletions spec/webauthn/authenticator_assertion_response_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -239,22 +239,6 @@
end
end

describe "tokenBinding validation" do
let(:client) { WebAuthn::FakeClient.new(actual_origin, token_binding: token_binding, encoding: false) }

context "it has stuff" do
let(:token_binding) { { status: "supported" } }

it_behaves_like "a valid assertion response"
end

context "has an invalid format" do
let(:token_binding) { "invalid token binding format" }

it_behaves_like "an invalid assertion response that raises", WebAuthn::TokenBindingVerificationError
end
end

describe "rp_id validation" do
before do
WebAuthn.configuration.rp_id = "different-rp_id"
Expand Down
20 changes: 0 additions & 20 deletions spec/webauthn/authenticator_attestation_response_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -617,26 +617,6 @@
end
end

describe "tokenBinding validation" do
let(:client) { WebAuthn::FakeClient.new(origin, token_binding: token_binding, encoding: false) }

before do
WebAuthn.configuration.allowed_origins = [origin]
end

context "it has stuff" do
let(:token_binding) { { status: "supported" } }

it_behaves_like "a valid attestation response"
end

context "has an invalid format" do
let(:token_binding) { "invalid token binding format" }

it_behaves_like "an invalid attestation response that raises", WebAuthn::TokenBindingVerificationError
end
end

describe "top_origin validation" do
let(:client) { WebAuthn::FakeClient.new(origin, encoding: false, cross_origin: cross_origin, top_origin: client_top_origin) }
let(:top_origin) { fake_top_origin }
Expand Down
Loading