Skip to content

Commit

Permalink
Added LoginTicket to URL API so that client's login_to_service can re…
Browse files Browse the repository at this point in the history
…trieve a login ticket
  • Loading branch information
dvantuyl authored and zuk committed Jun 28, 2011
1 parent 8176cc6 commit 2b11e20
Showing 1 changed file with 31 additions and 0 deletions.
31 changes: 31 additions & 0 deletions lib/casserver/server.rb
Original file line number Diff line number Diff line change
Expand Up @@ -550,6 +550,37 @@ def self.init_database!
render @template_engine, :login
end
end


# Handler for obtaining login tickets.
# This is useful when you want to build a custom login form located on a
# remote server. Your form will have to include a valid login ticket
# value, and this can be fetched from the CAS server using the POST handler.

get "#{uri_path}/loginTicket" do
CASServer::Utils::log_controller_action(self.class, params)

$LOG.error("Tried to use login ticket dispenser with get method!")

status 422

"To generate a login ticket, you must make a POST request."
end


# Renders a page with a login ticket (and only the login ticket)
# in the response body.
post "#{uri_path}/loginTicket" do
CASServer::Utils::log_controller_action(self.class, params)

lt = generate_login_ticket

$LOG.debug("Dispensing login ticket #{lt} to host #{(@env['HTTP_X_FORWARDED_FOR'] || @env['REMOTE_HOST'] || @env['REMOTE_ADDR']).inspect}")

@lt = lt.ticket

@lt
end


# 2.4
Expand Down

0 comments on commit 2b11e20

Please sign in to comment.