Module: Grape::Middleware::Auth::DSL
- Included in:
- API
- 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.
9 10 11 12 13 14 15 16 |
# File 'lib/grape/middleware/auth/dsl.rb', line 9 def auth(type = nil, = {}, &block) if type set(:auth, { type: type.to_sym, proc: block }.merge()) use Grape::Middleware::Auth::Base, settings[:auth] else settings[:auth] end end |
#http_basic(options = {}, &block) ⇒ Object
Add HTTP Basic authorization to the API.
22 23 24 25 |
# File 'lib/grape/middleware/auth/dsl.rb', line 22 def http_basic( = {}, &block) [:realm] ||= "API Authorization" auth :http_basic, , &block end |
#http_digest(options = {}, &block) ⇒ Object
27 28 29 30 31 |
# File 'lib/grape/middleware/auth/dsl.rb', line 27 def http_digest( = {}, &block) [:realm] ||= "API Authorization" [:opaque] ||= "secret" auth :http_digest, , &block end |