Class: Webhookdb::Service::Auth::FailureApp

Inherits:
Object
  • Object
show all
Defined in:
lib/webhookdb/service/auth.rb

Overview

Create the middleware for a Warden auth failure. Is not a ‘normal’ Rack middleware, which normally accepts ‘app’ in the initializer and has ‘call’ as an instance method. See github.com/wardencommunity/warden/wiki/Setup

Class Method Summary collapse

Class Method Details

.call(env) ⇒ Object



47
48
49
50
51
52
# File 'lib/webhookdb/service/auth.rb', line 47

def self.call(env)
  warden_opts = env.fetch("warden.options", {})
  msg = warden_opts[:message] || env["webhookdb.authfailuremessage"] || "Unauthorized"
  body = Webhookdb::Service.error_body(401, msg)
  return 401, {"Content-Type" => "application/json"}, [body.to_json]
end