Module: Grape::Middleware::Auth::DSL::ClassMethods
- Defined in:
- lib/grape/middleware/auth/dsl.rb
Instance Method Summary collapse
-
#auth(type = nil, options = {}, &block) ⇒ Object
Add an authentication type to the API.
-
#http_basic(options = {}, &block) ⇒ Object
Add HTTP Basic authorization to the API.
- #http_digest(options = {}, &block) ⇒ Object
Instance Method Details
#auth(type = nil, options = {}, &block) ⇒ Object
Add an authentication type to the API. Currently
only :http_basic
, :http_digest
are supported.
13 14 15 16 17 18 19 20 |
# File 'lib/grape/middleware/auth/dsl.rb', line 13 def auth(type = nil, = {}, &block) if type namespace_inheritable(:auth, { type: type.to_sym, proc: block }.merge()) use Grape::Middleware::Auth::Base, namespace_inheritable(:auth) else namespace_inheritable(:auth) end end |
#http_basic(options = {}, &block) ⇒ Object
Add HTTP Basic authorization to the API.
26 27 28 29 |
# File 'lib/grape/middleware/auth/dsl.rb', line 26 def http_basic( = {}, &block) [:realm] ||= 'API Authorization' auth :http_basic, , &block end |
#http_digest(options = {}, &block) ⇒ Object
31 32 33 34 35 |
# File 'lib/grape/middleware/auth/dsl.rb', line 31 def http_digest( = {}, &block) [:realm] ||= 'API Authorization' [:opaque] ||= 'secret' auth :http_digest, , &block end |