DEV: Rename experimental_passkeys to enable_passkeys (#24349)

Also includes a migration.
This commit is contained in:
Penar Musaraj 2023-11-13 15:04:15 -05:00 committed by GitHub
parent e2e454c480
commit a814348176
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
14 changed files with 39 additions and 28 deletions

View File

@ -25,7 +25,7 @@ export default Component.extend({
canUsePasskeys() {
return (
this.siteSettings.enable_local_logins &&
this.siteSettings.experimental_passkeys &&
this.siteSettings.enable_passkeys &&
isWebauthnSupported()
);
},

View File

@ -96,7 +96,7 @@ export default class Login extends Component {
get canUsePasskeys() {
return (
this.siteSettings.enable_local_logins &&
this.siteSettings.experimental_passkeys &&
this.siteSettings.enable_passkeys &&
isWebauthnSupported()
);
}

View File

@ -28,7 +28,7 @@ export default Controller.extend(CanCheckEmails, {
return (
!this.siteSettings.enable_discourse_connect &&
this.siteSettings.enable_local_logins &&
this.siteSettings.experimental_passkeys &&
this.siteSettings.enable_passkeys &&
isWebauthnSupported()
);
},

View File

@ -47,7 +47,7 @@ acceptance("Modal - Login - With 2FA", function (needs) {
acceptance("Modal - Login - With Passkeys enabled", function (needs) {
needs.settings({
experimental_passkeys: true,
enable_passkeys: true,
});
needs.pretender((server, helper) => {
@ -72,7 +72,7 @@ acceptance("Modal - Login - With Passkeys enabled", function (needs) {
acceptance("Modal - Login - With Passkeys disabled", function (needs) {
needs.settings({
experimental_passkeys: false,
enable_passkeys: false,
});
test("Excludes passkeys button and conditional UI", async function (assert) {
@ -87,7 +87,7 @@ acceptance("Modal - Login - With Passkeys disabled", function (needs) {
acceptance("Modal - Login - Passkeys on mobile", function (needs) {
needs.mobileView();
needs.settings({
experimental_passkeys: true,
enable_passkeys: true,
});
needs.pretender((server, helper) => {

View File

@ -99,7 +99,7 @@ acceptance("User Preferences - Security", function (needs) {
});
test("Viewing Passkeys - user has a key", async function (assert) {
this.siteSettings.experimental_passkeys = true;
this.siteSettings.enable_passkeys = true;
updateCurrentUser({
user_passkeys: [
@ -161,7 +161,7 @@ acceptance("User Preferences - Security", function (needs) {
});
test("Viewing Passkeys - empty state", async function (assert) {
this.siteSettings.experimental_passkeys = true;
this.siteSettings.enable_passkeys = true;
await visit("/u/eviltrout/preferences/security");
@ -179,7 +179,7 @@ acceptance("User Preferences - Security", function (needs) {
});
test("Viewing Passkeys - another user has a key", async function (assert) {
this.siteSettings.experimental_passkeys = true;
this.siteSettings.enable_passkeys = true;
// user charlie has passkeys in fixtures
await visit("/u/charlie/preferences/security");

View File

@ -338,7 +338,7 @@ class SessionController < ApplicationController
end
def passkey_login
raise Discourse::NotFound unless SiteSetting.experimental_passkeys
raise Discourse::NotFound unless SiteSetting.enable_passkeys
params.require(:publicKeyCredential)

View File

@ -1609,7 +1609,7 @@ class UsersController < ApplicationController
end
def create_passkey
raise Discourse::NotFound unless SiteSetting.experimental_passkeys
raise Discourse::NotFound unless SiteSetting.enable_passkeys
challenge_session = DiscourseWebauthn.stage_challenge(current_user, secure_session)
render json:
@ -1624,7 +1624,7 @@ class UsersController < ApplicationController
end
def register_passkey
raise Discourse::NotFound unless SiteSetting.experimental_passkeys
raise Discourse::NotFound unless SiteSetting.enable_passkeys
params.require(:name)
params.require(:attestation)
@ -1644,7 +1644,7 @@ class UsersController < ApplicationController
end
def delete_passkey
raise Discourse::NotFound unless SiteSetting.experimental_passkeys
raise Discourse::NotFound unless SiteSetting.enable_passkeys
current_user.security_keys.find_by(id: params[:id].to_i)&.destroy!
@ -1652,7 +1652,7 @@ class UsersController < ApplicationController
end
def rename_passkey
raise Discourse::NotFound unless SiteSetting.experimental_passkeys
raise Discourse::NotFound unless SiteSetting.enable_passkeys
params.require(:id)
params.require(:name)

View File

@ -175,7 +175,7 @@ class UserSerializer < UserCardSerializer
end
def include_user_passkeys?
SiteSetting.experimental_passkeys?
SiteSetting.enable_passkeys?
end
def bio_raw

View File

@ -416,6 +416,10 @@ login:
client: true
default: true
validator: "EnableLocalLoginsViaEmailValidator"
enable_passkeys:
client: true
default: false
hidden: true
allow_new_registrations:
client: true
default: true
@ -2180,10 +2184,6 @@ developer:
experimental_topics_filter:
client: true
default: false
experimental_passkeys:
client: true
default: false
hidden: true
experimental_search_menu_groups:
type: group_list
list_type: compact

View File

@ -0,0 +1,11 @@
# frozen_string_literal: true
class RenameExperimentalPasskeysSiteSetting < ActiveRecord::Migration[7.0]
def up
execute "UPDATE site_settings SET name = 'enable_passkeys' WHERE name = 'experimental_passkeys'"
end
def down
execute "UPDATE site_settings SET name = 'experimental_passkeys' WHERE name = 'enable_passkeys'"
end
end

View File

@ -3043,14 +3043,14 @@ RSpec.describe SessionController do
describe "#passkey_login" do
it "returns 404 if feature is not enabled" do
SiteSetting.experimental_passkeys = false
SiteSetting.enable_passkeys = false
post "/session/passkey/auth.json"
expect(response.status).to eq(404)
end
context "when experimental_passkeys is enabled" do
before { SiteSetting.experimental_passkeys = true }
context "when enable_passkeys is enabled" do
before { SiteSetting.enable_passkeys = true }
it "fails if public key param is missing" do
post "/session/passkey/auth.json"

View File

@ -5950,7 +5950,7 @@ RSpec.describe UsersController do
describe "#create_passkey" do
before do
SiteSetting.experimental_passkeys = true
SiteSetting.enable_passkeys = true
stub_secure_session_confirmed
end
@ -5991,7 +5991,7 @@ RSpec.describe UsersController do
end
describe "#rename_passkey" do
before { SiteSetting.experimental_passkeys = true }
before { SiteSetting.enable_passkeys = true }
it "fails if no user is logged in" do
put "/u/rename_passkey/NONE.json"
@ -6044,7 +6044,7 @@ RSpec.describe UsersController do
end
describe "#delete_passkey" do
before { SiteSetting.experimental_passkeys = true }
before { SiteSetting.enable_passkeys = true }
fab!(:passkey) { Fabricate(:passkey_with_random_credential, user: user1) }
it "fails if user does not have a confirmed session" do
@ -6079,7 +6079,7 @@ RSpec.describe UsersController do
end
describe "#register_passkey" do
before { SiteSetting.experimental_passkeys = true }
before { SiteSetting.enable_passkeys = true }
it "fails if user is not logged in" do
stub_secure_session_confirmed

View File

@ -456,7 +456,7 @@ RSpec.describe UserSerializer do
end
it "includes passkeys if feature is enabled" do
SiteSetting.experimental_passkeys = true
SiteSetting.enable_passkeys = true
json = UserSerializer.new(user, scope: Guardian.new(user), root: false).as_json

View File

@ -49,7 +49,7 @@ describe "User preferences for Security", type: :system do
end
shared_examples "passkeys" do
before { SiteSetting.experimental_passkeys = true }
before { SiteSetting.enable_passkeys = true }
it "adds a passkey and logs in with it" do
options =