Sha256: 871c1d1be6d227f9a1608e9a32c50906a874c5dd74af9a1cc6715cb8b432cd2f
Contents?: true
Size: 1.37 KB
Versions: 4
Compression:
Stored size: 1.37 KB
Contents
# frozen_string_literal: true require 'rack/auth/basic' module Grape module Middleware module Auth module DSL extend ActiveSupport::Concern module ClassMethods # Add an authentication type to the API. Currently # only `:http_basic`, `:http_digest` are supported. def auth(type = nil, options = {}, &block) if type namespace_inheritable(:auth, options.reverse_merge(type: type.to_sym, proc: block)) use Grape::Middleware::Auth::Base, namespace_inheritable(:auth) else namespace_inheritable(:auth) end end # Add HTTP Basic authorization to the API. # # @param [Hash] options A hash of options. # @option options [String] :realm "API Authorization" The HTTP Basic realm. def http_basic(options = {}, &block) options[:realm] ||= 'API Authorization' auth :http_basic, options, &block end def http_digest(options = {}, &block) options[:realm] ||= 'API Authorization' if options[:realm].respond_to?(:values_at) options[:realm][:opaque] ||= 'secret' else options[:opaque] ||= 'secret' end auth :http_digest, options, &block end end end end end end
Version data entries
4 entries across 4 versions & 1 rubygems
Version | Path |
---|---|
grape-2.0.0 | lib/grape/middleware/auth/dsl.rb |
grape-1.8.0 | lib/grape/middleware/auth/dsl.rb |
grape-1.7.1 | lib/grape/middleware/auth/dsl.rb |
grape-1.7.0 | lib/grape/middleware/auth/dsl.rb |