Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

remove initilize and move :url attribute processing into cas.rb #26

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
remove initilize and move :url attribute processing into cas.rb
  • Loading branch information
eriko committed Nov 19, 2013
commit 90a2665e1d50dd658f6108de9e476901a5a283fc
25 changes: 21 additions & 4 deletions lib/omniauth/strategies/cas.rb
Original file line number Diff line number Diff line change
Expand Up @@ -55,10 +55,6 @@ class InvalidCASTicket < StandardError; end
})
end

def initialize( app, *args, &block )
super
@configuration = Configuration.new( @options )
end

def callback_phase
@ticket = request.params['ticket']
Expand Down Expand Up @@ -89,6 +85,10 @@ def request_phase
#
#
def cas_url
extract_url if @options['url']

validate_cas_setup

@cas_url ||= begin
uri = Addressable::URI.new
uri.host = @options.host
Expand All @@ -100,6 +100,23 @@ def cas_url
end
end

def extract_url
url = Addressable::URI.parse( @options.delete('url') )

@options.merge!(
'host' => url.host,
'port' => url.port,
'path' => url.path,
'ssl' => url.scheme == 'https'
)
end

def validate_cas_setup
if @options.host.nil? || @options.login_url.nil?
raise ArgumentError.new(":host and :login_url MUST be provided")
end
end

# Build a service-validation URL from +service+ and +ticket+.
# If +service+ has a ticket param, first remove it. URL-encode
# +service+ and add it and the +ticket+ as paraemters to the
Expand Down
34 changes: 0 additions & 34 deletions lib/omniauth/strategies/cas/configuration.rb

This file was deleted.