diff --git a/e2e/vaultcompat/cluster_setup_test.go b/e2e/vaultcompat/cluster_setup_test.go index 48a6d7818..67eefdd48 100644 --- a/e2e/vaultcompat/cluster_setup_test.go +++ b/e2e/vaultcompat/cluster_setup_test.go @@ -36,7 +36,7 @@ func roleWID(policies []string) map[string]any { return map[string]any{ "role_type": "jwt", "bound_audiences": "vault.io", - "user_claim": "/nomad_job_id", + "user_claim": "/extra_claims/nomad_workload_id", "user_claim_json_pointer": true, "claim_mappings": map[string]any{ "nomad_namespace": "nomad_namespace", diff --git a/e2e/vaultcompat/input/restricted_jwt.hcl b/e2e/vaultcompat/input/restricted_jwt.hcl new file mode 100644 index 000000000..3ad151cbe --- /dev/null +++ b/e2e/vaultcompat/input/restricted_jwt.hcl @@ -0,0 +1,38 @@ +# Copyright (c) HashiCorp, Inc. +# SPDX-License-Identifier: BUSL-1.1 + +job "restricted_jwt" { + type = "batch" + + // Tasks in this group are expected to succeed and run to completion. + group "success" { + vault {} + + count = 2 + + // Task default_identity uses the default workload identity injected by the + // server and the inherits the Vault configuration from the group. + task "authorized" { + driver = "raw_exec" + + config { + command = "cat" + args = ["${NOMAD_SECRETS_DIR}/secret.txt"] + } + + // Vault has an alias that maps this job's nomad_workload_id to an entity + // with a policy that allows access to these secrets + template { + data = < **Warning:** The token-based authentication flow is deprecated and will be @@ -316,3 +342,4 @@ can be accomplished by sending the process a `SIGHUP` signal. [vault_bound_aud]: /vault/api-docs/auth/jwt#bound_audiences [vault_auth_enable_path]: /vault/docs/commands/auth/enable#path [workload_id]: /nomad/docs/concepts/workload-identity +[vault-jwt-user-claim]: /vault/api-docs/auth/jwt#user_claim