diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2022-07-20 18:40:28 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2022-07-20 18:40:28 +0300 |
commit | b595cb0c1dec83de5bdee18284abe86614bed33b (patch) | |
tree | 8c3d4540f193c5ff98019352f554e921b3a41a72 /app/models/key.rb | |
parent | 2f9104a328fc8a4bddeaa4627b595166d24671d0 (diff) |
Add latest changes from gitlab-org/gitlab@15-2-stable-eev15.2.0-rc42
Diffstat (limited to 'app/models/key.rb')
-rw-r--r-- | app/models/key.rb | 14 |
1 files changed, 7 insertions, 7 deletions
diff --git a/app/models/key.rb b/app/models/key.rb index 5268ce2e040..9f6029cc5d4 100644 --- a/app/models/key.rb +++ b/app/models/key.rb @@ -28,7 +28,7 @@ class Key < ApplicationRecord validate :key_meets_restrictions validate :expiration, on: :create - validate :banned_key, if: :should_check_for_banned_key? + validate :banned_key, if: :key_changed? delegate :name, :email, to: :user, prefix: true @@ -121,6 +121,12 @@ class Key < ApplicationRecord @public_key ||= Gitlab::SSHPublicKey.new(key) end + def ensure_sha256_fingerprint! + return if self.fingerprint_sha256 + + save if generate_fingerprint + end + private def generate_fingerprint @@ -143,12 +149,6 @@ class Key < ApplicationRecord end end - def should_check_for_banned_key? - return false unless user - - key_changed? && Feature.enabled?(:ssh_banned_key, user) - end - def banned_key return unless public_key.banned? |