Module: Rack::OAuth2::Rails::Filters
- Defined in:
- lib/rack/oauth2/rails.rb
Overview
Filter methods available in controller.
Instance Method Summary collapse
-
#oauth_required(options = {}) ⇒ Object
Adds before filter to require authentication on all the listed paths.
Instance Method Details
#oauth_required(options = {}) ⇒ Object
Adds before filter to require authentication on all the listed paths. Use the :scope option if client must also have access to that scope.
:except, and the :scope option.
74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 |
# File 'lib/rack/oauth2/rails.rb', line 74 def oauth_required( = {}) if scope = .delete(:scope) before_filter do |controller| if controller.oauth.authenticated? if !controller.oauth.scope.include?(scope) controller.send :head, controller.oauth.no_scope!(scope) end else controller.send :head, controller.oauth.no_access! end end else before_filter :oauth_required, end end |