diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2022-04-20 13:00:54 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2022-04-20 13:00:54 +0300 |
commit | 3cccd102ba543e02725d247893729e5c73b38295 (patch) | |
tree | f36a04ec38517f5deaaacb5acc7d949688d1e187 /app/models/key.rb | |
parent | 205943281328046ef7b4528031b90fbda70c75ac (diff) |
Add latest changes from gitlab-org/gitlab@14-10-stable-eev14.10.0-rc42
Diffstat (limited to 'app/models/key.rb')
-rw-r--r-- | app/models/key.rb | 12 |
1 files changed, 9 insertions, 3 deletions
diff --git a/app/models/key.rb b/app/models/key.rb index 4a4e792c074..42ea0f29171 100644 --- a/app/models/key.rb +++ b/app/models/key.rb @@ -26,7 +26,13 @@ class Key < ApplicationRecord validates :fingerprint, uniqueness: true, - presence: { message: 'cannot be generated' } + presence: { message: 'cannot be generated' }, + unless: -> { Gitlab::FIPS.enabled? } + + validates :fingerprint_sha256, + uniqueness: true, + presence: { message: 'cannot be generated' }, + if: -> { Gitlab::FIPS.enabled? } validate :key_meets_restrictions @@ -43,7 +49,7 @@ class Key < ApplicationRecord scope :preload_users, -> { preload(:user) } scope :for_user, -> (user) { where(user: user) } - scope :order_last_used_at_desc, -> { reorder(::Gitlab::Database.nulls_last_order('last_used_at', 'DESC')) } + scope :order_last_used_at_desc, -> { reorder(arel_table[:last_used_at].desc.nulls_last) } # Date is set specifically in this scope to improve query time. scope :expired_today_and_not_notified, -> { where(["date(expires_at AT TIME ZONE 'UTC') = CURRENT_DATE AND expiry_notification_delivered_at IS NULL"]) } @@ -129,7 +135,7 @@ class Key < ApplicationRecord return unless public_key.valid? - self.fingerprint_md5 = public_key.fingerprint + self.fingerprint_md5 = public_key.fingerprint unless Gitlab::FIPS.enabled? self.fingerprint_sha256 = public_key.fingerprint_sha256.gsub("SHA256:", "") end |