Shelf JWT Auth
Overview
Get started with Shelf JWT Authentication for your backend. Register user with Username/Password & issue JWT tokens for accessing protected routes.
Getting Started
Bootstrap
Initialize your project using the command below
$ globe create -t shelf_jwt_auth
For local development, create a
.envfile in the root of your project and provideJWT_SECRET_KEYenvironment variable.
Start Server
$ dart run bin/server
REST Endpoints
Register User
curl -X POST -H "Content-Type: application/json" -d '{"username": "john", "password": "password123"}' http://localhost:8080/registerUser registeredLogin User
curl -X POST -H "Content-Type: application/json" -d '{"username": "john", "password": "password123"}' http://localhost:8080/login{ "token": "<your-jwt-token>" }Get Current User
curl -H "Authorization: Bearer <your-jwt-token>" http://localhost:8080/me{ "id": "user_id", "username": "john", "createdAt": "2024-05-07T12:30:45Z" }