Class: Castronaut::Presenters::Login
- Inherits:
-
Object
- Object
- Castronaut::Presenters::Login
- Defined in:
- lib/castronaut/presenters/login.rb
Instance Attribute Summary collapse
-
#controller ⇒ Object
readonly
Returns the value of attribute controller.
-
#messages ⇒ Object
Returns the value of attribute messages.
-
#your_mission ⇒ Object
readonly
Returns the value of attribute your_mission.
Instance Method Summary collapse
- #client_host ⇒ Object
- #gateway? ⇒ Boolean
-
#initialize(controller) ⇒ Login
constructor
A new instance of Login.
- #login_ticket ⇒ Object
- #redirection_loop? ⇒ Boolean
- #renewal ⇒ Object
- #represent! ⇒ Object
- #service ⇒ Object
- #ticket_generating_ticket_cookie ⇒ Object
Constructor Details
#initialize(controller) ⇒ Login
Returns a new instance of Login.
11 12 13 14 15 |
# File 'lib/castronaut/presenters/login.rb', line 11 def initialize(controller) @controller = controller @messages = [] @your_mission = nil end |
Instance Attribute Details
#controller ⇒ Object (readonly)
Returns the value of attribute controller.
5 6 7 |
# File 'lib/castronaut/presenters/login.rb', line 5 def controller @controller end |
#messages ⇒ Object
Returns the value of attribute messages.
6 7 8 |
# File 'lib/castronaut/presenters/login.rb', line 6 def @messages end |
#your_mission ⇒ Object (readonly)
Returns the value of attribute your_mission.
5 6 7 |
# File 'lib/castronaut/presenters/login.rb', line 5 def your_mission @your_mission end |
Instance Method Details
#client_host ⇒ Object
39 40 41 |
# File 'lib/castronaut/presenters/login.rb', line 39 def client_host env['HTTP_X_FORWARDED_FOR'] || env['REMOTE_HOST'] || env['REMOTE_ADDR'] end |
#gateway? ⇒ Boolean
25 26 27 28 29 |
# File 'lib/castronaut/presenters/login.rb', line 25 def gateway? return true if params['gateway'] == 'true' return true if params['gateway'] == '1' false end |
#login_ticket ⇒ Object
43 44 45 |
# File 'lib/castronaut/presenters/login.rb', line 43 def login_ticket Castronaut::Models::LoginTicket.generate_from(client_host).ticket end |
#redirection_loop? ⇒ Boolean
35 36 37 |
# File 'lib/castronaut/presenters/login.rb', line 35 def redirection_loop? params.has_key?('redirection_loop_intercepted') end |
#renewal ⇒ Object
21 22 23 |
# File 'lib/castronaut/presenters/login.rb', line 21 def renewal params['renew'] end |
#represent! ⇒ Object
47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 |
# File 'lib/castronaut/presenters/login.rb', line 47 def represent! ticket_granting_ticket_result = Castronaut::Models::TicketGrantingTicket.() if ticket_granting_ticket_result.valid? << "You are currently logged in as #{ticket_granting_ticket_result.username}. If this is not you, please log in below." end if redirection_loop? << "The client and server are unable to negotiate authentication. Please try logging in again later." else if service if !renewal && ticket_granting_ticket_result.valid? service_ticket = Castronaut::Models::ServiceTicket.generate_ticket_for(service, client_host, ticket_granting_ticket_result.ticket) if service_ticket.service_uri return controller.redirect(service_ticket.service_uri, 303) else << "The target service your browser supplied appears to be invalid. Please contact your system administrator for help." end elsif gateway? return controller.redirect(service, 303) end elsif gateway? << "The server cannot fulfill this gateway request because no service parameter was given." end end @your_mission = lambda { controller.erb :login, :locals => { :presenter => self } } self end |
#service ⇒ Object
17 18 19 |
# File 'lib/castronaut/presenters/login.rb', line 17 def service params['service'] end |
#ticket_generating_ticket_cookie ⇒ Object
31 32 33 |
# File 'lib/castronaut/presenters/login.rb', line 31 def ['tgt'] end |