lib/shib_rack/handler.rb in shib-rack-0.3.0 vs lib/shib_rack/handler.rb in shib-rack-0.4.0
- old
+ new
@@ -3,20 +3,20 @@
module ShibRack
# Rack application which handles incoming sessions authenticated by
# Shibboleth SP.
class Handler
attr_reader :error_handler
- private :error_handler
def initialize(opts)
@receiver = constantize(opts[:receiver])
@error_handler = constantize(opts[:error_handler])&.new || self
end
def call(env)
return login(env) if env['PATH_INFO'] == '/login'
return logout(env) if env['PATH_INFO'] == '/logout'
+
[404, {}, ["Not found: #{env['PATH_INFO']}"]]
end
def handle(_env, _exception)
[
@@ -30,19 +30,20 @@
private
def login(env)
receiver.receive(env)
- rescue => e
+ rescue StandardError => e
error_handler.handle(env, e)
end
def logout(env)
receiver.logout(env)
end
def constantize(klass_name)
return nil if klass_name.nil?
+
klass_name.split('::').reduce(Kernel) { |acc, elem| acc.const_get(elem) }
end
def receiver
@receiver.new