Sha256: d1d420e779de53cf5f5835adc9e1e6d411b753cf12dc0aed33357887c85d2e2a
Contents?: true
Size: 730 Bytes
Versions: 24
Compression:
Stored size: 730 Bytes
Contents
require 'rack/auth/basic' module Grape module Middleware module Auth class Basic < Grape::Middleware::Base attr_reader :authenticator def initialize(app, options = {}, &authenticator) super(app, options) @authenticator = authenticator end def basic_request Rack::Auth::Basic::Request.new(env) end def credentials basic_request.provided?? basic_request.credentials : [nil, nil] end def before unless authenticator.call(*credentials) throw :error, :status => 401, :message => "API Authorization Failed." end end end end end end
Version data entries
24 entries across 24 versions & 2 rubygems