diff --git a/Gemfile b/Gemfile index 0c3fdc880..0174d73ac 100644 --- a/Gemfile +++ b/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' diff --git a/app/controllers/sso_controller.rb b/app/controllers/sso_controller.rb new file mode 100644 index 000000000..0ae7b7449 --- /dev/null +++ b/app/controllers/sso_controller.rb @@ -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 diff --git a/config/routes.rb b/config/routes.rb index 9599c705a..0592041f6 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -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|