Merge branch 'develop' into hjq_beidou
This commit is contained in:
commit
855b33c4a5
|
@ -55,10 +55,7 @@ class SsosController < ApplicationController
|
||||||
end
|
end
|
||||||
|
|
||||||
def parse(auth)
|
def parse(auth)
|
||||||
crypted_str = Base64.decode64(base64_safe(auth))
|
content = decrypt(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)
|
|
||||||
ActiveSupport::JSON.decode(content)
|
ActiveSupport::JSON.decode(content)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -68,4 +65,20 @@ class SsosController < ApplicationController
|
||||||
sso
|
sso
|
||||||
end
|
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
|
end
|
||||||
|
|
|
@ -1,3 +1,7 @@
|
||||||
|
#coding=utf-8
|
||||||
|
|
||||||
|
require 'base64'
|
||||||
|
|
||||||
class Sso < ActiveRecord::Base
|
class Sso < ActiveRecord::Base
|
||||||
belongs_to :user
|
belongs_to :user
|
||||||
attr_accessible :email, :name, :openid, :password, :school, :sex, :user, :user_id
|
attr_accessible :email, :name, :openid, :password, :school, :sex, :user, :user_id
|
||||||
|
@ -13,7 +17,7 @@ class Sso < ActiveRecord::Base
|
||||||
sso.openid = opt["openid"]
|
sso.openid = opt["openid"]
|
||||||
sso.email = opt["email"]
|
sso.email = opt["email"]
|
||||||
sso.password = opt["password"]
|
sso.password = opt["password"]
|
||||||
sso.school = opt["school"]
|
sso.school = Base64.decode64(opt["school"]).force_encoding('utf-8')
|
||||||
sso.sex = opt["sex"]
|
sso.sex = opt["sex"]
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue