Sha256: 0047fc255e8ebcaea8deed781ef2d501bbab5931a09cf7989814fec1afba7388
Contents?: true
Size: 1.29 KB
Versions: 7
Compression:
Stored size: 1.29 KB
Contents
require 'omniauth/enterprise' module OmniAuth module Strategies class CAS include OmniAuth::Strategy autoload :Configuration, 'omniauth/strategies/cas/configuration' autoload :ServiceTicketValidator, 'omniauth/strategies/cas/service_ticket_validator' def initialize(app, options = {}, &block) super(app, options[:name] || :cas, options.dup, &block) @configuration = OmniAuth::Strategies::CAS::Configuration.new(options) end protected def request_phase [ 302, { 'Location' => @configuration.login_url(callback_url), 'Content-Type' => 'text/plain' }, ["You are being redirected to CAS for sign-in."] ] end def callback_phase ticket = request.params['ticket'] return fail!(:no_ticket, 'No CAS Ticket') unless ticket validator = ServiceTicketValidator.new(@configuration, callback_url, ticket) @user_info = validator.user_info return fail!(:invalid_ticket, 'Invalid CAS Ticket') if @user_info.nil? || @user_info.empty? super end def auth_hash OmniAuth::Utils.deep_merge(super, { 'uid' => @user_info.delete('user'), 'extra' => @user_info }) end end end end
Version data entries
7 entries across 7 versions & 2 rubygems