Kick-start template for building REST API Web service in Rust using axum
, JSON Web Tokens (JWT)
, PostgreSQL
, and Redis
The project covers:
- REST API based on
axum
- routing
- api versioning
- CORS settings
- basic error handling
- graceful shutdown
JSON Web Tokens (JWT)
based authentication & authorization- login, logout, refresh, and revoking operations
- role based authorization
- generating and validating of access and refresh tokens
- setting the tokens expiry time (based on configuration)
- using the refresh tokens rotation technique
- revoking the issued tokens by using
Redis
(based on configuration)- revoke all tokens issued until the current time
- revoke tokens belonging to a user issued until the current time
- cleanup of revoked tokens
PostgreSQL
database withSQLx
driver- database migrations
- async connection pooling
- async CRUD operations
Redis
in-memory storage- async operations
.env
based configuration parsingtracing
based logsdocker-compose
configurationRedis
servicePostgreSQL
service
- Tests
docker
based end-to-end tests- GitHub CI configuration for running tests
Running the REST API service:
docker-compose up -d
cargo run
Running the service in test configuration:
ENV_TEST=1 cargo run
REST API tests: /tests
REST API parameters: tests/endpoints.http
Running the API tests:
docker-compose up -d
cargo test
Setting the RUST_LOG
- logging level on the launch:
RUST_LOG=info,hyper=debug,axum_web=trace cargo run
Development: this project is under development, you should not expect stability yet.