Onyxia-ui ask a personal vault token for a user and inject the token in VAULT_TOKEN env var.
/opt/onyxia-init.sh use this vault token to inject the content of a secret in environment variables.
Some drawbacks:
VAULT_TOKEN=$(vault write -field="token" auth/$VAULT_INJECTION_SA_AUTH_PATH/login role=$VAULT_INJECTION_SA_AUTH_ROLE jwt=@/var/run/secrets/kubernetes.io/serviceaccount/token)
vault auth enable --path=kubernetes-cluster jwt
cat <<EOF | vault write auth/kubernetes-cluster/role/kubernetes-role -
{
"policies": ["kubernetes-role"],
"user_claim": "/kubernetes.io/namespace",
"user_claim_json_pointer": "true",
"bound_audiences": "https://kubernetes.default.svc.cluster.local",
"claim_mappings": {
"/kubernetes.io/namespace": "namespace"
},
"role_type": "jwt",
"ttl": "1h"
}
EOF
path "onyxia-kv/data/{{identity.entity.aliases.auth_jwt_9cdca6c6.name}}/*" {
capabilities = ["read","list"]
}
path "onyxia-kv/{{identity.entity.aliases.auth_jwt_9cdca6c6.name}}/*" {
capabilities = ["read","list"]
}
path "onyxia-kv/metadata/{{identity.entity.aliases.auth_jwt_9cdca6c6.name}}/*" {
capabilities = ["read","list"]
}
{
"Version": "2012-10-17",
"Statement": [
{
"Sid": "S3ConsoleAccess",
"Effect": "Allow",
"Action": [
"s3:GetBucketLocation",
"s3:ListAllMyBuckets"
],
"Resource": ["arn:aws:s3:::home"]
},
{
"Sid": "ListObjectsInBucket",
"Effect": "Allow",
"Action": ["s3:ListBucket"],
"Resource": "arn:aws:s3:::home",
"Condition": {
"StringLike": {
"s3:prefix": [
"user-${jwt:preferred_username}",
"user-${jwt:preferred_username}/",
"user-${jwt:preferred_username}/*"
]
}
}
},
{
"Sid": "ListMultipart",
"Effect": "Allow",
"Action": ["s3:ListMultipartUploadParts","s3:ListBucketMultipartUploads","s3:AbortMultipartUpload"],
"Resource": "arn:aws:s3:::home"
},
{
"Effect": "Allow",
"Action": "s3:*",
"Resource": [
"arn:aws:s3:::home/user-${jwt:preferred_username}/",
"arn:aws:s3:::home/user-${jwt:preferred_username}/*"
]
}
]
}
{preferred_username:'alexisdondon', groups : [shared-test-r], policy : [home, shared-test]}
{
"Version": "2012-10-17",
"Statement": [
{
"Sid": "shared-test-listobject",
"Effect": "Allow",
"Action": [
"s3:ListBucket"
],
"Resource": "arn:aws:s3:::shared",
"Condition": {
"ForAnyValue:StringEquals": {
"jwt:groups": [
"shared-test-r",
"shared-test-rw"
]
},
"StringLike": {
"s3:prefix": [
"test/",
"test/*"
]
}
}
},
{
"Sid": "shared-test-read",
"Effect": "Allow",
"Action": [
"s3:GetObject"
],
"Resource": [
"arn:aws:s3:::shared/test/*"
],
"Condition": {
"ForAnyValue:StringEquals": {
"jwt:groups": [
"shared-test-r"
]
}
}
},
{
"Sid": "shared-test-write",
"Effect": "Allow",
"Action": [
"s3:*"
],
"Resource": [
"arn:aws:s3:::shared/test/*"
],
"Condition": {
"ForAnyValue:StringEquals": {
"jwt:groups": [
"shared-test-w"
]
}
}
}
]
}
Equipe Datascience