mirror of
https://github.com/discourse/discourse.git
synced 2024-12-30 06:33:50 +08:00
0af6c5efdc
This is part 1 of 3, split up of PR #23529. This PR refactors the webauthn code to support passkey authentication/registration. Passkeys aren't used yet, that is coming in PRs 2 and 3. Co-authored-by: Alan Guo Xiang Tan <gxtan1990@gmail.com>
33 lines
1.2 KiB
Ruby
33 lines
1.2 KiB
Ruby
# frozen_string_literal: true
|
|
|
|
Fabricator(:user_security_key) do
|
|
user
|
|
# Note: these values are valid and decode to a credential ID and COSE public key
|
|
# HOWEVER they are largely useless unless you have the device that created
|
|
# them. It is nice to have an approximation though.
|
|
credential_id do
|
|
"mJAJ4CznTO0SuLkJbYwpgK75ao4KMNIPlU5KWM92nq39kRbXzI9mSv6GxTcsMYoiPgaouNw7b7zBiS4vsQaO6A=="
|
|
end
|
|
public_key do
|
|
"pQECAyYgASFYIMNgw4GCpwBUlR2SznJ1yY7B9yFvsuxhfo+C9kcA4IitIlggRdofrCezymy2B/YarX+gfB6gZKg648/cHIMjf6wWmmU="
|
|
end
|
|
enabled true
|
|
factor_type { UserSecurityKey.factor_types[:second_factor] }
|
|
name { sequence(:name) { |i| "Security Key #{i + 1}" } }
|
|
end
|
|
|
|
##
|
|
# Useful for specs that just need a user security key model but not
|
|
# any of the related usefulness as a webauthn credential, because the
|
|
# credential_id has a UNIQUE index
|
|
Fabricator(:user_security_key_with_random_credential, from: :user_security_key) do
|
|
credential_id { SecureRandom.base64(40) }
|
|
public_key { SecureRandom.base64(40) }
|
|
end
|
|
|
|
Fabricator(:passkey_with_random_credential, from: :user_security_key) do
|
|
credential_id { SecureRandom.base64(40) }
|
|
public_key { SecureRandom.base64(40) }
|
|
factor_type { UserSecurityKey.factor_types[:first_factor] }
|
|
end
|