Class: Rack::Casual::Authentication
- Inherits:
-
Object
- Object
- Rack::Casual::Authentication
- Defined in:
- lib/rack/casual/authentication.rb
Overview
How it works
-
Request enters app
-
Is params present with a valid CAS ticket
-
‘- Validate ticket
If valid find or create user User not ok? -- show bad info, don't redirect back to cas User ok? -- set user.id in session and continue
-
Is response a 401?
-
‘- Authenticate using auth_token if auth_token is present `- Or redirect to CAS
-
Done
Instance Method Summary collapse
- #call(env) ⇒ Object
-
#initialize(app) ⇒ Authentication
constructor
A new instance of Authentication.
Constructor Details
#initialize(app) ⇒ Authentication
Returns a new instance of Authentication.
21 22 23 |
# File 'lib/rack/casual/authentication.rb', line 21 def initialize(app) @app = app end |
Instance Method Details
#call(env) ⇒ Object
25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 |
# File 'lib/rack/casual/authentication.rb', line 25 def call(env) @request = Rack::Request.new(env) @env = env # Skip middleware if ignore_url is set and matches request.path if Rack::Casual.ignore_url && @request.path.match(Rack::Casual.ignore_url) @app.call(env) else unless process_request_from_cas @app.call(env) else handle_401(@app.call(env)) end end end |