diff --git a/app/controllers/webauthn/rails/credentials_controller.rb b/app/controllers/webauthn/rails/credentials_controller.rb index 30e57ea2..d4d2ce4f 100644 --- a/app/controllers/webauthn/rails/credentials_controller.rb +++ b/app/controllers/webauthn/rails/credentials_controller.rb @@ -30,7 +30,7 @@ def callback ) credential = current_user.webauthn_credentials.find_or_initialize_by( - external_id: Base64.strict_encode64(webauthn_credential.raw_id) + external_id: webauthn_credential.id ) if credential.update( diff --git a/app/controllers/webauthn/rails/registrations_controller.rb b/app/controllers/webauthn/rails/registrations_controller.rb index 890aa1dc..bc15f867 100644 --- a/app/controllers/webauthn/rails/registrations_controller.rb +++ b/app/controllers/webauthn/rails/registrations_controller.rb @@ -44,7 +44,7 @@ def callback ) user.webauthn_credentials.build( - external_id: Base64.strict_encode64(webauthn_credential.raw_id), + external_id: webauthn_credential.id, nickname: params[:credential_nickname], public_key: webauthn_credential.public_key, sign_count: webauthn_credential.sign_count diff --git a/app/controllers/webauthn/rails/sessions_controller.rb b/app/controllers/webauthn/rails/sessions_controller.rb index 7af8abf3..f2a1b1a4 100644 --- a/app/controllers/webauthn/rails/sessions_controller.rb +++ b/app/controllers/webauthn/rails/sessions_controller.rb @@ -35,7 +35,7 @@ def callback user = User.find_by(username: session[:current_authentication][:username] || session[:current_authentication]["username"]) raise "user #{session[:current_authentication][:username]} never initiated sign up" unless user - stored_credential = user.webauthn_credentials.find_by(external_id: Base64.strict_encode64(webauthn_credential.raw_id)) + stored_credential = user.webauthn_credentials.find_by(external_id: webauthn_credential.id) begin webauthn_credential.verify( diff --git a/test/controllers/registrations_controller_test.rb b/test/controllers/registrations_controller_test.rb index ebffa35e..7e611dde 100644 --- a/test/controllers/registrations_controller_test.rb +++ b/test/controllers/registrations_controller_test.rb @@ -45,7 +45,7 @@ class RegistrationsControllerTest < ActionDispatch::IntegrationTest username: "bob", webauthn_credentials: [ WebauthnCredential.new( - external_id: Base64.strict_encode64(webauthn_credential.raw_id), + external_id: webauthn_credential.id, nickname: "Bob's USB Key", public_key: webauthn_credential.public_key, sign_count: webauthn_credential.sign_count