Class: UnauthorizedController

Inherits:
ActionController::Metal
  • Object
show all
Includes:
ActionController::RackDelegation
Defined in:
app/controllers/unauthorized_controller.rb

Overview

Special controller handling requests routed from Warden. Responds with HTTP 401 and, optionally, with a Keystone URI in the WWW-Authenticate header.

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.call(env) ⇒ Object


7
8
9
10
# File 'app/controllers/unauthorized_controller.rb', line 7

def self.call(env)
  @respond ||= action(:respond)
  @respond.call(env)
end

.default_url_options(*args) ⇒ Object


18
19
20
# File 'app/controllers/unauthorized_controller.rb', line 18

def self.default_url_options(*args)
  defined?(ApplicationController) ? ApplicationController.default_url_options(*args) : {}
end

Instance Method Details

#respondObject


12
13
14
15
16
# File 'app/controllers/unauthorized_controller.rb', line 12

def respond
  Rails.logger.warn "[AuthN] [#{self.class}] Authentication failed: #{warden_message}"
  set_unauth
  Rails.logger.warn "[AuthN] [#{self.class}] Responding with #{status} #{headers.inspect}"
end