Class: Cas::Client::Middleware
- Inherits:
-
Object
- Object
- Cas::Client::Middleware
- Defined in:
- lib/cas/client/middleware.rb
Instance Method Summary collapse
- #call(env) ⇒ Object
-
#initialize(app, &block) ⇒ Middleware
constructor
A new instance of Middleware.
Constructor Details
#initialize(app, &block) ⇒ Middleware
Returns a new instance of Middleware.
6 7 8 9 10 |
# File 'lib/cas/client/middleware.rb', line 6 def initialize(app, &block) @app = app Cas::Client.configure(&block) if block_given? end |
Instance Method Details
#call(env) ⇒ Object
12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 |
# File 'lib/cas/client/middleware.rb', line 12 def call(env) @request = Rack::Request.new(env) status, headers, rack_body = @app.call(env) if ticket_validation? attributes = server.validate_service(self_url, ticket_param) set_session(attributes) return redirect_to(self_url) elsif status == 401 log(env, "Cas::Client::Middleware detected 401, Status: #{status}, Headers: #{headers}\n") return redirect_to(server.login_url({ service_url: self_url })) else return [status, headers, rack_body] end end |