module Rack::OAuth2::Rails
Rails
support.
Adds oauth instance method that returns Rack::OAuth2::Helper, see there for more details.
Adds oauth_required filter method. Use this filter with actions that require authentication, and with actions 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).
@example config/environment.rb
require "rack/oauth2/rails" Rails::Initializer.run do |config| config.oauth[:scope] = %w{read write} config.oauth[:authenticator] = lambda do |username, password| User.authenticated username, password end . . . end
@example app/controllers/my_controller.rb
class MyController < ApplicationController oauth_required :only=>:show oauth_required :only=>:update, :scope=>"write" . . . protected def current_user @current_user ||= User.find(oauth.identity) if oauth.authenticated? end end
@see Helpers
@see Filters
@see Configuration