Add logout url.
This commit is contained in:
parent
1311d8fd66
commit
059cddf9bb
|
@ -1,6 +1,16 @@
|
||||||
class SsoLoginBoxController < SessionsController
|
class SsoLoginBoxController < SessionsController
|
||||||
require 'openssl'
|
require 'openssl'
|
||||||
OpenSSL::SSL::VERIFY_PEER = OpenSSL::SSL::VERIFY_NONE
|
OpenSSL::SSL::VERIFY_PEER = OpenSSL::SSL::VERIFY_NONE
|
||||||
|
def self.logout #Token Revocation
|
||||||
|
session = OrbitHelper.request.session
|
||||||
|
if session[:sso_token]
|
||||||
|
token_connection = Faraday.new 'https://cas.ccu.edu.tw/oauth2.0/revoke'
|
||||||
|
token_response = token_connection.post do |request|
|
||||||
|
request.params['token'] = session[:sso_token]
|
||||||
|
request.params['token_type_hint'] = 'access_token'
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
def oauth2_auth_page
|
def oauth2_auth_page
|
||||||
session[:referer_url] = params[:referer_url]
|
session[:referer_url] = params[:referer_url]
|
||||||
redirect_to "https://cas.ccu.edu.tw/oauth2.0/authorize?response_type=#{ENV['RESPONSE_TYPE']}&client_id=#{ENV['APP_ID']}&redirect_uri=#{ENV['REDIRECT_URI']}"
|
redirect_to "https://cas.ccu.edu.tw/oauth2.0/authorize?response_type=#{ENV['RESPONSE_TYPE']}&client_id=#{ENV['APP_ID']}&redirect_uri=#{ENV['REDIRECT_URI']}"
|
||||||
|
@ -29,6 +39,7 @@ class SsoLoginBoxController < SessionsController
|
||||||
user_name = JSON.parse(account_response.body)['id']
|
user_name = JSON.parse(account_response.body)['id']
|
||||||
user = User.find_by(user_name: user_name) rescue nil
|
user = User.find_by(user_name: user_name) rescue nil
|
||||||
if !user.nil?
|
if !user.nil?
|
||||||
|
session[:sso_token] = token
|
||||||
session[:user_id] = user.id
|
session[:user_id] = user.id
|
||||||
session[:login_referer] = nil
|
session[:login_referer] = nil
|
||||||
if session[:referer_url].present?
|
if session[:referer_url].present?
|
||||||
|
|
|
@ -1,4 +1,10 @@
|
||||||
require "sso_login_box/engine"
|
require "sso_login_box/engine"
|
||||||
|
|
||||||
module SsoLoginBox
|
module SsoLoginBox
|
||||||
|
# def self.controller_name #if defined, call controller's logout method
|
||||||
|
# "SsoLoginBoxController"
|
||||||
|
# end
|
||||||
|
def self.logout_url
|
||||||
|
"https://cas.ccu.edu.tw/logout"
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in New Issue