From e25214af86715bdf5c4c0d876ffadcbe897cf409 Mon Sep 17 00:00:00 2001 From: Joseph Snyder Date: Wed, 5 Apr 2023 15:49:46 -0400 Subject: [PATCH] Add User Identities toggle to User Preferences Add a new column to the User Preferences table which will control the inclusion of the triggering user's identities in the JWT information sent to the job. Changelog: added --- app/models/user_preference.rb | 2 ++ ...0406134436_add_identity_toggle_to_user_preferences.rb | 9 +++++++++ db/schema_migrations/20230406134436 | 1 + db/structure.sql | 1 + spec/models/user_preference_spec.rb | 7 +++++++ 5 files changed, 20 insertions(+) create mode 100644 db/migrate/20230406134436_add_identity_toggle_to_user_preferences.rb create mode 100644 db/schema_migrations/20230406134436 diff --git a/app/models/user_preference.rb b/app/models/user_preference.rb index ecc64da20981c0..2519db825c0f27 100644 --- a/app/models/user_preference.rb +++ b/app/models/user_preference.rb @@ -24,6 +24,8 @@ class UserPreference < ApplicationRecord allow_blank: true validates :use_legacy_web_ide, allow_nil: false, inclusion: { in: [true, false] } + validates :pass_user_identities_to_ci_jwt, allow_nil: false, inclusion: { in: [true, false] } + validates :pinned_nav_items, json_schema: { filename: 'pinned_nav_items' } ignore_columns :experience_level, remove_with: '14.10', remove_after: '2021-03-22' diff --git a/db/migrate/20230406134436_add_identity_toggle_to_user_preferences.rb b/db/migrate/20230406134436_add_identity_toggle_to_user_preferences.rb new file mode 100644 index 00000000000000..0b7fcceb3ee219 --- /dev/null +++ b/db/migrate/20230406134436_add_identity_toggle_to_user_preferences.rb @@ -0,0 +1,9 @@ +# frozen_string_literal: true + +class AddIdentityToggleToUserPreferences < Gitlab::Database::Migration[2.1] + enable_lock_retries! + + def change + add_column :user_preferences, :pass_user_identities_to_ci_jwt, :boolean, default: false, null: false + end +end diff --git a/db/schema_migrations/20230406134436 b/db/schema_migrations/20230406134436 new file mode 100644 index 00000000000000..17d51bba6ce68a --- /dev/null +++ b/db/schema_migrations/20230406134436 @@ -0,0 +1 @@ +3b7a512959c9d109ee4b454693ebfafed624869c82fa64d92b3f780165e91feb \ No newline at end of file diff --git a/db/structure.sql b/db/structure.sql index a09543d9a57857..ab6a82471a928a 100644 --- a/db/structure.sql +++ b/db/structure.sql @@ -23382,6 +23382,7 @@ CREATE TABLE user_preferences ( use_new_navigation boolean, achievements_enabled boolean DEFAULT true NOT NULL, pinned_nav_items jsonb DEFAULT '{}'::jsonb NOT NULL, + pass_user_identities_to_ci_jwt boolean DEFAULT false NOT NULL, CONSTRAINT check_89bf269f41 CHECK ((char_length(diffs_deletion_color) <= 7)), CONSTRAINT check_d07ccd35f7 CHECK ((char_length(diffs_addition_color) <= 7)) ); diff --git a/spec/models/user_preference_spec.rb b/spec/models/user_preference_spec.rb index a6f64c90657ece..5c368b1632b33a 100644 --- a/spec/models/user_preference_spec.rb +++ b/spec/models/user_preference_spec.rb @@ -54,6 +54,13 @@ it { is_expected.not_to allow_value(nil).for(:use_legacy_web_ide) } it { is_expected.not_to allow_value("").for(:use_legacy_web_ide) } end + + describe 'pass_user_identities_to_ci_jwt' do + it { is_expected.to allow_value(true).for(:pass_user_identities_to_ci_jwt) } + it { is_expected.to allow_value(false).for(:pass_user_identities_to_ci_jwt) } + it { is_expected.not_to allow_value(nil).for(:pass_user_identities_to_ci_jwt) } + it { is_expected.not_to allow_value("").for(:pass_user_identities_to_ci_jwt) } + end end describe 'notes filters global keys' do -- GitLab