Package org.forgerock.secrets.vault
Class VaultKeyValueSecretStore
java.lang.Object
org.forgerock.secrets.vault.VaultKeyValueSecretStore
- All Implemented Interfaces:
SecretStore<Secret>
A secret store that fetches secrets from a Hashicorp Vault
server, using version 2 of the key-value
backend. This backend allows storing arbitrary data as secrets, while also allowing versioning of those
secrets. We make use of the versioning capability to allow secret rotation - the latest version is always the
active secret, while previous versions are valid until they are destroyed.
-
Nested Class Summary
Modifier and TypeClassDescriptionstatic enum
Standard implementations ofVaultKeyValueSecretStore.SecretFieldDecoder
for common fields.static interface
Determines how a field in the Vault JSON response should be decoded into one or more fields on aSecretBuilder
object. -
Field Summary
Modifier and TypeFieldDescriptionstatic final String
The default path at which this secret engine is mounted by Vault.Fields inherited from interface org.forgerock.secrets.SecretStore
CLOCK, LEASE_EXPIRY_DURATION
-
Constructor Summary
ConstructorDescriptionVaultKeyValueSecretStore
(SecretReference<GenericSecret> tokenReference, Map<JsonPointer, ? extends VaultKeyValueSecretStore.SecretFieldDecoder> fieldDecoders, VaultConfig config) Constructs the key-value store using the given authentication token and options. -
Method Summary
Modifier and TypeMethodDescription<S extends T>
Promise<S,NoSuchSecretException> Returns the active secret for the given purpose.<S extends T>
Promise<S,NoSuchSecretException> Returns the named secret from this store.The top-level class that this store is capable of storing.<S extends T>
Promise<Stream<S>,NeverThrowsException> Returns all valid secrets for the given purpose from this store.void
refresh()
Indicates that the store should refresh its secrets from the backing storage mechanism.Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface org.forgerock.secrets.SecretStore
retire, revoke, rotate
-
Field Details
-
DEFAULT_PATH
The default path at which this secret engine is mounted by Vault.- See Also:
-
-
Constructor Details
-
VaultKeyValueSecretStore
public VaultKeyValueSecretStore(SecretReference<GenericSecret> tokenReference, Map<JsonPointer, ? extends VaultKeyValueSecretStore.SecretFieldDecoder> fieldDecoders, VaultConfig config) Constructs the key-value store using the given authentication token and options.- Parameters:
tokenReference
- the reference for obtaining a Vault authentication token. SeeAppRoleTokenStore
orJwtAuthenticationTokenStore
.fieldDecoders
- determines how the JSON content of the secret value should be decoded into a Secret object.config
- the configuration options.
-
-
Method Details
-
refresh
public void refresh()Description copied from interface:SecretStore
Indicates that the store should refresh its secrets from the backing storage mechanism. This can be used to cause reload of a store after a secret rotation if the backend does not automatically detect such changes. Refresh may be an asynchronous operation and no guarantees are made about when clients of this secret store may see updated secrets after a call to refresh.- Specified by:
refresh
in interfaceSecretStore<Secret>
-
getStoredType
Description copied from interface:SecretStore
The top-level class that this store is capable of storing. This is a reification of the type parameter and can be used to lookup stores for a given type.- Specified by:
getStoredType
in interfaceSecretStore<T extends Secret>
- Returns:
- the top-most type that this store is capable of storing, typically either
CryptoKey
for key-stores,GenericSecret
for password stores, orSecret
if the store is capable of storing any type of secret.
-
getActive
Description copied from interface:SecretStore
Returns the active secret for the given purpose.- Specified by:
getActive
in interfaceSecretStore<T extends Secret>
- Type Parameters:
S
- the type of secret.- Parameters:
purpose
- the purpose for which a secret is required.- Returns:
- the active secret from this store.
-
getNamed
Description copied from interface:SecretStore
Returns the named secret from this store. The default implementation callsSecretStore.getValid(Purpose)
and then returns the first valid key with a matching stable ID.- Specified by:
getNamed
in interfaceSecretStore<T extends Secret>
- Type Parameters:
S
- the type of secret.- Parameters:
purpose
- the secret purpose.name
- the name (stable id) of the secret.- Returns:
- a promise for the named secret, or a
NoSuchSecretException
promise if no such secret exists.
-
getValid
Description copied from interface:SecretStore
Returns all valid secrets for the given purpose from this store.- Specified by:
getValid
in interfaceSecretStore<T extends Secret>
- Type Parameters:
S
- the type of secret.- Parameters:
purpose
- the purpose.- Returns:
- a stream of all valid secrets of the given type from this store, or an empty stream if none exist.
-