Sha256: 2090ddc6702eec29b5dc21d7bd13ec6431dedf923cc25edebab471c0ea124e4c
Contents?: true
Size: 716 Bytes
Versions: 4
Compression:
Stored size: 716 Bytes
Contents
require 'rack/auth/basic' module Grape module Middleware module Auth class Base < Grape::Middleware::Base attr_reader :authenticator def initialize(app, options = {}, &authenticator) super(app, options) @authenticator = authenticator end def base_request raise NotImplementedError, "You must implement base_request." end def credentials base_request.provided? ? base_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
4 entries across 4 versions & 2 rubygems