2025-01-06 17:26 | IT / Coding / How-To | rust, axum, rest-api, postgres, sqlx, redis, jwt, tokens, docker
Getting started with REST API Web Services in Rust using Axum, PostgreSQL, Redis, and JWT
(Draft)
GitHub: https://github.com/sheroz/axum-rest-api-sample
This sample starter project covers:
REST API based on axum
- Routing
- API versioning
- CORS settings
- Error handling (basic)
- Graceful shutdown
Authentication & authorization using JSON Web Tokens (JWT)
- Login, logout, refresh, and revoking operations
- Role based authorization
- Generating and validating access and refresh tokens
- Setting tokens expiry time (based on configuration)
- Using refresh tokens rotation technique
- Revoking issued tokens by using
Redis
(based on configuration)- Revoke all tokens issued until the current time
- Revoke tokens belonging to the user issued until the current time
- Cleanup of revoked tokens
Using PostgreSQL
database with SQLx
driver
- Database migrations
- Async connection pooling
- Async CRUD operations
Using Redis
in-memory storage
- Async
Redis
operations
Configuration settings
- Loading and parsing
.env
file - Using environment variables
Logs
- tracing based logs
Tests
Docker
based end-to-end tests- GitHub CI configuration for running tests
Using Docker
for running services
PostgreSQL
andRedis
- Building the application using the official
Rust
image - Running the full stack: API +
PostgreSQL
+Redis
The source code is available on GitHub: https://github.com/sheroz/axum-rest-api-sample
2025 January (1)
2023 September (1)
2023 August (1)
2019 May (1)
2016 March (2)
2016 February (1)
2014 December (1)
2013 May (1)
2013 March (1)
2013 February (1)
2012 December (2)
2012 October (1)
2011 February (2)
2010 October (2)
2010 July (1)
2010 May (1)
2010 April (1)
2023 September (1)
2023 August (1)
2019 May (1)
2016 March (2)
2016 February (1)
2014 December (1)
2013 May (1)
2013 March (1)
2013 February (1)
2012 December (2)
2012 October (1)
2011 February (2)
2010 October (2)
2010 July (1)
2010 May (1)
2010 April (1)
IT / Coding / How-To
28147-89 (1), access (1), ajax (1), apple (1), asus (1), axum (1), benchmark (1), block-cipher (1), c++ (1), cache (1), capistrano (1), centos (2), chrome (1), client (1), clock (1), cntvct_el0 (1), counter (1), counter-timer-register (1), cryptography (1), crystal reports (1), database (4), dbase (1), dbf (1), docker (2), error (7), fedora (2), firefox (1), google (2), gost (1), gost-28147-89 (1), gost-r-34-12-2015 (1), highlight (1), hp (1), html (1), intel (1), intellijidea (1), ireport (1), jasperreports (1), jaspersoft (1), java (5), javascript (2), jdbc (1), jdk (1), jet (1), jetty (1), jquery (2), jwt (1), laptop (1), linux (8), macos (1), magma (1), mongodb (1), ms visual c++ (1), mysql (1), native (1), network (2), openvpn (1), oracle (2), performance (3), postgres (2), postgresql (2), prettify (1), r-34-12-2015 (1), rails (1), ramdisk (2), ramdrive (2), rdtsc (1), rdtscp (1), recaptcha (1), redis (2), rest (1), rest-api (1), restful (1), ruby (1), rust (3), security (3), server (2), sidekiq (1), spam (1), spring (1), sql (1), sqlx (1), startup (1), subversion (1), svn (1), syntax (1), time-stamp-counter (1), timer (1), tokens (1), tomcat (2), ubuntu (2), update (1), vba (1), web service (1), wifi (1), winapi (1), windows (9)
Other Topics
active directory (1), java (1), jcifs (1), kerberos (1), ldap (1), linux (1), ntlm (1), spnego (1), story (1), ubuntu (1), windows (1)