Cloudflare Worker to generate JSON Web Tokens. Useful for environments without performant crypto implementations (Roblox). Specifically adapted for Firestore at the moment.
- Configure wrangler.toml according to the Cloudflare Workers Docs
- Grab yourself a service account keyfile from GCP IAM
- Name the keyfile
gcp-auth.json
and put it in the root directory - Run
node ./generateConfig.js
- Run
wrangler publish
to deploy and create the worker on the Cloudflare site, it still won't be functional however - Copy the
private_key
field from the keyfile into an encrypted Worker Environment Variable calledGCP_KEY
- Generate a long random string to use as an authentication token, copy into an encrypted Worker Environment Variable called
AUTH_TOKEN
- The Worker is up and running! Just make a simple GET request to get a fresh GCP JWT. Note: the request must contain a
token
header containing the authentication token set in step 7