Module: OAuth2::Auth::Server::Authentication::ControllerMethods

Defined in:
lib/oauth2-auth-server/authentication.rb

Instance Method Summary collapse

Instance Method Details

#require_oauth_client_token(options = {}) ⇒ Object

Raises:



32
33
34
35
36
# File 'lib/oauth2-auth-server/authentication.rb', line 32

def require_oauth_client_token(options = {})
  require_oauth_token(options)
  raise Rack::OAuth2::Server::Resource::Bearer::Unauthorized.new(:invalid_token, 'Client token is required') if @current_token.user
  @current_client = @current_token.client
end

#require_oauth_token(options = {}) ⇒ Object

Raises:



26
27
28
29
30
# File 'lib/oauth2-auth-server/authentication.rb', line 26

def require_oauth_token(options = {})
  @current_token = request.env[Rack::OAuth2::Server::Resource::ACCESS_TOKEN]
  raise Rack::OAuth2::Server::Resource::Bearer::Unauthorized unless @current_token
  raise Rack::OAuth2::Server::Resource::Bearer::Forbidden.new(:insufficient_scope) unless @current_token.has_scope?(options[:scope])
end