Skip to content

Commit 3ab7b81

Browse files
authored
Merge pull request #390 from authzed/simplify_fgam_token_generation
chore(docs): simplify FGAM token generation
2 parents 34b56dd + 1ee301b commit 3ab7b81

File tree

1 file changed

+7
-6
lines changed

1 file changed

+7
-6
lines changed

pages/authzed/concepts/restricted-api-access.mdx

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -251,18 +251,19 @@ If you want to apply a configuration to an existing SpiceDB cluster without down
251251
```sh
252252
# Generate your secret (substitute your preferred method for generating a cryptographically-secure random string here)
253253
# This will be a part of the token
254-
base64 < /dev/random | head -c64
254+
SECRET="$(base64 < /dev/random | head -c64)"; echo "$SECRET"
255255
# g2l2/YjC3jFg6FdV080qiqBPvCrlLuc9GcHutgHF4WhVjsg7+AvlqLmoCrJEC68t
256256

257257
# Hash that secret using sha256sum
258258
# This will go in your FGAM configuration as the token hash
259259
# NOTE: truncate the trailing spaces and "-". You just want the alphanum characters.
260-
echo -n "g2l2/YjC3jFg6FdV080qiqBPvCrlLuc9GcHutgHF4WhVjsg7+AvlqLmoCrJEC68t" | sha256sum
261-
# 1d619ac2f5013845c5f2df93add92fc87e88ca6c57d19a77d1b189663f1ff5b0 -
260+
HASH="$(echo -n "$SECRET" | sha256sum | cut -d" " -f1)"; echo "$HASH"
261+
# 1d619ac2f5013845c5f2df93add92fc87e88ca6c57d19a77d1b189663f1ff5b0
262262

263-
# Add the prefix to create the token that you'll supply to your client
264-
echo "sdbst_h256_g2l2/YjC3jFg6FdV080qiqBPvCrlLuc9GcHutgHF4WhVjsg7+AvlqLmoCrJEC68t"
265-
# sdbst_h256_g2l2/YjC3jFg6FdV080qiqBPvCrlLuc9GcHutgHF4WhVjsg7+AvlqLmoCrJEC68t
263+
# Add the prefix "sdbst_h256_" to create the token that you'll supply to your client
264+
printf "token: sdbst_h256_%s\nhash: %s\n" "$SECRET" "$HASH"
265+
# token: sdbst_h256_g2l2/YjC3jFg6FdV080qiqBPvCrlLuc9GcHutgHF4WhVjsg7+AvlqLmoCrJEC68t
266+
# hash: 1d619ac2f5013845c5f2df93add92fc87e88ca6c57d19a77d1b189663f1ff5b0
266267
```
267268

268269
2. Prepare the FGAM configuration YAML.

0 commit comments

Comments
 (0)