Module: Simple::OAuth2::Helpers
- Defined in:
- lib/simple_oauth2/helpers.rb
Overview
Set of Simple::OAuth2 helpers
Instance Method Summary collapse
-
#access_token_required!(*scopes) ⇒ Object
Adds OAuth2 AccessToken protection for routes.
-
#current_access_token ⇒ Object
Returns AccessToken instance found by access_token value passed with the request.
-
#current_resource_owner ⇒ Object
Returns ResourceOwner from the AccessToken found by access_token value passed with the request.
Instance Method Details
#access_token_required!(*scopes) ⇒ Object
Adds OAuth2 AccessToken protection for routes
13 14 15 16 |
# File 'lib/simple_oauth2/helpers.rb', line 13 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_token ⇒ Object
Returns AccessToken instance found by access_token value passed with the request
24 25 26 |
# File 'lib/simple_oauth2/helpers.rb', line 24 def current_access_token @current_access_token ||= request.env[Rack::OAuth2::Server::Resource::ACCESS_TOKEN] end |
#current_resource_owner ⇒ Object
Returns ResourceOwner from the AccessToken found by access_token value passed with the request
19 20 21 |
# File 'lib/simple_oauth2/helpers.rb', line 19 def current_resource_owner @current_resource_owner ||= instance_eval(&Simple::OAuth2.config.resource_owner_authenticator) end |