Rust CRUD API — Actix · MongoDB
Actix-web 4 + MongoDB with JWT from cookie or Bearer, and rotating refresh tokens.
An Actix-web 4 take on the Rust API: public and private endpoints, a short-lived access token plus a single-use refresh token that rotates on every refresh, read from either an HttpOnly cookie or an Authorization: Bearer header. A CurrentUser extractor handles login and User / Admin role checks, and passwords are bcrypt-hashed. One `docker compose up --build` runs the API with MongoDB 8.
What's inside
- Public + private REST endpoints
- JWT from a cookie or a Bearer header
- Access (15 min) + single-use refresh tokens (7 days)
- Role checks via a CurrentUser extractor
- bcrypt password hashing
- compose: API + MongoDB 8, healthchecked
Quickstart
$ git clone https://github.com/devai-io/devai_boilerplates.git$ cd devai_boilerplates/rust-crud-actix-mongo-api$ docker compose up --build # API on http://localhost:8080
about this series
One of the devai.io advanced Rust boilerplates — the Actix-web flavor, with cookie/Bearer auth and token rotation, brought up to date.
More in API & Backend
view allRust CRUD API — Warp · Postgres
A JWT-secured REST API in Rust: Warp handlers, sqlx, Postgres, role-based routes.
Rust CRUD API — Warp · MongoDB
The same JWT-secured Rust API, backed by MongoDB instead of Postgres.