jwt-mock-server
v0.0.6
Published
Start a mock jwt authentication server for local development
Downloads
133
Maintainers
Readme
A JWT mock server for local development
Run in local
npm install
npm run start
## OR
npm run start -- --claims '{"username": "[email protected]", "userId": 1, "authorities": ["AUTH_1"]}'
Run with npx
default port 9000
npx --package jwt-mock-server start
to run in a different port 3000
PORT=3000 npx --package jwt-mock-server start
endpoints
curl --location --request GET 'localhost:9000/jwt/.well-known/jwks.json'
get a jwt token and pass claims in post body
curl --location --request POST 'localhost:9000/jwt/token' \
--header 'Content-Type: application/json' \
--data-raw '{"username": "[email protected]"}'
get a jwt using get and pass claims in query params:
curl --location --request GET 'localhost:9000/jwt/[email protected]&authorities=AUTH_WP&authorities=AUTH_WP2' \
--header 'Content-Type: application/json'
or you can get the default claims, the default claims needs to be passed when you start the server
npx --package github:ruiyang/jwt-mock-server start --claims '{"username": "[email protected]"}'
curl --location --request GET 'localhost:9000/jwt/token' \
--header 'Content-Type: application/json'
shutdown the server gracefully
curl --location --request GET 'localhost:9000/shutdown'