Skip to content
This repository was archived by the owner on May 15, 2025. It is now read-only.

Commit 41f875e

Browse files
committed
update readme
1 parent 28a70b0 commit 41f875e

File tree

1 file changed

+19
-17
lines changed

1 file changed

+19
-17
lines changed

vault-jwt/README.md

Lines changed: 19 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -14,13 +14,13 @@ This module lets you authenticate with [Hashicorp Vault](https://www.vaultprojec
1414

1515
```tf
1616
module "vault" {
17-
count = data.coder_workspace.me.start_count
18-
source = "registry.coder.com/modules/vault-jwt/coder"
19-
version = "1.0.21"
20-
agent_id = coder_agent.example.id
21-
vault_addr = "https://vault.example.com"
22-
vault_jwt_role = "coder" # The Vault role to use for authentication
23-
vault_jwt_token= "eyJhbGciOiJIUzI1N..." # optional, if not present, defaults to user's oidc authentication token
17+
count = data.coder_workspace.me.start_count
18+
source = "registry.coder.com/modules/vault-jwt/coder"
19+
version = "1.0.21"
20+
agent_id = coder_agent.example.id
21+
vault_addr = "https://vault.example.com"
22+
vault_jwt_role = "coder" # The Vault role to use for authentication
23+
vault_jwt_token = "eyJhbGciOiJIUzI1N..." # optional, if not present, defaults to user's oidc authentication token
2424
}
2525
```
2626

@@ -81,7 +81,6 @@ module "vault" {
8181
}
8282
```
8383

84-
8584
### use a custom jwt token
8685

8786
```tf
@@ -104,7 +103,7 @@ resource "jwt_signed_token" "vault" {
104103
count = data.coder_workspace.me.start_count
105104
algorithm = "RS256"
106105
# `openssl genrsa -out key.pem 4096` and `openssl rsa -in key.pem -pubout > pub.pem` to generate keys
107-
key = file("key.pem")
106+
key = file("key.pem")
108107
claims_json = jsonencode({
109108
iss = "https://code.example.com"
110109
sub = "${data.coder_workspace.me.id}"
@@ -132,16 +131,18 @@ resource "jwt_signed_token" "vault" {
132131
}
133132
134133
module "vault" {
135-
count = data.coder_workspace.me.start_count
136-
source = "registry.coder.com/modules/vault-jwt/coder"
137-
version = "1.0.20"
138-
agent_id = coder_agent.example.id
139-
vault_addr = "https://vault.example.com"
140-
vault_jwt_role = "coder" # The Vault role to use for authentication
141-
vault_jwt_token = jwt_signed_token.vault[0].token
134+
count = data.coder_workspace.me.start_count
135+
source = "registry.coder.com/modules/vault-jwt/coder"
136+
version = "1.0.20"
137+
agent_id = coder_agent.example.id
138+
vault_addr = "https://vault.example.com"
139+
vault_jwt_role = "coder" # The Vault role to use for authentication
140+
vault_jwt_token = jwt_signed_token.vault[0].token
142141
}
143142
```
143+
144144
#### example vault jwt role
145+
145146
```
146147
vault write auth/<JWT_MOUNT>/role/workspace -<<EOF
147148
{
@@ -168,7 +169,9 @@ vault write auth/<JWT_MOUNT>/role/workspace -<<EOF
168169
}
169170
EOF
170171
```
172+
171173
#### example workspace access vault policy
174+
172175
```hcl
173176
path "kv/data/app/coder/{{identity.entity.aliases.<MOUNT_ACCESSOR>.metadata.owner_name}}/{{identity.entity.aliases.<MOUNT_ACCESSOR>.metadata.workspace_name}}" {
174177
capabilities = ["create", "read", "update", "delete", "list", "subscribe"]
@@ -179,4 +182,3 @@ path "kv/metadata/app/coder/{{identity.entity.aliases.<MOUNT_ACCESSOR>.metadata.
179182
subscribe_event_types = ["*"]
180183
}
181184
```
182-

0 commit comments

Comments
 (0)