mirror of
https://github.com/OpenNebula/one.git
synced 2025-03-21 14:50:08 +03:00
feature #1741: escape spaces instead of deleting them in x509 auth
This commit is contained in:
parent
1e0d87c147
commit
efbaff9b9a
@ -42,6 +42,14 @@ class OpenNebula::X509Auth
|
||||
:ca_dir => ETC_LOCATION + "/auth/certificates"
|
||||
}
|
||||
|
||||
def self.escape_dn(dn)
|
||||
dn.gsub(/\s/) { |s| "\\"+s[0].ord.to_s(16) }
|
||||
end
|
||||
|
||||
def self.unescape_dn(dn)
|
||||
dn.gsub(/\\[0-9a-f]{2}/) { |s| s[1,2].to_i(16).chr }
|
||||
end
|
||||
|
||||
###########################################################################
|
||||
# Initialize x509Auth object
|
||||
#
|
||||
@ -81,7 +89,7 @@ class OpenNebula::X509Auth
|
||||
# Returns a valid password string to create a user using this auth driver.
|
||||
# In this case the dn of the user certificate.
|
||||
def password
|
||||
@cert_chain[0].subject.to_s.delete("\s")
|
||||
self.class.escape_dn(@cert_chain[0].subject.to_s)
|
||||
end
|
||||
|
||||
# Generates a login token in the form:
|
||||
@ -123,7 +131,8 @@ class OpenNebula::X509Auth
|
||||
|
||||
# Some DN in the chain must match a DN in the password
|
||||
dn_ok = @cert_chain.each do |cert|
|
||||
if pass.split('|').include?(cert.subject.to_s.delete("\s"))
|
||||
if pass.split('|').include?(
|
||||
self.class.escape_dn(cert.subject.to_s))
|
||||
break true
|
||||
end
|
||||
end
|
||||
|
@ -42,7 +42,8 @@ class OneUserHelper < OpenNebulaHelper::OneHelper
|
||||
end
|
||||
|
||||
if options[:driver] == OpenNebula::User::X509_AUTH
|
||||
password.delete!("\s")
|
||||
require 'opennebula/x509_auth'
|
||||
password = OpenNebula::X509Auth.escape_dn(password)
|
||||
end
|
||||
|
||||
if options[:sha1] || options[:driver] == OpenNebula::User::CIPHER_AUTH
|
||||
|
Loading…
x
Reference in New Issue
Block a user