class Rack::Auth::Request

Constants

VERSION

Public Class Methods

new(app, &auth) click to toggle source
# File lib/rack/auth/request.rb, line 6
def initialize(app, &auth)
  @app, @auth = app, auth
end

Public Instance Methods

call(env) click to toggle source
# File lib/rack/auth/request.rb, line 10
def call(env)
  auth_response = @auth.call(env)

  return unauthorized if auth_response[0] == 401
  return forbidden if auth_response[0] == 403

  return @app.call(env) if 200 <= auth_response[0] && auth_response[0] < 300

  ise
end

Private Instance Methods

forbidden() click to toggle source
# File lib/rack/auth/request.rb, line 33
def forbidden
  return [
    403,
    {
      CONTENT_TYPE => 'text/plain',
      CONTENT_LENGTH => '0'
    },
    []
  ]
end
ise() click to toggle source
# File lib/rack/auth/request.rb, line 43
def ise
  return [
    500,
    {
      CONTENT_TYPE => 'text/plain',
      CONTENT_LENGTH => '0'
    },
    []
  ]
end
unauthorized() click to toggle source
# File lib/rack/auth/request.rb, line 23
def unauthorized
  return [
    401,
    {
      CONTENT_TYPE => 'text/plain',
      CONTENT_LENGTH => '0'
    },
    []
  ]
end