From a3430f011f1adceaef8484f38a57018712a18ad2 Mon Sep 17 00:00:00 2001 From: Markus Koller Date: Tue, 24 Jan 2017 22:09:58 +0100 Subject: Support 2FA requirement per-group --- ...24193147_add_two_factor_columns_to_namespaces.rb | 21 +++++++++++++++++++++ ...0170124193205_add_two_factor_columns_to_users.rb | 17 +++++++++++++++++ db/schema.rb | 5 +++++ 3 files changed, 43 insertions(+) create mode 100644 db/migrate/20170124193147_add_two_factor_columns_to_namespaces.rb create mode 100644 db/migrate/20170124193205_add_two_factor_columns_to_users.rb (limited to 'db') diff --git a/db/migrate/20170124193147_add_two_factor_columns_to_namespaces.rb b/db/migrate/20170124193147_add_two_factor_columns_to_namespaces.rb new file mode 100644 index 00000000000..ca4429c676c --- /dev/null +++ b/db/migrate/20170124193147_add_two_factor_columns_to_namespaces.rb @@ -0,0 +1,21 @@ +class AddTwoFactorColumnsToNamespaces < ActiveRecord::Migration + include Gitlab::Database::MigrationHelpers + + DOWNTIME = false + + disable_ddl_transaction! + + def up + add_column_with_default(:namespaces, :require_two_factor_authentication, :boolean, default: false) + add_column_with_default(:namespaces, :two_factor_grace_period, :integer, default: 48) + + add_concurrent_index(:namespaces, :require_two_factor_authentication) + end + + def down + remove_column(:namespaces, :require_two_factor_authentication) + remove_column(:namespaces, :two_factor_grace_period) + + remove_index(:namespaces, :require_two_factor_authentication) if index_exists?(:namespaces, :require_two_factor_authentication) + end +end diff --git a/db/migrate/20170124193205_add_two_factor_columns_to_users.rb b/db/migrate/20170124193205_add_two_factor_columns_to_users.rb new file mode 100644 index 00000000000..bef1b2062c8 --- /dev/null +++ b/db/migrate/20170124193205_add_two_factor_columns_to_users.rb @@ -0,0 +1,17 @@ +class AddTwoFactorColumnsToUsers < ActiveRecord::Migration + include Gitlab::Database::MigrationHelpers + + DOWNTIME = false + + disable_ddl_transaction! + + def up + add_column_with_default(:users, :require_two_factor_authentication, :boolean, default: false) + add_column_with_default(:users, :two_factor_grace_period, :integer, default: 48) + end + + def down + remove_column(:users, :require_two_factor_authentication) + remove_column(:users, :two_factor_grace_period) + end +end diff --git a/db/schema.rb b/db/schema.rb index ccf18d07179..2d2507828d4 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -692,6 +692,8 @@ ActiveRecord::Schema.define(version: 20170402231018) do t.text "description_html" t.boolean "lfs_enabled" t.integer "parent_id" + t.boolean "require_two_factor_authentication", default: false, null: false + t.integer "two_factor_grace_period", default: 48, null: false end add_index "namespaces", ["created_at"], name: "index_namespaces_on_created_at", using: :btree @@ -702,6 +704,7 @@ ActiveRecord::Schema.define(version: 20170402231018) do add_index "namespaces", ["parent_id", "id"], name: "index_namespaces_on_parent_id_and_id", unique: true, using: :btree add_index "namespaces", ["path"], name: "index_namespaces_on_path", using: :btree add_index "namespaces", ["path"], name: "index_namespaces_on_path_trigram", using: :gin, opclasses: {"path"=>"gin_trgm_ops"} + add_index "namespaces", ["require_two_factor_authentication"], name: "index_namespaces_on_require_two_factor_authentication", using: :btree add_index "namespaces", ["type"], name: "index_namespaces_on_type", using: :btree create_table "notes", force: :cascade do |t| @@ -1246,6 +1249,8 @@ ActiveRecord::Schema.define(version: 20170402231018) do t.boolean "authorized_projects_populated" t.boolean "ghost" t.boolean "notified_of_own_activity" + t.boolean "require_two_factor_authentication", default: false, null: false + t.integer "two_factor_grace_period", default: 48, null: false end add_index "users", ["admin"], name: "index_users_on_admin", using: :btree -- cgit v1.2.3 From 1735ed613910b38c4c069da9c4637bbc4856db36 Mon Sep 17 00:00:00 2001 From: Alexis Reigel Date: Tue, 14 Mar 2017 14:34:21 +0100 Subject: rename cache db column with `_cached` suffix --- db/migrate/20170124193205_add_two_factor_columns_to_users.rb | 4 ++-- db/schema.rb | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) (limited to 'db') diff --git a/db/migrate/20170124193205_add_two_factor_columns_to_users.rb b/db/migrate/20170124193205_add_two_factor_columns_to_users.rb index bef1b2062c8..1d1021fcbb3 100644 --- a/db/migrate/20170124193205_add_two_factor_columns_to_users.rb +++ b/db/migrate/20170124193205_add_two_factor_columns_to_users.rb @@ -6,12 +6,12 @@ class AddTwoFactorColumnsToUsers < ActiveRecord::Migration disable_ddl_transaction! def up - add_column_with_default(:users, :require_two_factor_authentication, :boolean, default: false) + add_column_with_default(:users, :require_two_factor_authentication_from_group, :boolean, default: false) add_column_with_default(:users, :two_factor_grace_period, :integer, default: 48) end def down - remove_column(:users, :require_two_factor_authentication) + remove_column(:users, :require_two_factor_authentication_from_group) remove_column(:users, :two_factor_grace_period) end end diff --git a/db/schema.rb b/db/schema.rb index 2d2507828d4..62b9a766ff3 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -1249,7 +1249,7 @@ ActiveRecord::Schema.define(version: 20170402231018) do t.boolean "authorized_projects_populated" t.boolean "ghost" t.boolean "notified_of_own_activity" - t.boolean "require_two_factor_authentication", default: false, null: false + t.boolean "require_two_factor_authentication_from_group", default: false, null: false t.integer "two_factor_grace_period", default: 48, null: false end -- cgit v1.2.3