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
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
### Changed

- Options for getting or creating passkeys and security keys are now served by dedicated Rails controllers and retrieved via JavaScript fetch requests. [#73](https://github.com/cedarcode/devise-webauthn/pull/73) [@nicolastemciuc]
- BREAKING!: Remove helpers for generating WebAuthn options. [#106](https://github.com/cedarcode/devise-webauthn/pull/115) [@nicolastemciuc]

## [v0.3.0](https://github.com/cedarcode/devise-webauthn/compare/v0.2.2...v0.3.0/) - 2026-01-16

Expand Down
71 changes: 0 additions & 71 deletions lib/devise/webauthn/helpers/credentials_helper.rb
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
# frozen_string_literal: true

# rubocop:disable Metrics/ModuleLength
module Devise
module Webauthn
module CredentialsHelper
Expand Down Expand Up @@ -59,75 +58,6 @@ def login_with_security_key_button(text = nil, resource:, button_classes: nil, f
end
end

def create_passkey_options(resource)
@create_passkey_options ||= begin
options = WebAuthn::Credential.options_for_create(
user: {
id: resource.webauthn_id,
name: resource_human_palatable_identifier
},
exclude: resource.passkeys.pluck(:external_id),
authenticator_selection: {
resident_key: "required",
user_verification: "required"
}
)

# Store challenge in session for later verification
session[:webauthn_challenge] = options.challenge

options
end
end

def passkey_authentication_options
@passkey_authentication_options ||= begin
options = WebAuthn::Credential.options_for_get(
user_verification: "required"
)

# Store challenge in session for later verification
session[:authentication_challenge] = options.challenge

options
end
end

def create_security_key_options(resource)
@create_security_key_options ||= begin
options = WebAuthn::Credential.options_for_create(
user: {
id: resource.webauthn_id,
name: resource_human_palatable_identifier
},
exclude: resource.webauthn_credentials.pluck(:external_id),
authenticator_selection: {
resident_key: "discouraged",
user_verification: "discouraged"
}
)

# Store challenge in session for later verification
session[:webauthn_challenge] = options.challenge

options
end
end

def security_key_authentication_options(resource)
@security_key_authentication_options ||= begin
options = WebAuthn::Credential.options_for_get(
allow: resource.webauthn_credentials.pluck(:external_id),
user_verification: "discouraged"
)

# Store challenge in session for later verification
session[:two_factor_authentication_challenge] = options.challenge

options
end
end

private

def resource_human_palatable_identifier
Expand All @@ -139,4 +69,3 @@ def resource_human_palatable_identifier
end
end
end
# rubocop:enable Metrics/ModuleLength