添加单点登录controller
This commit is contained in:
parent
483f99f401
commit
0635c1e98b
2
Gemfile
2
Gemfile
|
@ -45,11 +45,11 @@ gem 'elasticsearch-rails'
|
|||
|
||||
### profile
|
||||
#gem 'oneapm_rpm'
|
||||
#gem "query_reviewer", group: :development
|
||||
|
||||
group :development do
|
||||
gem 'grape-swagger'
|
||||
gem 'better_errors', '~> 1.1.0'
|
||||
gem "query_reviewer"
|
||||
# gem 'rack-mini-profiler', '~> 0.9.3'
|
||||
if RUBY_PLATFORM =~ /w32/
|
||||
gem 'win32console'
|
||||
|
|
|
@ -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
|
|
@ -1197,6 +1197,8 @@ RedmineApp::Application.routes.draw do
|
|||
end
|
||||
end
|
||||
|
||||
get '/sso', to: 'sso#index'
|
||||
|
||||
get '/:sub_dir_name', :to => 'org_subfields#show', :as => 'show_subfield_without_id'
|
||||
|
||||
Dir.glob File.expand_path("plugins/*", Rails.root) do |plugin_dir|
|
||||
|
|
Loading…
Reference in New Issue