Class: Castronaut::Models::LoginTicket
- Inherits:
-
ActiveRecord::Base
- Object
- ActiveRecord::Base
- Castronaut::Models::LoginTicket
- 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
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? login_ticket = find_by_ticket(ticket) return Castronaut::TicketResult.new(nil, InvalidMessage) if login_ticket.nil? return Castronaut::TicketResult.new(login_ticket, AlreadyConsumedMessage) if login_ticket.consumed? return Castronaut::TicketResult.new(login_ticket, ExpiredMessage) if login_ticket.expired? login_ticket.consume! Castronaut::TicketResult.new(login_ticket, nil, "success") end |
Instance Method Details
#expired? ⇒ 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 |
#proxies ⇒ Object
47 48 |
# File 'lib/castronaut/models/login_ticket.rb', line 47 def proxies end |
#ticket_prefix ⇒ Object
40 41 42 |
# File 'lib/castronaut/models/login_ticket.rb', line 40 def ticket_prefix "LT" end |
#username ⇒ Object
44 45 |
# File 'lib/castronaut/models/login_ticket.rb', line 44 def username end |