Module: Grape::Middleware::Auth::DSL
- Included in:
- API::Instance
- Defined in:
- lib/grape/middleware/auth/dsl.rb
Instance Method Summary collapse
- #auth(type = nil, options = {}, &block) ⇒ Object
-
#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
7 8 9 10 11 12 13 14 |
# File 'lib/grape/middleware/auth/dsl.rb', line 7 def auth(type = nil, = {}, &block) if type namespace_inheritable(:auth, .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) ⇒ Object
Add HTTP Basic authorization to the API.
20 21 22 23 |
# File 'lib/grape/middleware/auth/dsl.rb', line 20 def http_basic( = {}, &block) [:realm] ||= 'API Authorization' auth :http_basic, , &block end |
#http_digest(options = {}, &block) ⇒ Object
25 26 27 28 29 30 31 32 33 34 35 |
# File 'lib/grape/middleware/auth/dsl.rb', line 25 def http_digest( = {}, &block) [:realm] ||= 'API Authorization' if [:realm].respond_to?(:values_at) [:realm][:opaque] ||= 'secret' else [:opaque] ||= 'secret' end auth :http_digest, , &block end |