Class: CasrackTheAuthenticator::Simple

Inherits:
Object
  • Object
show all
Defined in:
lib/casrack_the_authenticator/simple.rb

Overview

The most basic CAS client use-case: redirects to CAS if a middleware or endpoint beneath this one returns a 401 response. On successful redirection back from CAS, puts the username of the CAS user in the session under :cas_user.

Instance Method Summary collapse

Constructor Details

#initialize(app, options) ⇒ Simple

Create a new CAS middleware.

Parameters:

  • app

    the underlying Rack application

  • options (Hash)
    • see

    CasrackTheAuthenticator::Configuration for more information



19
20
21
22
# File 'lib/casrack_the_authenticator/simple.rb', line 19

def initialize(app, options)
  @app = app
  @configuration = CasrackTheAuthenticator::Configuration.new(options)
end

Instance Method Details

#call(env) ⇒ Array<Integer, Hash, #each>

Processes the CAS user if a “ticket” parameter is passed, then calls the underlying Rack application; if the result is a 401, redirects to CAS; otherwise, returns the response unchanged.

Returns:

  • (Array<Integer, Hash, #each>)

    a Rack response



30
31
32
33
34
# File 'lib/casrack_the_authenticator/simple.rb', line 30

def call(env)
  request = Rack::Request.new(env)
  process_return_from_cas(request)
  redirect_on_401(request, @app.call(env))
end