parent
483f99f401
commit
0635c1e98b
@ -0,0 +1,37 @@
|
|||||||
|
#coding=utf-8
|
||||||
|
|
||||||
|
require 'base64'
|
||||||
|
require 'json'
|
||||||
|
require 'openssl'
|
||||||
|
|
||||||
|
## 单点登录 <=> 北斗
|
||||||
|
class SsoController < ApplicationController
|
||||||
|
|
||||||
|
def index
|
||||||
|
options = parse(params[:auth])
|
||||||
|
|
||||||
|
logger.debug options
|
||||||
|
|
||||||
|
## 认证
|
||||||
|
login(options[:id])
|
||||||
|
|
||||||
|
## 选择性跳转
|
||||||
|
|
||||||
|
redirect_to Organization.find(82)
|
||||||
|
|
||||||
|
end
|
||||||
|
|
||||||
|
private
|
||||||
|
def parse(auth)
|
||||||
|
crypted_str = Base64.decode64(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)
|
||||||
|
JSON.parser(content)
|
||||||
|
end
|
||||||
|
|
||||||
|
def login(id)
|
||||||
|
|
||||||
|
start_user_session(user)
|
||||||
|
end
|
||||||
|
|
||||||
|
end
|
Loading…
Reference in new issue