Module: Simple::OAuth2::Helpers

Defined in:
lib/simple_oauth2/helpers.rb

Overview

Set OAuth2 helpers

Instance Method Summary collapse

Instance Method Details

#access_token_required!(*scopes) ⇒ Object

Raises:

  • (Rack::OAuth2::Server::Resource::Bearer::Unauthorized)

5
6
7
8
# File 'lib/simple_oauth2/helpers.rb', line 5

def access_token_required!(*scopes)
  raise Rack::OAuth2::Server::Resource::Bearer::Unauthorized if current_access_token.nil?
  raise Rack::OAuth2::Server::Resource::Bearer::Forbidden unless valid_access_token?(scopes)
end

#current_access_tokenObject


14
15
16
# File 'lib/simple_oauth2/helpers.rb', line 14

def current_access_token
  @current_access_token ||= request.env[Rack::OAuth2::Server::Resource::ACCESS_TOKEN]
end

#current_resource_ownerObject


10
11
12
# File 'lib/simple_oauth2/helpers.rb', line 10

def current_resource_owner
  @current_resource_owner ||= current_access_token.resource_owner
end