Secrets Management
Clace supports secret management when working with apps. Secrets can be passed to containerized apps through the environment params. Secrets can also be passed to any plugin as argument. For OAuth config, the client secrets can be configured as secret in the config file.
Supported Providers
Clace currently supports AWS Secrets Manager (ASM) and HashiCorp Vault as providers for secrets management. Secrets can also be read from the environment of the Clace server, which can be used in development and testing.
AWS Secrets Manager
To enable ASM, add one or more entries in the clace.toml
config. The config name should be asm
or should start with asm_
. For example
[secret.asm]
@@ -129,7 +129,15 @@
Secrets can be accessed using the syntax {{secret "PROVIDER_NAME" "KEY_NAME"}}
. The three contexts in which secrets can be accessed are:
- App Params : Param values in
params.star
or in the app metadata definition can access the secrets. - Plugin arguments : Secrets can be passed as string arguments in calls to plugin functions.
- Config file: Secrets are supported in
clace.toml
config for:- For client key and secret in auth config
- For password in git_auth config
- For string values in plugin config
Secrets are always resolved late. The Starlark code does not get access to the plain text secrets. The secret lookup happens when the call to the plugin API is done. In case of params, the lookup happens when the param is passed to the container.
For git_auth config, an example secret usage is
clace.toml[auth.google_prod]
key = "mykey.apps.googleusercontent.com"
secret = '{{secret "PROVIDER_NAME" "GOOGLE_OAUTH_SECRET"}}'
-hosted_domain = "example.com"
Multiple Keys
+
hosted_domain = "example.com"
Plugin Access to Secrets +
For secrets which are passed to plugins, through app params or plugin arguments, the plugin needs to be authorized to access the secret. The permissions for each plugin are defined in the app definition. For example:
app = ace.app("test",
+ routes = [ace.api("/", type="TEXT")],
+ permissions = [
+ ace.permission("exec.in", "run", ["ls"], secrets=[["c1", "c2"], ["TESTENV"]]),
+ ]
+ )
The secrets accessible are specified as a list of list of strings. In this case, the {{secret "PROVIDER_NAME" "c1" "c2"}}
and {{secret "PROVIDER_NAME" "TESTENV"}}
calls are allowed. Additional keys are also permitted.
Multiple Keys
If the KEY_NAME
is a single string, it is passed as is to the provider. If multiple keys are specified, they are concatenated and passed to the provider. For example, {{secret "env" "ABC" "DEF"}}
will get converted to a env lookup for ABC_DEF
. The delimiter used depends on the provider. The defaults are:
- ASM and Vault :
/
- Env :
_
- Properties:
.
The formatter used to concatenate the keys can be customized by setting the keys_printf
property. For example,
[secret.prop]
file_name = "/etc/mykeys.properties"
-keys_printf = "%s-%s.%s"
combines {{secret "prop" "ABC" "DEF" "XYZ"}}
as ABC-DEF.XYZ
. This allows the app to work with multiple secret providers without requiring code changes in the app.