Module: Rack::OAuth2::Sinatra
- Defined in:
- lib/rack/oauth2/sinatra.rb
Overview
Sinatra support.
Adds oauth instance method that returns Rack::OAuth2::Helper, see there for more details.
Adds oauth_required class method. Use this filter with paths that require authentication, and with paths that require client to have a specific access scope.
Adds oauth setting you can use to configure the module (e.g. setting available scope, see example).
Defined Under Namespace
Modules: Helpers
Class Method Summary collapse
Instance Method Summary collapse
-
#oauth_required(*args) ⇒ Object
Adds before filter to require authentication on all the listed paths.
Class Method Details
Instance Method Details
#oauth_required(*args) ⇒ 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.
38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 |
# File 'lib/rack/oauth2/sinatra.rb', line 38 def oauth_required(*args) = args.pop if Hash === args.last scope = [:scope] if args.each do |path| before path do if oauth.authenticated? if scope && !oauth.scope.include?(scope) halt oauth.no_scope! scope end else halt oauth.no_access! end end end end |