Class: ShibRack::DevelopmentHandler

Inherits:
Handler
  • Object
show all
Defined in:
lib/shib_rack/development_handler.rb

Overview

Handler for authenticating to an application in development mode, using sample identities for local testing.

Class Attribute Summary collapse

Attributes inherited from Handler

#error_handler

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from Handler

#handle, #initialize

Constructor Details

This class inherits a constructor from ShibRack::Handler

Class Attribute Details

.identitiesObject



13
14
15
# File 'lib/shib_rack/development_handler.rb', line 13

def identities
  @identities ||= load_identities
end

.login_redirect(env) ⇒ Object



17
18
19
# File 'lib/shib_rack/development_handler.rb', line 17

def (env)
  @login_redirect ||= "#{env['SCRIPT_NAME']}/development"
end

Class Method Details

.load_identitiesObject



25
26
27
28
29
30
31
32
# File 'lib/shib_rack/development_handler.rb', line 25

def load_identities
  require 'yaml'
  yaml = File.read(File.expand_path('identities.yml', __dir__))

  YAML.safe_load(yaml)['identities'].map do |identity|
    identity.reduce({}) { |a, (k, v)| a.merge("HTTP_#{k.upcase}" => v) }
  end
end

.resolve_identity(shared_token) ⇒ Object



21
22
23
# File 'lib/shib_rack/development_handler.rb', line 21

def resolve_identity(shared_token)
  identities.find { |i| i['HTTP_AUEDUPERSONSHAREDTOKEN'] == shared_token }
end

Instance Method Details

#call(env) ⇒ Object



35
36
37
38
39
40
41
42
43
44
# File 'lib/shib_rack/development_handler.rb', line 35

def call(env)
  case env['PATH_INFO']
  when '/login'
    (env)
  when '/development'
    development
  else
    super
  end
end