Skip to content

Commit

Permalink
Merge pull request #50 from bradseefeld/master
Browse files Browse the repository at this point in the history
Fix bug #42 where we are unable to programmatically authenticate
  • Loading branch information
soupmatt committed Sep 10, 2012
2 parents 906bb76 + b7de9ec commit 342cbeb
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions lib/casclient/responses.rb
Original file line number Diff line number Diff line change
Expand Up @@ -190,8 +190,15 @@ def parse_http_response(http_response)
if location =~ /ticket=([^&]+)/
@ticket = $~[1]
end

if not ((http_response.kind_of?(Net::HTTPSuccess) || http_response.kind_of?(Net::HTTPFound)) && @ticket.present?)

# Legacy check. CAS Server used to return a 200 (Success) or a 302 (Found) on successful authentication.
# This behavior should be deprecated at some point in the future.
legacy_valid_ticket = (http_response.kind_of?(Net::HTTPSuccess) || http_response.kind_of?(Net::HTTPFound)) && @ticket.present?

# If using rubycas-server 1.1.0+
valid_ticket = http_response.kind_of?(Net::HTTPSeeOther) && @ticket.present?

if !legacy_valid_ticket && !valid_ticket
@failure = true
# Try to extract the error message -- this only works with RubyCAS-Server.
# For other servers we just return the entire response body (i.e. the whole error page).
Expand Down

0 comments on commit 342cbeb

Please sign in to comment.