Class: CasrackTheAuthenticator::Fake

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

Overview

A fake CAS authenticator. Good for disconnected-mode development.

Constant Summary collapse

BASIC_AUTH_401 =
[
  401,
  {
    'Content-Type' => 'text/plain',
    'Content-Length' => '0',
    'WWW-Authenticate' => 'Basic realm="CasrackTheAuthenticator::Fake"'
  },
  []
]

Instance Method Summary collapse

Constructor Details

#initialize(app, *usernames) ⇒ Fake

Returns a new instance of Fake.

Parameters:

  • app

    the underlying Rack application

  • usernames (Array<String>)

    an Array of usernames that will successfully authenticate as though they had come from CAS.



24
25
26
27
# File 'lib/casrack_the_authenticator/fake.rb', line 24

def initialize(app, *usernames)
  @app, @usernames = app, usernames
  raise "Why would you create a Fake CAS authenticator but not let anyone use it?" if usernames.empty?
end

Instance Method Details

#call(env) ⇒ Object



29
30
31
32
# File 'lib/casrack_the_authenticator/fake.rb', line 29

def call(env)
  process_basic_auth(env)
  basic_auth_on_401(@app.call(env))
end