添加单点登录controller

This commit is contained in:
guange 2016-05-04 14:05:46 +08:00
parent 483f99f401
commit 0635c1e98b
3 changed files with 40 additions and 1 deletions

View File

@ -45,11 +45,11 @@ gem 'elasticsearch-rails'
### profile ### profile
#gem 'oneapm_rpm' #gem 'oneapm_rpm'
#gem "query_reviewer", group: :development
group :development do group :development do
gem 'grape-swagger' gem 'grape-swagger'
gem 'better_errors', '~> 1.1.0' gem 'better_errors', '~> 1.1.0'
gem "query_reviewer"
# gem 'rack-mini-profiler', '~> 0.9.3' # gem 'rack-mini-profiler', '~> 0.9.3'
if RUBY_PLATFORM =~ /w32/ if RUBY_PLATFORM =~ /w32/
gem 'win32console' gem 'win32console'

View File

@ -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

View File

@ -1197,6 +1197,8 @@ RedmineApp::Application.routes.draw do
end end
end end
get '/sso', to: 'sso#index'
get '/:sub_dir_name', :to => 'org_subfields#show', :as => 'show_subfield_without_id' get '/:sub_dir_name', :to => 'org_subfields#show', :as => 'show_subfield_without_id'
Dir.glob File.expand_path("plugins/*", Rails.root) do |plugin_dir| Dir.glob File.expand_path("plugins/*", Rails.root) do |plugin_dir|