summaryrefslogtreecommitdiff
path: root/app/models/key.rb
diff options
context:
space:
mode:
Diffstat (limited to 'app/models/key.rb')
-rw-r--r--app/models/key.rb12
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