Class: Castronaut::Models::LoginTicket

Inherits:
ActiveRecord::Base
  • Object
show all
Includes:
Consumeable, Dispenser
Defined in:
lib/castronaut/models/login_ticket.rb

Constant Summary collapse

MissingMessage =
"Your login request did not include a login ticket. There may be a problem with the authentication system."
InvalidMessage =
"The login ticket you provided is invalid. Please try logging in again."
AlreadyConsumedMessage =
"The login ticket you provided has already been used up. Please try logging in again."
ExpiredMessage =
"Your login ticket has expired. Please try logging in again."

Class Method Summary collapse

Instance Method Summary collapse

Methods included from Consumeable

#consume!, #consumed?

Class Method Details

.generate_from(client_host) ⇒ Object



16
17
18
# File 'lib/castronaut/models/login_ticket.rb', line 16

def self.generate_from(client_host)
  create! :client_hostname => client_host
end

.validate_ticket(ticket) ⇒ Object



20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
# File 'lib/castronaut/models/login_ticket.rb', line 20

def self.validate_ticket(ticket)
  return Castronaut::TicketResult.new(nil, MissingMessage) if ticket.nil?

   = find_by_ticket(ticket)

  return Castronaut::TicketResult.new(nil, InvalidMessage) if .nil?

  return Castronaut::TicketResult.new(, AlreadyConsumedMessage) if .consumed?

  return Castronaut::TicketResult.new(, ExpiredMessage) if .expired?

  .consume!

  Castronaut::TicketResult.new(, nil, "success")
end

Instance Method Details

#expired?Boolean

Returns:

  • (Boolean)


36
37
38
# File 'lib/castronaut/models/login_ticket.rb', line 36

def expired?
  #Time.now - lt.created_on < CASServer::Conf.login_ticket_expiry
end

#proxiesObject



47
48
# File 'lib/castronaut/models/login_ticket.rb', line 47

def proxies
end

#ticket_prefixObject



40
41
42
# File 'lib/castronaut/models/login_ticket.rb', line 40

def ticket_prefix
  "LT"
end

#usernameObject



44
45
# File 'lib/castronaut/models/login_ticket.rb', line 44

def username
end