Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'app/models/key.rb')
-rw-r--r--app/models/key.rb15
1 files changed, 7 insertions, 8 deletions
diff --git a/app/models/key.rb b/app/models/key.rb
index 42ea0f29171..e093f9faad3 100644
--- a/app/models/key.rb
+++ b/app/models/key.rb
@@ -5,7 +5,7 @@ require 'digest/md5'
class Key < ApplicationRecord
include AfterCommitQueue
include Sortable
- include Sha256Attribute
+ include ShaAttribute
include Expirable
include FromUnion
@@ -24,17 +24,12 @@ class Key < ApplicationRecord
length: { maximum: 5000 },
format: { with: /\A(#{Gitlab::SSHPublicKey.supported_algorithms.join('|')})/ }
- validates :fingerprint,
- uniqueness: true,
- presence: { message: 'cannot be generated' },
- unless: -> { Gitlab::FIPS.enabled? }
-
validates :fingerprint_sha256,
uniqueness: true,
- presence: { message: 'cannot be generated' },
- if: -> { Gitlab::FIPS.enabled? }
+ presence: { message: 'cannot be generated' }
validate :key_meets_restrictions
+ validate :expiration, on: :create
delegate :name, :email, to: :user, prefix: true
@@ -154,6 +149,10 @@ class Key < ApplicationRecord
"type is forbidden. Must be #{Gitlab::Utils.to_exclusive_sentence(allowed_types)}"
end
+
+ def expiration
+ errors.add(:key, message: 'has expired') if expired?
+ end
end
Key.prepend_mod_with('Key')