プロジェクト

全般

プロフィール

Vote #79375

完了

Update session token only once per minute

Admin Redmine さんが約4年前に追加. 約4年前に更新.

ステータス:
Closed
優先度:
通常
担当者:
-
カテゴリ:
Performance_53
対象バージョン:
開始日:
2022/05/09
期日:
進捗率:

0%

予定工数:
category_id:
53
version_id:
155
issue_org_id:
29041
author_id:
123153
assigned_to_id:
332
comments:
9
status_id:
5
tracker_id:
2
plus1:
0
affected_version:
closed_on:
affected_version_id:
ステータス-->[Closed]

説明

this is simmilar to #28952

if Rails.application.config.redmine_verify_sessions is enabled, basically each read request triggers an update to tokens table. This is bad for performance because it blocks the database.
My patch transforms the update query into a select query that doesn't block on heavy load. We could actually update the token only once per hour which is the minimum available setting for Setting.session_lifetime and Setting.session_timeout, but redmine modifications could use smaller values, so I choose 1 minute interval. Smaller session_timeout then 1 minute won't work now, but I think such small timeout doesn't make much sense.


journals

--------------------------------------------------------------------------------

--------------------------------------------------------------------------------
ping Marius BALTEANU
--------------------------------------------------------------------------------
Pavel Rosický wrote:
> ping Marius BALTEANU

Pong. I've missed something?
--------------------------------------------------------------------------------
if you have time, could you review? https://www.redmine.org/attachments/20901/user.rb.patch

GET requests shouldn't update a database all the time. It's even more relevant for #29513

disabling Rails.application.config.redmine_verify_sessions isn't an option because it makes Redmine vulnerable

are there any security concerns about this change?
--------------------------------------------------------------------------------
Combined user.rb.patch and sessions_controller_test.rb.patch.
--------------------------------------------------------------------------------
I support the approach to reduce write traffic to the database. With this patch, the write contention on the tokens table and the Redmine database in general should be reduced quite a bit.

At first, I though that we would need to check whether we have only one valid token for the @maximum@ query too. Turns out that there is a unique index on the @tokens.value@ column in the database. As such, we are guaranteed to have only exactly zero or one token with a given value in the database. As both of these cases are checked by the patch, I think it should be fine and as secure as the previous version.

The slight reduction in accuracy is acceptable as the value is only used for session expiration where the difference of at most one minute is negligible. Enforcing session timeouts of less than one minute is not useful and does not need to be supported as it would effectively reduce the session to be only useful for (more-or-less) a single request.
--------------------------------------------------------------------------------
Setting the target version to 5.0.0.
--------------------------------------------------------------------------------
Committed the patch. Thank you.
--------------------------------------------------------------------------------


related_issues

relates,Closed,28952,Update User#last_login_on only once per minute

Admin Redmine さんが約4年前に更新

  • カテゴリPerformance_53 にセット
  • 対象バージョン5.0.0_155 にセット

他の形式にエクスポート: Atom PDF

いいね!0
いいね!0