Skip to content

Commit b7de9ec

Browse files
author
Brad Seefeld
committed
rubycas#42: Support legacy checks
1 parent 1308deb commit b7de9ec

File tree

1 file changed

+9
-2
lines changed

1 file changed

+9
-2
lines changed

lib/casclient/responses.rb

+9-2
Original file line numberDiff line numberDiff line change
@@ -190,8 +190,15 @@ def parse_http_response(http_response)
190190
if location =~ /ticket=([^&]+)/
191191
@ticket = $~[1]
192192
end
193-
194-
unless http_response.kind_of?(Net::HTTPSeeOther) && @ticket.present?
193+
194+
# Legacy check. CAS Server used to return a 200 (Success) or a 302 (Found) on successful authentication.
195+
# This behavior should be deprecated at some point in the future.
196+
legacy_valid_ticket = (http_response.kind_of?(Net::HTTPSuccess) || http_response.kind_of?(Net::HTTPFound)) && @ticket.present?
197+
198+
# If using rubycas-server 1.1.0+
199+
valid_ticket = http_response.kind_of?(Net::HTTPSeeOther) && @ticket.present?
200+
201+
if !legacy_valid_ticket && !valid_ticket
195202
@failure = true
196203
# Try to extract the error message -- this only works with RubyCAS-Server.
197204
# For other servers we just return the entire response body (i.e. the whole error page).

0 commit comments

Comments
 (0)