Skip to content

Commit

Permalink
adopt webauthn-ruby >= 2
Browse files Browse the repository at this point in the history
  • Loading branch information
sorah committed May 26, 2022
1 parent 7e62d5a commit b025c90
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 5 deletions.
1 change: 1 addition & 0 deletions Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -6,3 +6,4 @@ git_source(:github) {|repo_name| "https://github.com/#{repo_name}" }
gemspec

gem 'puma'
gem 'nokogiri'
3 changes: 1 addition & 2 deletions clarion.gemspec
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@

lib = File.expand_path("../lib", __FILE__)
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
require "clarion/version"
Expand All @@ -20,7 +19,7 @@ Gem::Specification.new do |spec|
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
spec.require_paths = ["lib"]

spec.add_dependency "webauthn", '< 2'
spec.add_dependency "webauthn", '>= 2.0.0'
spec.add_dependency "sinatra"
spec.add_dependency "erubis"
spec.add_dependency "aws-sdk-s3"
Expand Down
6 changes: 3 additions & 3 deletions lib/clarion/authenticator.rb
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,6 @@ def credential_request_options

def verify!(challenge: self.challenge(), origin:, extension_results: {}, credential_id:, authenticator_data:, client_data_json:, signature:)
assertion = WebAuthn::AuthenticatorAssertionResponse.new(
credential_id: credential_id,
authenticator_data: authenticator_data,
client_data_json: client_data_json,
signature: signature,
Expand All @@ -55,8 +54,9 @@ def verify!(challenge: self.challenge(), origin:, extension_results: {}, credent
end

rp_id = extension_results&.fetch('appid', extension_results&.fetch(:appid, false)) ? legacy_app_id : self.rp_id()
allowed_credentials = authn.keys.map { |_| {id: _.handle, public_key: _.public_key_bytes} }
unless assertion.valid?(challenge, origin, rp_id: rp_id, allowed_credentials: allowed_credentials)

# TODO: move sign_count verification to webauthn-ruby
unless assertion.valid?(challenge, origin, rp_id: rp_id, public_key: key.public_key_bytes, sign_count: false)
raise Authenticator::InvalidAssertion, "invalid assertion"
end

Expand Down

0 comments on commit b025c90

Please sign in to comment.