Class: ForestAdminAgent::Auth::OAuth2::ForestProvider

Inherits:
OpenIDConnect::Client
  • Object
show all
Defined in:
lib/forest_admin_agent/auth/oauth2/forest_provider.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(rendering_id, attributes = {}) ⇒ ForestProvider

Returns a new instance of ForestProvider.



10
11
12
13
14
15
16
# File 'lib/forest_admin_agent/auth/oauth2/forest_provider.rb', line 10

def initialize(rendering_id, attributes = {})
  super(attributes)
  @rendering_id = rendering_id
  @authorization_endpoint = '/oidc/auth'
  @token_endpoint = '/oidc/token'
  self.userinfo_endpoint = "/liana/v2/renderings/#{rendering_id}/authorization"
end

Instance Attribute Details

#rendering_idObject (readonly)

Returns the value of attribute rendering_id.



8
9
10
# File 'lib/forest_admin_agent/auth/oauth2/forest_provider.rb', line 8

def rendering_id
  @rendering_id
end

Instance Method Details

#get_resource_owner(access_token) ⇒ Object



18
19
20
21
22
23
24
25
26
27
# File 'lib/forest_admin_agent/auth/oauth2/forest_provider.rb', line 18

def get_resource_owner(access_token)
  headers = { 'forest-token': access_token.access_token, 'forest-secret-key': secret }
  hash = check_response do
    OpenIDConnect.http_client.get access_token.client.userinfo_uri, {}, headers
  end

  response = OpenIDConnect::ResponseObject::UserInfo.new hash

  create_resource_owner response.raw_attributes[:data]
end