Class: AtomicTenant::DeploymentManager::PlatformGuidStrategy

Inherits:
DeploymentManagerStrategy show all
Defined in:
lib/atomic_tenant/deployment_manager/platform_guid_strategy.rb

Instance Method Summary collapse

Instance Method Details

#call(decoded_id_token:) ⇒ Object

return DeploymentStrategyResult



11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
# File 'lib/atomic_tenant/deployment_manager/platform_guid_strategy.rb', line 11

def call(decoded_id_token:)
  iss = decoded_id_token["iss"]
  platform_guid = decoded_id_token.dig(AtomicLti::Definitions::TOOL_PLATFORM_CLAIM, "guid")
  target_link_uri = decoded_id_token[AtomicLti::Definitions::TARGET_LINK_URI_CLAIM]


  return DeploymentStrategyResult.new() if !platform_guid.present? || !target_link_uri.present?


  uri = URI.parse(target_link_uri)
  application_key = uri.host&.split('.')&.first

  return DeploymentStrategyResult.new() if !application_key.present?

  app = Application.find_by(key: application_key)

  return DeploymentStrategyResult.new() if !app.present?

  if(pinned = AtomicTenant::PinnedPlatformGuid.find_by(iss: iss, platform_guid: platform_guid, application_id: app.id))
    DeploymentStrategyResult.new(application_instance_id: pinned.application_instance_id)
  else
    DeploymentStrategyResult.new()
  end
end

#nameObject



6
7
8
# File 'lib/atomic_tenant/deployment_manager/platform_guid_strategy.rb', line 6

def name
  "PlatformGuidStrategy"
end