Class: Persona::Config

Inherits:
Object
  • Object
show all
Defined in:
lib/persona.rb

Overview

Injection points for the app-specific parts of the persona flow. Every default is a self-contained generic — the gem has no domain dependencies until the app overrides a seam.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeConfig

Returns a new instance of Config.



100
101
102
103
104
105
106
107
# File 'lib/persona.rb', line 100

def initialize
  @on_join = ->(_user) {}
  @guest_nickname_generator = -> { Persona.generate_nickname }
  @guest_email_factory = -> { "agent-#{SecureRandom.hex(8)}@guest.local" }
  @oidc_providers = {}
  @account_link_store = nil
  @link_store = nil
end

Instance Attribute Details

Storage port for AccountLink — an object implementing the contract documented in Persona::AccountLink. No default: consumers that enable account linking must provide one backed by their own persistence.



93
94
95
# File 'lib/persona.rb', line 93

def 
  @account_link_store
end

#guest_email_factoryObject

Builds the placeholder email/identifier persisted on a new guest user. It MUST NOT be derived from the agent_uid or the session credential: this value is exposable (a settings page, a profile view echoes it), so deriving it would leak the credential back (P-3). The default draws from independent randomness for exactly this reason.



78
79
80
# File 'lib/persona.rb', line 78

def guest_email_factory
  @guest_email_factory
end

#guest_nickname_generatorObject

Builds the display nickname for a new guest when the caller supplies none.



71
72
73
# File 'lib/persona.rb', line 71

def guest_nickname_generator
  @guest_nickname_generator
end

Storage for the OIDC redirect round-trip, e.g. Persona::Oidc::LinkStore.new(redis: ). No default: consumers that enable account linking must provide one.



98
99
100
# File 'lib/persona.rb', line 98

def link_store
  @link_store
end

#oidc_providersObject (readonly)

Registered OIDC providers by name (see Persona::Oidc for the provider contract). Empty by default: register providers explicitly, including the development stub — an unregistered provider can never verify.



83
84
85
# File 'lib/persona.rb', line 83

def oidc_providers
  @oidc_providers
end

#on_joinObject

Called with the freshly-resolved guest user on every join (both the first join and returning visits). Must be idempotent. Defaults to a no-op; the app injects its membership side effects here.



67
68
69
# File 'lib/persona.rb', line 67

def on_join
  @on_join
end

Instance Method Details

#register_oidc_provider(provider) ⇒ Object



85
86
87
88
# File 'lib/persona.rb', line 85

def register_oidc_provider(provider)
  @oidc_providers[provider.name] = provider
  provider
end