Case study

Bastion

The sign-in system every SaaS needs, built carefully once.

Bastion screenshot

Every software-as-a-service product needs accounts, sign-in, password recovery, and an admin area before it can do anything else, and most teams build them in a hurry. Bastion is our answer: an open-source starter kit for Spring Boot and React that does all of it properly, documents how, and proves each security control with a test.

The challenge

Authentication looks simple and isn't. A sign-in page that leaks whether an email has an account, a password reset that skips two-factor, a stolen refresh token that keeps working for weeks: each is a common mistake, and each can hand an attacker an account. Teams under deadline pressure rarely have time to get them all right, and a security bug in sign-in puts every customer at risk.

We wanted a foundation we could start every product on, without cutting corners, that any team could adopt and understand.

What we built

Modern sign-in, done fully

Email and password with authenticator-app two-factor and recovery codes, plus passkeys for phishing-resistant, passwordless sign-in. Passwords are hashed with Argon2id and checked against known breaches without the password ever leaving the server.

Sessions that can't be quietly stolen

Short-lived access tokens live only in memory; refresh tokens rotate on every use. Replaying an old refresh token is treated as theft and signs out every session. Sign-out, account locks, and password resets take effect on the very next request.

No leaks, no shortcuts

Every account endpoint gives the same answer, in the same time, whether or not the account exists. Password reset never bypasses two-factor. Sensitive changes ask the user to confirm who they are again, and the admin area requires a two-factor session.

Hardened down to the containers

Every container runs read-only and unprivileged on its own network segment, the web tier can't reach the database, and the application's database login can only read and write rows. Images and CI actions are pinned and scanned on every change.

Documented honestly

A written security model lists every threat Bastion addresses, the control that answers it, the test that proves it, and the risks that remain the adopter's. A one-command rename and an AI-assisted setup guide turn it into a new project.

Results

  • 83 backend tests, including real passkey ceremonies against an emulated authenticator and the real database migrations run on MySQL
  • Every change runs static analysis, CodeQL, dependency and container scanning, secret detection, and a smoke test that proves the hardening on a running stack
  • The identity service inside Commerce, our event-driven web store, is Bastion, copied and renamed with none of its controls weakened
  • Free and open source under the MIT licence, for anyone to build on

Technology

Spring BootJavaReactTypeScriptMySQLDocker

Services behind this project

Next case study

Commerce

A web store built the way a high-traffic one should be.

Have a project in mind?

Let's talk about what we can build together.

Get in touch