Merge branch 'develop' into hjq_beidou
This commit is contained in:
commit
855b33c4a5
|
@ -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
|
||||
|
|
|
@ -1,3 +1,7 @@
|
|||
#coding=utf-8
|
||||
|
||||
require 'base64'
|
||||
|
||||
class Sso < ActiveRecord::Base
|
||||
belongs_to :user
|
||||
attr_accessible :email, :name, :openid, :password, :school, :sex, :user, :user_id
|
||||
|
@ -13,7 +17,7 @@ class Sso < ActiveRecord::Base
|
|||
sso.openid = opt["openid"]
|
||||
sso.email = opt["email"]
|
||||
sso.password = opt["password"]
|
||||
sso.school = opt["school"]
|
||||
sso.school = Base64.decode64(opt["school"]).force_encoding('utf-8')
|
||||
sso.sex = opt["sex"]
|
||||
|
||||
|
||||
|
|
Loading…
Reference in New Issue