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
path: root/lib
diff options
context:
space:
mode:
authorIan Baum <ibaum@gitlab.com>2018-02-12 22:05:31 +0300
committerIan Baum <ibaum@gitlab.com>2018-02-12 22:06:57 +0300
commite607fd796657afd214b8f25201919d3e33b3f35f (patch)
treea15d22d1963efdfd168f30b5a385fad68d9aa1ec /lib
parent769f732111a4479e540eeb61eff9f609fb683a2d (diff)
Merge branch 'rd-43185-revert-sanitize-extra-blank-spaces-used-when-uploading-a-ssh-key' into 'master'
Revert "Merge branch 'rd-40552-gitlab-should-check-if-keys-are-valid-before-saving' into 'master'" See merge request gitlab-org/gitlab-ce!17062
Diffstat (limited to 'lib')
-rw-r--r--lib/gitlab/ssh_public_key.rb28
1 files changed, 6 insertions, 22 deletions
diff --git a/lib/gitlab/ssh_public_key.rb b/lib/gitlab/ssh_public_key.rb
index 545e7c74f7e..89ca1298120 100644
--- a/lib/gitlab/ssh_public_key.rb
+++ b/lib/gitlab/ssh_public_key.rb
@@ -21,22 +21,6 @@ module Gitlab
technology(name)&.supported_sizes
end
- def self.sanitize(key_content)
- ssh_type, *parts = key_content.strip.split
-
- return key_content if parts.empty?
-
- parts.each_with_object("#{ssh_type} ").with_index do |(part, content), index|
- content << part
-
- if Gitlab::SSHPublicKey.new(content).valid?
- break [content, parts[index + 1]].compact.join(' ') # Add the comment part if present
- elsif parts.size == index + 1 # return original content if we've reached the last element
- break key_content
- end
- end
- end
-
attr_reader :key_text, :key
# Unqualified MD5 fingerprint for compatibility
@@ -53,23 +37,23 @@ module Gitlab
end
def valid?
- key.present? && bits && technology.supported_sizes.include?(bits)
+ key.present?
end
def type
- technology.name if key.present?
+ technology.name if valid?
end
def bits
- return if key.blank?
+ return unless valid?
case type
when :rsa
- key.n&.num_bits
+ key.n.num_bits
when :dsa
- key.p&.num_bits
+ key.p.num_bits
when :ecdsa
- key.group.order&.num_bits
+ key.group.order.num_bits
when :ed25519
256
else