Interface AuthSettings
It exists as an interface rather than a Properties for one concrete reason: some
callers hold a credential that is not IN their properties file. The crypto CLI, for instance,
stores its client secret encrypted and decrypts it in memory; handing the chain a properties
object would force either a plaintext write or a special case in the chain for one caller. With
this interface the caller supplies what it has, however it obtained it, and the chain stays
ignorant of where anything came from.
Precedence
An explicitly supplied value wins, then a properties entry, then the environment. The environment is last so that a file written on purpose is not overridden by an ambient variable somebody exported for something else - and first-from-the-bottom is still enough for a container or a pod spec to configure a workload whose code names nothing.
-
Nested Class Summary
Nested Classes -
Method Summary
Modifier and TypeMethodDescriptionstatic AuthSettings.Builderbuilder()A builder for callers that hold some values in hand - a decrypted secret, a token they were given - and want the rest resolved from properties and the environment.default booleanisPresent(AuthSetting setting) Whether a setting is configured, WITHOUT producing its value.static AuthSettingsof(Properties properties) Settings backed by a properties object with the process environment as fallback.default Optional<SecretChars>secret(AuthSetting setting) Returns a setting whose value is a credential, wrapped so the caller can close it.value(AuthSetting setting) Returns the configured value of a setting.
-
Method Details
-
value
Returns the configured value of a setting.- Parameters:
setting- the setting to read; must not benull- Returns:
- the value, absent when unset or blank
-
isPresent
Whether a setting is configured, WITHOUT producing its value.Presence and value are different questions and must stay separable. "Which credential does this deployment use?" is asked by status commands, health checks and the chain itself; it has to be answerable from configuration alone, cheaply and without side effects. Answering it by fetching the value would mean a caller merely INSPECTING a configuration had to be able to decrypt a stored secret - so a store that is present but unreadable would crash the status command instead of being reported by it, which is exactly backwards.
- Parameters:
setting- the setting to test; must not benull- Returns:
truewhen a value is configured
-
secret
Returns a setting whose value is a credential, wrapped so the caller can close it.The default derives it from
value(AuthSetting); an implementation holding real secret material overrides this and never lets it become aStringat all.- Parameters:
setting- the setting to read; must not benull- Returns:
- the credential, absent when unset. The caller owns and closes what it receives.
-
of
Settings backed by a properties object with the process environment as fallback.- Parameters:
properties- the properties; must not benull- Returns:
- the settings view
-
builder
A builder for callers that hold some values in hand - a decrypted secret, a token they were given - and want the rest resolved from properties and the environment.- Returns:
- a new builder
-