Vault
Onyxia-web uses vault as a storage for two kinds of secrets: 1. secrets or information generated by Onyxia to store different values (S3 sources configuration) 2. user secrets\
Onyxia uses the KV version 2 secret engine. Vault must be configured with JWT or OIDC authentification methods.
As Vault needs to be initialized with a master key, it can't be directly configured with all parameters such as oidc or access policies and roles. So first step we create a vault with dev mode (do not use this in production and do your initialization with any of the recommanded configuration: Shamir, gcp, another vault).
helm repo add hashicorp https://helm.releases.hashicorp.com
DOMAIN=my-domain.net
cat << EOF > ./vault-values.yaml
server:
dev:
enabled: true
# Set VAULT_DEV_ROOT_TOKEN_ID value
devRootToken: "root"
ingress:
enabled: true
annotations:
kubernetes.io/ingress.class: nginx
hosts:
- host: "vault.lab.$DOMAIN"
tls:
- hosts:
- vault.lab.$DOMAIN
EOF
helm install vault hashicorp/vault -f vault-values.yamlSetting up JWT authentication for Vault
The authentication step already configured the vault audience on tokens issued to onyxia. Vault will validate those tokens and use onyxia-username as the user's identifier. No additional Keycloak client, login flow, or client secret is needed for this JWT integration.
We will now configure Vault to enable JWT support, set policies for users permissions and initialize the secret engine.
You will need the Vault CLI. You can either download it here and configure VAULT_ADDR=https://vault.lab.my-domain.net and VAULT_TOKEN=root or exec into the vault pod kubectl exec -it vault-0 -n vault -- /bin/sh which will have vault CLI installed and pre-configured.
First, we start by creating a JWT endpoint in Vault, and writing information about Keycloak to the configuration. We use the same realm as usually in this documentation.
All users authenticate with the onyxia-user Vault role; claims and policies determine their access.
First you need to get the identifier (mount accessor) for the JWT authentification just created. You can use :
which should provide you something like auth_jwt_xyz. You will need it to write a proper policy by replacing the auth_jwt_xyz content with your own value.
Setting up a policy
Create locally a file named onyxia-policy.hcl.
You can notice that this policy is written for a KV version 2 secret engine mounted to the onyxia-kv path. The following policy is only working for personnal access because the entity alias name will be the onyxia-username claim in the JWT token.
The following optional group-policy example expects group0 through group9 in the entity alias metadata. To use it, configure matching claim_mappings on the Vault role, such as /groups/0=group0. Only map indices present in every token accepted by that role: Vault rejects logins when a mapped claim is missing. The personal role below omits these mappings so group membership remains optional.
Once the policy file is created, we can proceed with creating the policy.
Create the onyxia-user role for personal storage:
We need to enable the secret engine.
Then, you need to allow the URL https://datalab.my-domain.net in Vault's CORS settings.
Add the Vault settings to your existing region in apps/onyxia/values.yaml, preserving its service and S3 configuration:
Last updated
Was this helpful?