Class: Himari::ItemProviders::Storage

Inherits:
Object
  • Object
show all
Includes:
Himari::ItemProvider
Defined in:
lib/himari/item_providers/storage.rb

Overview

Looks up dynamically registered clients from storage and presents them to the OIDC endpoints as plain ClientRegistration objects. Lookups always carry an id hint; without one this returns nothing (there is no list operation). Expired registrations are filtered out here so backends without TTL (Memory, Filesystem) and DynamoDB’s delayed TTL both fail closed.

Instance Method Summary collapse

Constructor Details

#initialize(storage:, skip_consent: false, scopes: Himari::ClientRegistration::IMPLICIT_SCOPES) ⇒ Storage

Returns a new instance of Storage.

Parameters:

  • storage (Himari::Storages::Base)
  • skip_consent (Boolean) (defaults to: false)

    applied to every dynamic client this provider resolves

  • scopes (Array<String>) (defaults to: Himari::ClientRegistration::IMPLICIT_SCOPES)

    recognised scopes applied to every dynamic client resolved



19
20
21
22
23
# File 'lib/himari/item_providers/storage.rb', line 19

def initialize(storage:, skip_consent: false, scopes: Himari::ClientRegistration::IMPLICIT_SCOPES)
  @storage = storage
  @skip_consent = skip_consent
  @scopes = scopes
end

Instance Method Details

#collect(id: nil, **_hint) ⇒ Object



25
26
27
28
29
30
# File 'lib/himari/item_providers/storage.rb', line 25

def collect(id: nil, **_hint)
  return [] unless id

  client = @storage.find_dynamic_client(id)
  client&.active? ? [client.to_client_registration(skip_consent: @skip_consent, scopes: @scopes)] : []
end