This directory contains various examples demonstrating the usage of JWT-Vault-Go.
Before running any example, make sure you have Vault running and configured:
# Start Vault dev server
vault server -dev
# In another terminal
export VAULT_ADDR='http://127.0.0.1:8200'
export VAULT_TOKEN='dev-token'
# Enable transit engine
vault secrets enable transit
# Create keys for different algorithms
vault write -f transit/keys/jwt-key-ES256 type=ecdsa-p256
vault write -f transit/keys/jwt-key-RS256 type=rsa-2048
vault write -f transit/keys/jwt-key-PS256 type=rsa-2048
Basic JWT signing and verification with default settings (ES256).
go run examples/basic/main.go
Examples of using different signing algorithms (ECDSA, RSA, RSA-PSS).
go run examples/algorithms/main.go
Using custom claims structures with JWT-Vault-Go.
go run examples/custom-claims/main.go
Demonstrating key rotation functionality.
go run examples/key-rotation/main.go
Example of using JWT-Vault-Go in an HTTP middleware.
go run examples/middleware/main.go
Examples of token validation and error handling.
go run examples/validation/main.go
When adding new examples:
- Create a new directory under
examples/
- Include a
main.go
file demonstrating the feature - Update this README with a description
- Ensure the example includes proper error handling
- Document any special setup requirements