Permalink
Browse files

#42: Support legacy checks

  • Loading branch information...
1 parent 1308deb commit b7de9ece870f189e56193a0333374e5776d8f2da Brad Seefeld committed Sep 7, 2012
Showing with 9 additions and 2 deletions.
  1. +9 −2 lib/casclient/responses.rb
View
@@ -190,8 +190,15 @@ def parse_http_response(http_response)
if location =~ /ticket=([^&]+)/
@ticket = $~[1]
end
-
- unless http_response.kind_of?(Net::HTTPSeeOther) && @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).

0 comments on commit b7de9ec

Please sign in to comment.