Skip to content

Commit fdd9b24

Browse files
author
GitLab Bot
committed
Add latest changes from gitlab-org/gitlab@master
1 parent 7486638 commit fdd9b24

35 files changed

+336
-47
lines changed

app/assets/javascripts/notes/components/mr_discussion_filter.vue

+5-2
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ import {
1111
import { mapActions, mapState } from 'vuex';
1212
import { InternalEvents } from '~/tracking';
1313
import LocalStorageSync from '~/vue_shared/components/local_storage_sync.vue';
14-
import { __ } from '~/locale';
14+
import { sprintf, __ } from '~/locale';
1515
import { SORT_DIRECTION_UI } from '~/search/sort/constants';
1616
import {
1717
MR_FILTER_OPTIONS,
@@ -63,7 +63,10 @@ export default {
6363
return __('All activity');
6464
}
6565
if (length > 1) {
66-
return `%{strongStart}${firstSelected.text}%{strongEnd} +${length - 1} more`;
66+
return sprintf(__('%{strongStart}%{firstSelected}%{strongEnd} +%{length} more'), {
67+
firstSelected: firstSelected.text,
68+
length: length - 1,
69+
});
6770
}
6871
6972
return firstSelected.text;

app/assets/javascripts/work_items/components/work_item_description.vue

+3-5
Original file line numberDiff line numberDiff line change
@@ -46,11 +46,9 @@ export default {
4646
},
4747
mixins: [Tracking.mixin(), glFeatureFlagMixin()],
4848
provide: {
49-
editorAiActions() {
50-
return window.gon?.licensed_features?.generateDescription
51-
? [generateDescriptionAction()]
52-
: [];
53-
},
49+
editorAiActions: window.gon?.licensed_features?.generateDescription
50+
? [generateDescriptionAction()]
51+
: [],
5452
},
5553
inject: ['isGroup'],
5654
props: {

app/helpers/application_settings_helper.rb

+1
Original file line numberDiff line numberDiff line change
@@ -400,6 +400,7 @@ def visible_attributes
400400
:restricted_visibility_levels,
401401
:rsa_key_restriction,
402402
:session_expire_delay,
403+
:session_expire_from_init,
403404
:shared_runners_enabled,
404405
:shared_runners_text,
405406
:sign_in_restrictions,

app/helpers/releases_helper.rb

+12-8
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,6 @@ def deployments_for_release
9393
commit = project.repository.commit(@release.tag)
9494

9595
deployments.map do |deployment|
96-
user = deployment.deployable&.user
9796
environment = deployment.environment
9897

9998
{
@@ -114,19 +113,24 @@ def deployments_for_release
114113
title: commit.title
115114
},
116115

117-
triggerer: if user
118-
{
119-
name: user.name,
120-
web_url: user_url(user),
121-
avatar_url: user.avatar_url
122-
}
123-
end,
116+
triggerer: triggerer_data(deployment),
124117

125118
created_at: deployment.created_at,
126119
finished_at: deployment.finished_at
127120
}
128121
end
129122
end
123+
124+
def triggerer_data(deployment)
125+
user = deployment.deployable&.user
126+
return unless user
127+
128+
{
129+
name: user.name,
130+
web_url: user_url(user),
131+
avatar_url: user.avatar_url
132+
}
133+
end
130134
end
131135

132136
ReleasesHelper.prepend_mod_with('ReleasesHelper')

app/helpers/sessions_helper.rb

+5-1
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,11 @@ def obfuscated_email(email)
1313
end
1414

1515
def remember_me_enabled?
16-
Gitlab::CurrentSettings.remember_me_enabled?
16+
Gitlab::CurrentSettings.remember_me_enabled? &&
17+
(
18+
Feature.enabled?(:session_expire_from_init, :instance) &&
19+
!Gitlab::CurrentSettings.session_expire_from_init
20+
)
1721
end
1822

1923
def unconfirmed_verification_email?(user)

app/models/active_session.rb

+23-2
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,8 @@ def self.set(user, request)
7676
session_private_id = request.session.id.private_id
7777
client = Gitlab::SafeDeviceDetector.new(request.user_agent)
7878
timestamp = Time.current
79-
expiry = Settings.gitlab['session_expire_delay'] * 60
79+
key = key_name(user.id, session_private_id)
80+
expiry = expiry_time(key)
8081

8182
active_user_session = new(
8283
ip_address: request.remote_ip,
@@ -94,7 +95,7 @@ def self.set(user, request)
9495
Gitlab::Instrumentation::RedisClusterValidator.allow_cross_slot_commands do
9596
redis.pipelined do |pipeline|
9697
pipeline.setex(
97-
key_name(user.id, session_private_id),
98+
key,
9899
expiry,
99100
active_user_session.dump
100101
)
@@ -169,6 +170,26 @@ def self.destroy_all_but_current(user, current_rack_session)
169170
"#{Gitlab::Redis::Sessions::SESSION_NAMESPACE}:#{session_id}"
170171
end
171172

173+
def self.expiry_time(key)
174+
# initialize to defaults
175+
ttl = Settings.gitlab['session_expire_delay'] * 60
176+
177+
return ttl unless Feature.enabled?(:session_expire_from_init, :instance) &&
178+
Gitlab::CurrentSettings.session_expire_from_init
179+
180+
# If we're initializing a session, there won't already be a session
181+
# Only use current session TTL if we have expire session from init enabled
182+
Gitlab::Redis::Sessions.with do |redis|
183+
# redis returns -2 if the key doesn't exist, -1 if no TTL
184+
ttl_expire = redis.ttl(key)
185+
186+
# for new sessions, return default ttl, otherwise, keep same ttl
187+
ttl = ttl_expire if ttl_expire > -1
188+
end
189+
190+
ttl
191+
end
192+
172193
def self.key_name(user_id, session_id = '*')
173194
"#{Gitlab::Redis::Sessions::USER_SESSIONS_NAMESPACE}::v2:#{user_id}:#{session_id}"
174195
end

app/models/application_setting.rb

+2-1
Original file line numberDiff line numberDiff line change
@@ -700,7 +700,8 @@ def self.kroki_formats_attributes
700700

701701
jsonb_accessor :sign_in_restrictions,
702702
disable_password_authentication_for_users_with_sso_identities: [:boolean, { default: false }],
703-
root_moved_permanently_redirection: [:boolean, { default: false }]
703+
root_moved_permanently_redirection: [:boolean, { default: false }],
704+
session_expire_from_init: [:boolean, { default: false }]
704705

705706
validates :sign_in_restrictions, json_schema: { filename: 'application_setting_sign_in_restrictions' }
706707

app/models/application_setting_implementation.rb

+1
Original file line numberDiff line numberDiff line change
@@ -180,6 +180,7 @@ def defaults # rubocop:disable Metrics/AbcSize
180180
restricted_visibility_levels: Settings.gitlab['restricted_visibility_levels'],
181181
rsa_key_restriction: default_min_key_size(:rsa),
182182
session_expire_delay: Settings.gitlab['session_expire_delay'],
183+
session_expire_from_init: false,
183184
shared_runners_enabled: Settings.gitlab_ci['shared_runners_enabled'],
184185
shared_runners_text: nil,
185186
sidekiq_job_limiter_mode: Gitlab::SidekiqMiddleware::SizeLimiter::Validator::COMPRESS_MODE,

app/models/vulnerability.rb

-2
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,6 @@ class Vulnerability < Gitlab::Database::SecApplicationRecord
66
include AfterCommitQueue
77
include IgnorableColumns
88

9-
ignore_column :confidence, :confidence_overridden, remove_after: '2025-01-19', remove_with: '17.9'
10-
119
alias_attribute :vulnerability_id, :id
1210

1311
scope :with_projects, -> { preload(:project) }

app/validators/json_schemas/application_setting_sign_in_restrictions.json

+4
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,10 @@
1111
"root_moved_permanently_redirection": {
1212
"type": "boolean",
1313
"description": "When enabled, it will send 301 Moved Permanently instead of 302 if you want web crawlers to index a different site such as the Home Page URL."
14+
},
15+
"session_expire_from_init": {
16+
"type": "boolean",
17+
"description": "When enabled, sessions will expire a specific time after creation even if the session is active. Sessions cannot be extended."
1418
}
1519
}
1620
}

app/views/admin/application_settings/_account_and_limit.html.haml

+8-3
Original file line numberDiff line numberDiff line change
@@ -19,9 +19,14 @@
1919
= f.label :receive_max_input_size, _('Maximum push size (MiB)'), class: 'label-light'
2020
= f.number_field :receive_max_input_size, class: 'form-control gl-form-input', title: _('Maximum size limit for a single commit.'), data: { toggle: 'tooltip', container: 'body', testid: 'receive-max-input-size-field' }
2121
.form-group
22-
= f.label :session_expire_delay, _('Session duration (minutes)'), class: 'label-light'
23-
= f.number_field :session_expire_delay, class: 'form-control gl-form-input', title: _('Maximum duration of a session.'), data: { toggle: 'tooltip', container: 'body' }
24-
%span.form-text.gl-text-subtle#session_expire_delay_help_block= _('Restart GitLab to apply changes.')
22+
= f.label :session_expire_delay, s_('Settings|Session timeout duration'), class: 'label-light'
23+
= f.number_field :session_expire_delay, class: 'form-control gl-form-input', title: _('Maximum duration of a session. Restart GitLab to apply changes.'), data: { toggle: 'tooltip', container: 'body' }
24+
.form-text.gl-text-subtle= s_('Settings|Session duration, in minutes. Restart GitLab to apply changes.')
25+
- if Feature.enabled?(:session_expire_from_init, :instance)
26+
.form-group
27+
= f.label :session_expire_from_init, s_('Settings|Session settings')
28+
= f.gitlab_ui_radio_component :session_expire_from_init, false, s_('Settings|Expire from time of last session activity')
29+
= f.gitlab_ui_radio_component :session_expire_from_init, true, s_('Settings|Expire from time of session creation')
2530
.form-group
2631
= f.label :remember_me_enabled, _('Remember me'), class: 'label-light'
2732
- remember_me_help_link = help_page_path('user/profile/_index.md', anchor: 'stay-signed-in-for-two-weeks')
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
---
2+
name: session_expire_from_init
3+
feature_issue_url: https://gitlab.com/gitlab-org/gitlab/-/issues/395038
4+
introduced_by_url: https://gitlab.com/gitlab-org/gitlab/-/merge_requests/183472
5+
rollout_issue_url: https://gitlab.com/gitlab-org/gitlab/-/issues/471679
6+
milestone: '17.11'
7+
group: group::authentication
8+
type: beta
9+
default_enabled: false

config/initializers/1_settings.rb

+1
Original file line numberDiff line numberDiff line change
@@ -231,6 +231,7 @@
231231
Settings.gitlab['graphql_timeout'] ||= 30
232232
Settings.gitlab['max_attachment_size'] ||= 100
233233
Settings.gitlab['session_expire_delay'] ||= 10080
234+
Settings.gitlab['session_expire_from_init'] ||= false
234235
Settings.gitlab['unauthenticated_session_expire_delay'] ||= 2.hours.to_i
235236
Settings.gitlab.default_projects_features['issues'] = true if Settings.gitlab.default_projects_features['issues'].nil?
236237
Settings.gitlab.default_projects_features['merge_requests'] = true if Settings.gitlab.default_projects_features['merge_requests'].nil?
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
# frozen_string_literal: true
2+
3+
class AddOrganizationIdToMergeRequestDiffCommitUsers < Gitlab::Database::Migration[2.2]
4+
milestone '17.11'
5+
6+
def change
7+
add_column :merge_request_diff_commit_users, :organization_id, :bigint
8+
end
9+
end
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
# frozen_string_literal: true
2+
3+
class AddUniqueIndexOnOrgIdNameEmailToMergeRequestDiffCommitUsers < Gitlab::Database::Migration[2.2]
4+
milestone '17.11'
5+
disable_ddl_transaction!
6+
7+
TABLE_NAME = :merge_request_diff_commit_users
8+
INDEX_NAME = 'index_merge_request_diff_commit_users_on_org_id_name_email'
9+
10+
def up
11+
add_concurrent_index TABLE_NAME, %w[organization_id name email], unique: true, name: INDEX_NAME
12+
end
13+
14+
def down
15+
remove_concurrent_index_by_name TABLE_NAME, INDEX_NAME
16+
end
17+
end
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
# frozen_string_literal: true
2+
3+
class AddForeignKeyToMergeRequestDiffCommitUsersOrganizationId < Gitlab::Database::Migration[2.2]
4+
milestone '17.11'
5+
disable_ddl_transaction!
6+
7+
def up
8+
add_concurrent_foreign_key :merge_request_diff_commit_users, :organizations, column: :organization_id,
9+
on_delete: :cascade
10+
end
11+
12+
def down
13+
with_lock_retries do
14+
remove_foreign_key :merge_request_diff_commit_users, column: :organization_id
15+
end
16+
end
17+
end

db/schema_migrations/20250319141850

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
59d9aa96e89873696dae1f3efb2eaac19874b6b136d35814a55c4317a8a23548

db/schema_migrations/20250319152240

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
06d4bd31858f437880fe1165d5070fa66c9b954e6298e2c4d28117025057ccd6

db/schema_migrations/20250319152360

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
dbc8263402fcc24ca1538bb1c74f7e24daae6c8e59f445110ed39b18b262ec2f

db/structure.sql

+6
Original file line numberDiff line numberDiff line change
@@ -16907,6 +16907,7 @@ CREATE TABLE merge_request_diff_commit_users (
1690716907
id bigint NOT NULL,
1690816908
name text,
1690916909
email text,
16910+
organization_id bigint,
1691016911
CONSTRAINT check_147358fc42 CHECK ((char_length(name) <= 512)),
1691116912
CONSTRAINT check_f5fa206cf7 CHECK ((char_length(email) <= 512)),
1691216913
CONSTRAINT merge_request_diff_commit_users_name_or_email_existence CHECK (((COALESCE(name, ''::text) <> ''::text) OR (COALESCE(email, ''::text) <> ''::text)))
@@ -35425,6 +35426,8 @@ CREATE INDEX index_merge_request_context_commits_on_project_id ON merge_request_
3542535426

3542635427
CREATE UNIQUE INDEX index_merge_request_diff_commit_users_on_name_and_email ON merge_request_diff_commit_users USING btree (name, email);
3542735428

35429+
CREATE UNIQUE INDEX index_merge_request_diff_commit_users_on_org_id_name_email ON merge_request_diff_commit_users USING btree (organization_id, name, email);
35430+
3542835431
CREATE INDEX index_merge_request_diff_commits_on_sha ON merge_request_diff_commits USING btree (sha);
3542935432

3543035433
CREATE INDEX index_merge_request_diff_details_failed_verification ON merge_request_diff_details USING btree (verification_retry_at NULLS FIRST) WHERE (verification_state = 3);
@@ -42423,6 +42426,9 @@ ALTER TABLE ONLY observability_logs_issues_connections
4242342426
ALTER TABLE ONLY packages_package_files
4242442427
ADD CONSTRAINT fk_86f0f182f8 FOREIGN KEY (package_id) REFERENCES packages_packages(id) ON DELETE CASCADE;
4242542428

42429+
ALTER TABLE ONLY merge_request_diff_commit_users
42430+
ADD CONSTRAINT fk_87f203759e FOREIGN KEY (organization_id) REFERENCES organizations(id) ON DELETE CASCADE;
42431+
4242642432
ALTER TABLE ONLY packages_pypi_metadata
4242742433
ADD CONSTRAINT fk_884056a10f FOREIGN KEY (project_id) REFERENCES projects(id) ON DELETE CASCADE;
4242842434

doc/administration/settings/account_and_limit_settings.md

+29
Original file line numberDiff line numberDiff line change
@@ -238,6 +238,35 @@ If [Remember me](#turn-remember-me-on-or-off) is enabled, users' sessions can re
238238

239239
For details, see [cookies used for sign-in](../../user/profile/_index.md#cookies-used-for-sign-in).
240240

241+
### Set sessions to expire from creation date
242+
243+
{{< history >}}
244+
245+
- [Introduced](https://gitlab.com/gitlab-org/gitlab/-/issues/395038) in GitLab 17.11 with a [flag](../feature_flags.md) named `session_expire_from_init`. Disabled by default.
246+
247+
{{< /history >}}
248+
249+
{{< alert type="flag" >}}
250+
251+
The availability of session expiry from creation dates is controlled by a feature flag.
252+
For more information, see the history.
253+
254+
{{< /alert >}}
255+
256+
By default, sessions expire a set amount of time after the session becomes inactive. Instead, you can configure sessions to expire a set amount of time after the session is created.
257+
258+
When the session duration is met, the session ends and the user is signed out even if:
259+
260+
- The user is still actively using the session.
261+
- The user selected [remember me](#turn-remember-me-on-or-off) during sign in.
262+
263+
1. On the left sidebar, at the bottom, select **Admin Area**.
264+
1. Select **Settings > General**.
265+
1. Expand **Account and limit**.
266+
1. Select the **Expire session from creation date** checkbox.
267+
268+
After a session ends, a window prompts the user to sign in again.
269+
241270
### Turn **Remember me** on or off
242271

243272
{{< history >}}

doc/api/settings.md

+1
Original file line numberDiff line numberDiff line change
@@ -679,6 +679,7 @@ to configure other related settings. These requirements are
679679
| `restricted_visibility_levels` | array of strings | no | Selected levels cannot be used by non-Administrator users for groups, projects or snippets. Can take `private`, `internal` and `public` as a parameter. Default is `null` which means there is no restriction.[Changed](https://gitlab.com/gitlab-org/gitlab/-/merge_requests/131203) in GitLab 16.4: cannot select levels that are set as `default_project_visibility` and `default_group_visibility`. |
680680
| `rsa_key_restriction` | integer | no | The minimum allowed bit length of an uploaded RSA key. Default is `0` (no restriction). `-1` disables RSA keys. |
681681
| `session_expire_delay` | integer | no | Session duration in minutes. GitLab restart is required to apply changes. |
682+
| `session_expire_from_init` | boolean | no | If `true`, sessions expire a number of minutes after the session was created rather than after the last activity. This lifetime of a session is defined by `session_expire_delay`. |
682683
| `security_policy_global_group_approvers_enabled` | boolean | no | Whether to look up merge request approval policy approval groups globally or within project hierarchies. |
683684
| `security_approval_policies_limit` | integer | no | Maximum number of active merge request approval policies per security policy project. Default: 5. Maximum: 20 |
684685
| `security_txt_content` | string | no | [Public security contact information](../administration/settings/security_contact_information.md). [Introduced](https://gitlab.com/gitlab-org/gitlab/-/issues/433210) in GitLab 16.7. |

doc/development/cells/application_settings_analysis.md

+4-4
Original file line numberDiff line numberDiff line change
@@ -14,12 +14,12 @@ title: Application Settings analysis
1414

1515
## Statistics
1616

17-
- Number of attributes: 492
17+
- Number of attributes: 493
1818
- Number of encrypted attributes: 41 (8.0%)
19-
- Number of attributes documented: 298 (61.0%)
19+
- Number of attributes documented: 298 (60.0%)
2020
- Number of attributes on GitLab.com different from the defaults: 222 (45.0%)
21-
- Number of attributes with `clusterwide` set: 492 (100.0%)
22-
- Number of attributes with `clusterwide: true` set: 123 (25.0%)
21+
- Number of attributes with `clusterwide` set: 493 (100.0%)
22+
- Number of attributes with `clusterwide: true` set: 124 (25.0%)
2323

2424
## Individual columns
2525

doc/development/sec/analyzer_development_guide.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -429,7 +429,7 @@ Verify whether the underlying tool has:
429429
#### Dockerfile
430430

431431
The `Dockerfile` should use an unprivileged user with the name `GitLab`.
432-
This is necessary is to provide compatibility with Red Hat OpenShift instances,
432+
This is necessary to provide compatibility with Red Hat OpenShift instances,
433433
which don't allow containers to run as an admin (root) user.
434434
There are certain limitations to keep in mind when running a container as an unprivileged user,
435435
such as the fact that any files that need to be written on the Docker filesystem will require the appropriate permissions for the `GitLab` user.

doc/user/workspace/_index.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -139,7 +139,7 @@ components:
139139
attributes:
140140
gl/inject-editor: true
141141
container:
142-
image: "registry.gitlab.com/gitlab-org/gitlab-build-images/workspaces/ubuntu-24.04:20250303043223-golang-1.23-docker-27.5.1@sha256:98f36ddf5d7ac53d95a270f5791ab7f50132a4cc87676e22f4f632678d8e15e1"
142+
image: "registry.gitlab.com/gitlab-org/gitlab-build-images/workspaces/ubuntu-24.04:20250321073701-golang-1.23-node-23.9-yarn-1.22-ruby-3.4.2-rust-1.85-docker-27.5.1@sha256:a059826e65f0bc0ee2f3fdfd62f16a108c5b99b24b4656734cd6b8f4631389ad"
143143
```
144144
145145
A GitLab default devfile might not be suitable for all development environments configurations.

lib/api/settings.rb

+1
Original file line numberDiff line numberDiff line change
@@ -166,6 +166,7 @@ def filter_attributes_using_license(attrs)
166166
end
167167
optional :restricted_visibility_levels, type: Array[String], coerce_with: Validations::Types::CommaSeparatedToArray.coerce, desc: 'Selected levels cannot be used by non-admin users for groups, projects or snippets. If the public level is restricted, user profiles are only visible to logged in users.'
168168
optional :session_expire_delay, type: Integer, desc: 'Session duration in minutes. GitLab restart is required to apply changes.'
169+
optional :session_expire_from_init, type: Boolean, desc: 'Expires sessions based off the creation date rather than last activity'
169170
optional :shared_runners_enabled, type: Boolean, desc: 'Enable shared runners for new projects'
170171
given shared_runners_enabled: ->(val) { val } do
171172
requires :shared_runners_text, type: String, desc: 'Shared runners text '

0 commit comments

Comments
 (0)