all templates
API & Backend

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

Browse the code

The full source, exactly as it ships in the repo.

loading…
Download .zip
loading tree…

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.