module Grape::Middleware::Auth::DSL::ClassMethods
Public Instance Methods
auth(type = nil, options = {}, &block)
click to toggle source
Add an authentication type to the API. Currently only `:http_basic`, `:http_digest` are supported.
# File lib/grape/middleware/auth/dsl.rb, line 13 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
http_basic(options = {}, &block)
click to toggle source
Add HTTP Basic authorization to the API.
@param [Hash] options A hash of options. @option options [String] :realm “API Authorization” The HTTP Basic realm.
# File lib/grape/middleware/auth/dsl.rb, line 26 def http_basic(options = {}, &block) options[:realm] ||= 'API Authorization' auth :http_basic, options, &block end
http_digest(options = {}, &block)
click to toggle source
# File lib/grape/middleware/auth/dsl.rb, line 31 def http_digest(options = {}, &block) options[:realm] ||= 'API Authorization' options[:opaque] ||= 'secret' auth :http_digest, options, &block end