Class: Identity::Gateway::Provider
- Inherits:
-
Object
- Object
- Identity::Gateway::Provider
- Includes:
- HTTParty
- Defined in:
- lib/identity/gateway/provider.rb
Instance Method Summary collapse
-
#authorize! ⇒ Object
Get token resource owner.
-
#current_resource ⇒ Object
The current instance object associated to the model define in the configuration.
-
#initialize(request) ⇒ Provider
constructor
Class initializer.
-
#revoke_access! ⇒ Object
Revoke access token.
Constructor Details
#initialize(request) ⇒ Provider
Class initializer.
Parameters
-
request
- Current request.
Returns
Assigns arguments to instance variables.
16 17 18 19 20 21 22 |
# File 'lib/identity/gateway/provider.rb', line 16 def initialize(request) @settings = Identity::Gateway.configuration @request = request @response = {} @subject = nil @model = Object.const_get(@settings.model) end |
Instance Method Details
#authorize! ⇒ Object
Get token resource owner.
Returns
-
Object
- HTTParty response or identity error.
28 29 30 31 32 33 |
# File 'lib/identity/gateway/provider.rb', line 28 def token = request_token @subject = @model.find_by(token: token) return unless (@subject && @subject.token_has_expired?) || @subject.nil? end |
#current_resource ⇒ Object
The current instance object associated to the model define in the configuration.
Returns
-
Object
- instance or nil.
40 41 42 |
# File 'lib/identity/gateway/provider.rb', line 40 def current_resource @subject end |
#revoke_access! ⇒ Object
Revoke access token.
Returns
-
HTTParty::Response
.
48 49 50 51 52 53 54 |
# File 'lib/identity/gateway/provider.rb', line 48 def revoke_access! self.class.post( "#{@settings.provider_url}/oauth/revoke", body: { token: request_token }.to_json, headers: api_headers ) end |