Introspection for the AshVault extension.
Spark.InfoGenerator generates the raw option readers — ash_vault_vault/1 and
ash_vault_vault!/1, ash_vault_scope/1, ash_vault_attributes/1,
ash_vault_decrypt_by_default/1, ash_vault_encrypt_nil?/1, ash_vault_scope_owner?/1,
ash_vault_options/1, ash_vault_key_lifecycle_rotate/1, ash_vault_key_lifecycle_destroy/1
— plus ash_vault/1, which returns the encrypt entities.
Note the generator's naming rules: entity readers are named after the section path
(hence ash_vault/1, not ash_vault_encrypt/1), ?-suffixed options get only a
predicate function with no bang variant, and options with a non-nil default never
return :error.
On top of those this module adds the helpers the extension itself uses.
Summary
Functions
ash_vault DSL entities
Shorthand for a list of encrypt entities with default options.
Shorthand for a list of encrypt entities with default options.
Encrypted fields whose decrypt calculation is loaded automatically.
Encrypted fields whose decrypt calculation is loaded automatically.
Encrypt nil rather than storing SQL NULL. Overridable per field.
Name of a generic action that destroys this scope's keys.
Name of a generic action that destroys this scope's keys.
ash_vault.key_lifecycle DSL options
Name of a generic action that rotates this scope's key.
Name of a generic action that rotates this scope's key.
ash_vault DSL options
The key scope: :tenant (AshVault.Scopes.AshTenant), :global (AshVault.Scopes.Global), or an AshVault.Scope module. Unrelated to Ash.Scope.
The key scope: :tenant (AshVault.Scopes.AshTenant), :global (AshVault.Scopes.Global), or an AshVault.Scope module. Unrelated to Ash.Scope.
This resource is the scope (the tenant/organization). Required for key_lifecycle.
The vault to encrypt and decrypt with. A module using AshVault.Vault, an MFA, or a fun/2 of (resource, context) -> vault_module.
The vault to encrypt and decrypt with. A module using AshVault.Vault, an MFA, or a fun/2 of (resource, context) -> vault_module.
The encrypt entities of a resource, without the attributes sugar.
Whether nil is encrypted for a field, resolving the per-field override against the
section-level default.
One encrypted field by name, or nil.
The names of every encrypted field of a resource.
Every encrypted field of a resource, as %AshVault.Encrypted{} structs.
The encrypt ..., legacy: ... entities of a resource, as declared (named after the
legacy attribute).
A legacy: field's legacy type and constraints.
One macaroon by name, or nil.
Every macaroon declared on a resource.
The normalize: strategy configured for a field, defaulting to :none.
The AshVault.Scope module for a resource's key scope.
Whether one field of a resource is searchable.
Every searchable field of a resource, as %AshVault.Encrypted{} structs.
The stable storage and cryptographic binding name of an encrypted field.
Resolve a logical field to its stable storage and binding name.
The vault module for a resource, resolving the fun/2 and MFA forms against the
callback context.
Functions
ash_vault DSL entities
Shorthand for a list of encrypt entities with default options.
Shorthand for a list of encrypt entities with default options.
Encrypted fields whose decrypt calculation is loaded automatically.
Encrypted fields whose decrypt calculation is loaded automatically.
Encrypt nil rather than storing SQL NULL. Overridable per field.
@spec ash_vault_key_lifecycle_destroy(dsl_or_extended :: module() | map()) :: {:ok, atom()} | :error
Name of a generic action that destroys this scope's keys.
Name of a generic action that destroys this scope's keys.
@spec ash_vault_key_lifecycle_options(dsl_or_extended :: module() | map()) :: %{ required(atom()) => any() }
ash_vault.key_lifecycle DSL options
Returns a map containing the and any configured or default values.
Name of a generic action that rotates this scope's key.
Name of a generic action that rotates this scope's key.
ash_vault DSL options
Returns a map containing the and any configured or default values.
@spec ash_vault_scope(dsl_or_extended :: module() | map()) :: {:ok, (:global | :tenant) | module()} | :error
The key scope: :tenant (AshVault.Scopes.AshTenant), :global (AshVault.Scopes.Global), or an AshVault.Scope module. Unrelated to Ash.Scope.
@spec ash_vault_scope!(dsl_or_extended :: module() | map()) :: ((:global | :tenant) | module()) | no_return()
The key scope: :tenant (AshVault.Scopes.AshTenant), :global (AshVault.Scopes.Global), or an AshVault.Scope module. Unrelated to Ash.Scope.
This resource is the scope (the tenant/organization). Required for key_lifecycle.
@spec ash_vault_vault(dsl_or_extended :: module() | map()) :: {:ok, module() | mfa() | (any(), any() -> any())} | :error
The vault to encrypt and decrypt with. A module using AshVault.Vault, an MFA, or a fun/2 of (resource, context) -> vault_module.
@spec ash_vault_vault!(dsl_or_extended :: module() | map()) :: (module() | mfa() | (any(), any() -> any())) | no_return()
The vault to encrypt and decrypt with. A module using AshVault.Vault, an MFA, or a fun/2 of (resource, context) -> vault_module.
@spec encrypt_entities(module() | Spark.Dsl.t()) :: [AshVault.Encrypted.t()]
The encrypt entities of a resource, without the attributes sugar.
ash_vault/1 returns every entity in the section — macaroons too — so anything that
wants encrypted fields reads them through here.
@spec encrypt_nil?(module() | Spark.Dsl.t(), atom() | AshVault.Encrypted.t()) :: boolean()
Whether nil is encrypted for a field, resolving the per-field override against the
section-level default.
@spec encrypted_field(module() | Spark.Dsl.t(), atom()) :: AshVault.Encrypted.t() | nil
One encrypted field by name, or nil.
@spec encrypted_field_names(module() | Spark.Dsl.t()) :: [atom()]
The names of every encrypted field of a resource.
@spec encrypted_fields(module() | Spark.Dsl.t()) :: [AshVault.Encrypted.t()]
Every encrypted field of a resource, as %AshVault.Encrypted{} structs.
This merges the attributes [...] sugar with the explicit encrypt entities, so it
returns the same answer before and after AshVault.Transformers.ExpandAttributes has
run. Explicit entities win over sugar of the same name, and order is
entities-then-sugar.
@spec legacy_fields(module() | Spark.Dsl.t()) :: [AshVault.Encrypted.t()]
The encrypt ..., legacy: ... entities of a resource, as declared (named after the
legacy attribute).
@spec legacy_type(AshVault.Encrypted.t()) :: {module(), keyword()}
A legacy: field's legacy type and constraints.
@spec macaroon(module() | Spark.Dsl.t(), atom()) :: AshVault.Macaroon.Definition.t() | nil
One macaroon by name, or nil.
@spec macaroons(module() | Spark.Dsl.t()) :: [AshVault.Macaroon.Definition.t()]
Every macaroon declared on a resource.
@spec normalize(module() | Spark.Dsl.t(), atom() | AshVault.Encrypted.t()) :: AshVault.Lookup.normalize()
The normalize: strategy configured for a field, defaulting to :none.
@spec scope_module(module() | Spark.Dsl.t()) :: module()
The AshVault.Scope module for a resource's key scope.
@spec searchable?(module() | Spark.Dsl.t(), atom()) :: boolean()
Whether one field of a resource is searchable.
@spec searchable_fields(module() | Spark.Dsl.t()) :: [AshVault.Encrypted.t()]
Every searchable field of a resource, as %AshVault.Encrypted{} structs.
@spec stored_as(AshVault.Encrypted.t()) :: atom()
The stable storage and cryptographic binding name of an encrypted field.
@spec stored_as(module() | Spark.Dsl.t(), atom()) :: atom()
Resolve a logical field to its stable storage and binding name.
@spec vault!(module() | Spark.Dsl.t(), term()) :: module()
The vault module for a resource, resolving the fun/2 and MFA forms against the
callback context.
The context handed here is always the normalized ash_context map built by
AshVault.Context.Builder — %{tenant:, actor:, source_context:, phase:} — so a
dynamic vault sees one shape on the write path, the read path and the lifecycle
actions alike, rather than three different Ash callback structs.