Class: Fluence::Gateway::Configuration::Settings
- Inherits:
-
Object
- Object
- Fluence::Gateway::Configuration::Settings
- Includes:
- Singleton
- Defined in:
- lib/fluence/gateway/configuration.rb
Overview
Singleton value object holding the SDK configuration.
Stores the OAuth2 credentials and the base URLs for the gateway and appcenter. Instantiated lazily the first time #config is called.
All attributes are read/write. Attributes other than timeout and
tenants resolve their value in this order: explicit setter value,
then the matching ENV variable, then a hard-coded default.
Credential attributes (client_id, client_secret) have no
hard-coded default and return nil when neither a setter nor the
matching ENV var is set.
Instance Attribute Summary collapse
-
#appcenter_url ⇒ String
Base URL of the appcenter OAuth2 server.
-
#client_id ⇒ String?
OAuth2 client identifier.
-
#client_secret ⇒ String?
OAuth2 client secret.
-
#gateway_url ⇒ String
Base URL of the Fluence API gateway.
-
#profile ⇒ Symbol
Resolves the active profile.
-
#scope ⇒ String
OAuth2 scope requested on the
client_credentialsgrant. -
#ssl_ca_file ⇒ String?
Path to an additional CA certificate file (PEM) that OpenSSL will trust on top of the system trust store.
-
#ssl_options ⇒ Hash
Extra Faraday SSL options merged into the
ssl:Hash passed toOAuth2::Client(and then toFaraday::Connection). -
#ssl_verify ⇒ Symbol
Returns the normalised SSL verification mode, resolving (in order) the explicit setter value,
ENV['GATEWAY_SSL_VERIFY'], then defaulting to:peer. -
#ssr_tenant ⇒ Boolean
Whether the configured gateway is a single-service (SSR) tenant.
-
#tenants ⇒ Hash{Symbol => Hash}
User-declared tenants.
-
#timeout ⇒ Integer
HTTP timeout in seconds.
Instance Method Summary collapse
-
#tenant_config(name = nil) ⇒ TenantConfig
Resolves the effective configuration for a tenant.
Instance Attribute Details
#appcenter_url ⇒ String
Base URL of the appcenter OAuth2 server.
Falls back to ENV['APPCENTER_URL'] when unset.
#client_id ⇒ String?
OAuth2 client identifier.
Falls back to ENV['APPCENTER_CLIENT_ID'] when unset.
#client_secret ⇒ String?
OAuth2 client secret.
Falls back to ENV['APPCENTER_CLIENT_SECRET'] when unset.
#gateway_url ⇒ String
Base URL of the Fluence API gateway.
Falls back to ENV['GATEWAY_URL'] when unset.
#profile ⇒ Symbol
Resolves the active profile. Order: explicit setter, then
ENV['GATEWAY_PROFILE'], then :production. Raises
ArgumentError when the resolved value is not a key of
PROFILES — validation is eager on both the setter path and
the ENV path.
#scope ⇒ String
OAuth2 scope requested on the client_credentials grant.
Falls back to ENV['APPCENTER_SCOPE'] when unset.
#ssl_ca_file ⇒ String?
Path to an additional CA certificate file (PEM) that OpenSSL will trust on top of the system trust store. Typical use case: a self-signed or internal-CA certificate in staging.
Takes precedence over the system store for hostnames signed
by the configured CA; hosts signed by a system CA still
validate. Ignored when #ssl_verify resolves to :none.
Falls back to ENV['GATEWAY_SSL_CA_FILE'] when unset.
#ssl_options ⇒ Hash
Extra Faraday SSL options merged into the ssl: Hash passed
to OAuth2::Client (and then to Faraday::Connection).
Accepts any key supported by Faraday::SSLOptions (ca_path,
cert_store, client_cert, client_key, verify_hostname,
…). Keys in this Hash override the entries derived from
#ssl_verify and #ssl_ca_file, so power users can bypass
the dedicated settings if they need to.
#ssl_verify ⇒ Symbol
Returns the normalised SSL verification mode, resolving (in
order) the explicit setter value, ENV['GATEWAY_SSL_VERIFY'],
then defaulting to :peer. Always returns one of :peer,
:none, :client_once, :fail_if_no_peer_cert.
#ssr_tenant ⇒ Boolean
Whether the configured gateway is a single-service (SSR) tenant.
When true, calls that try to route through a backend service
(via the service: kwarg or Fluence::Gateway::Client#with_service) raise
ServiceNotAllowedError, because SSR tenants expose a single
backend directly and the /backend/<service>/ prefix has no
meaning.
Falls back to ENV['GATEWAY_SSR_TENANT'] (presence = enabled)
when unset.
#tenants ⇒ Hash{Symbol => Hash}
User-declared tenants. Each value is a Hash of overrides over the global settings (only keys that differ need to be listed). A user-declared tenant overrides a same-name entry in BUILT_IN_TENANTS.
Supported override keys: :client_id, :client_secret,
:gateway_url, :appcenter_url, :timeout, :scope,
:ssr_tenant, :ssl_verify, :ssl_options, :ssl_ca_file.
#timeout ⇒ Integer
HTTP timeout in seconds.
Instance Method Details
#tenant_config(name = nil) ⇒ TenantConfig
Resolves the effective configuration for a tenant.
When name is nil, returns the global configuration as a
TenantConfig. Otherwise, looks up the tenant's overrides —
first in #tenants (user-declared), then in
BUILT_IN_TENANTS — and merges them over the global
settings before wrapping the result in a TenantConfig.
Raises UnknownTenantError if the name matches neither
source.