If anyone else is looking to do this in the future, I was able to configure my required action via the Keycloak vault. In our app, that's through Kubernetes secrets, but should be possible through any other vault mechanism, as well. Probably a better way to store sensitive config settings, anyways.
MyRequiredActionFactory.java:
@Override public RequiredActionProvider create(KeycloakSession session) {
return new MyRequiredAction(session);
}
MyRequiredActionProvider.java:
private final String mySecretConfig;
public MyRequiredAction(KeycloakSession session) {
try (VaultStringSecret secret = session.vault().getStringSecret("${vault.my_secret_config}")) {
mySecretConfig = secret.get().orElse("");
}
}
my-keycloak-secrets.yaml:
apiVersion: v1
kind: Secret
metadata:
name: my-keycloak-secrets
namespace: default
type: Opaque
stringData:
my_secret_config: "abc123..."
keycloak-deploy.yaml: (note that the key path has to mangled to include the realm name -- you can do this multiple times if you need the secret in more than one realm)
apiVersion: apps/v1
kind: Deployment
...
spec:
...
template:
...
spec:
containers:
- name: keycloak
image: mycompany/keycloak
...
env:
...
- name: KC_VAULT
value: file
- name: KC_VAULT_DIR
value: /secrets
volumeMounts:
- name: secrets
mountPath: "/secrets"
readOnly: true
volumes:
- name: secrets
secret:
secretName: my-keycloak-secrets
items:
- key: my_secret_config
path: myrealm_my__secret__config