Skip to content

Fixed proxy ticket #202

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

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
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
2 changes: 1 addition & 1 deletion lib/casserver/cas.rb
Original file line number Diff line number Diff line change
Expand Up @@ -170,7 +170,7 @@ def validate_service_ticket(service, ticket, allow_proxy_tickets = false)
if service.nil? or ticket.nil?
error = Error.new(:INVALID_REQUEST, "Ticket or service parameter was missing in the request.")
$LOG.warn "#{error.code} - #{error.message}"
elsif st = ServiceTicket.find_by_ticket(ticket)
elsif st = SPTicket.find_by_ticket(ticket)
if st.consumed?
error = Error.new(:INVALID_TICKET, "Ticket '#{ticket}' has already been used up.")
$LOG.warn "#{error.code} - #{error.message}"
Expand Down
7 changes: 4 additions & 3 deletions lib/casserver/model.rb
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,10 @@ class LoginTicket < ActiveRecord::Base
class SPTicket < ActiveRecord::Base
include Consumable
include Ticket

belongs_to :granted_by_tgt,
:class_name => 'CASServer::Model::TicketGrantingTicket',
:foreign_key => :granted_by_tgt_id

if ActiveRecord::VERSION::STRING >= '3.2'
self.table_name = 'casserver_st'
Expand All @@ -32,9 +36,6 @@ def matches_service?(service)
end

class ServiceTicket < SPTicket
belongs_to :granted_by_tgt,
:class_name => 'CASServer::Model::TicketGrantingTicket',
:foreign_key => :granted_by_tgt_id
has_one :proxy_granting_ticket,
:foreign_key => :created_by_st_id
end
Expand Down
15 changes: 7 additions & 8 deletions lib/casserver/server.rb
Original file line number Diff line number Diff line change
Expand Up @@ -529,18 +529,17 @@ def self.init_database!
send_logout_notification_for_service_ticket(st) if config[:enable_single_sign_out]
# TODO: Maybe we should do some special handling if send_logout_notification_for_service_ticket fails?
# (the above method returns false if the POST results in a non-200 HTTP response).
pgts = CASServer::Model::ProxyGrantingTicket.find_all_by_service_ticket_id(st.id)

pgts.each do |pgt|
$LOG.debug("Deleting Proxy-Granting Ticket '#{pgt}' for user '#{pgt.service_ticket.username}'")
pgt.destroy
end

$LOG.debug "Deleting #{st.class.name.demodulize} #{st.ticket.inspect} for service #{st.service}."
st.destroy
end

pgts = CASServer::Model::ProxyGrantingTicket.find(:all,
:conditions => [CASServer::Model::ServiceTicket.quoted_table_name+".username = ?", tgt.username],
:include => :service_ticket)
pgts.each do |pgt|
$LOG.debug("Deleting Proxy-Granting Ticket '#{pgt}' for user '#{pgt.service_ticket.username}'")
pgt.destroy
end

$LOG.debug("Deleting #{tgt.class.name.demodulize} '#{tgt}' for user '#{tgt.username}'")
tgt.destroy
end
Expand Down