safe base64

This commit is contained in:
guange 2016-05-04 16:54:12 +08:00
parent e9834f108a
commit eaad006d17
1 changed files with 8 additions and 3 deletions

View File

@ -24,11 +24,16 @@ class SsoController < ApplicationController
end
private
def base64_safe(content)
content = content.gsub('-', '+')
content.gsub('_', '/')
end
def parse(auth)
crypted_str = Base64.decode64(auth)
crypted_str = Base64.decode64(base64_safe(auth))
pkey = OpenSSL::PKey::RSA.new(File.new(File.join(Rails.root,"config/private.key")))
# content = pkey.private_decrypt(pwd,OpenSSL::PKey::RSA::NO_PADDING)
content = pkey.private_decrypt(crypted_str)
content = pkey.private_decrypt(crypted_str,OpenSSL::PKey::RSA::PKCS1_PADDING)
# content = pkey.private_decrypt(crypted_str)
JSON.parser(content)
end