mirror of
https://github.com/discourse/discourse.git
synced 2025-06-02 04:08:41 +08:00
FEATURE: Webauthn authenticator management with 2FA login (Security Keys) (#8099)
Adds 2 factor authentication method via second factor security keys over [web authn](https://developer.mozilla.org/en-US/docs/Web/API/Web_Authentication_API). Allows a user to authenticate a second factor on login, login-via-email, admin-login, and change password routes. Adds registration area within existing user second factor preferences to register multiple security keys. Supports both external (yubikey) and built-in (macOS/android fingerprint readers).
This commit is contained in:

committed by
Jeff Wong

parent
45ff119f27
commit
68d35b14f4
26
db/migrate/20190904104533_create_user_security_keys.rb
Normal file
26
db/migrate/20190904104533_create_user_security_keys.rb
Normal file
@ -0,0 +1,26 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
class CreateUserSecurityKeys < ActiveRecord::Migration[5.2]
|
||||
def up
|
||||
create_table :user_security_keys do |t|
|
||||
t.references :user, null: false, index: true, foreign_key: true
|
||||
t.string :credential_id, null: false
|
||||
t.string :public_key, null: false, index: true
|
||||
t.integer :factor_type, null: false, default: 0, index: true
|
||||
t.boolean :enabled, null: false, default: true
|
||||
t.string :name, null: false
|
||||
t.datetime :last_used
|
||||
|
||||
t.timestamps
|
||||
end
|
||||
|
||||
add_index :user_security_keys, :credential_id, unique: true
|
||||
add_index :user_security_keys, :last_used
|
||||
end
|
||||
|
||||
def down
|
||||
if table_exists?(:user_security_keys)
|
||||
drop_table(:user_security_keys)
|
||||
end
|
||||
end
|
||||
end
|
@ -0,0 +1,8 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
class AddSecureIdentifierColumnToUsers < ActiveRecord::Migration[5.2]
|
||||
def change
|
||||
add_column :users, :secure_identifier, :string
|
||||
add_index :users, :secure_identifier, unique: true
|
||||
end
|
||||
end
|
@ -0,0 +1,7 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
class AddEnabledIndexToUserSecurityKey < ActiveRecord::Migration[6.0]
|
||||
def change
|
||||
add_index :user_security_keys, [:factor_type, :enabled]
|
||||
end
|
||||
end
|
Reference in New Issue
Block a user