|
|
|
@ -55,10 +55,7 @@ class SsosController < ApplicationController
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
def parse(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(crypted_str,OpenSSL::PKey::RSA::PKCS1_PADDING)
|
|
|
|
|
# content = pkey.private_decrypt(crypted_str)
|
|
|
|
|
content = decrypt(auth)
|
|
|
|
|
ActiveSupport::JSON.decode(content)
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
@ -68,4 +65,20 @@ class SsosController < ApplicationController
|
|
|
|
|
sso
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
def decrypt(auth)
|
|
|
|
|
crypted_str = Base64.decode64(base64_safe(auth))
|
|
|
|
|
pkey = OpenSSL::PKey::RSA.new(File.new(File.join(Rails.root,"config/private.key")))
|
|
|
|
|
|
|
|
|
|
#to large
|
|
|
|
|
max_dec_len = 1024/8
|
|
|
|
|
size = (crypted_str.size + max_dec_len-1) / max_dec_len
|
|
|
|
|
|
|
|
|
|
content = ''
|
|
|
|
|
size.times do |time|
|
|
|
|
|
tmps = crypted_str[time*max_dec_len, max_dec_len]
|
|
|
|
|
content += pkey.private_decrypt(tmps,OpenSSL::PKey::RSA::PKCS1_PADDING)
|
|
|
|
|
end
|
|
|
|
|
content
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
end
|
|
|
|
|