Skip to content

0017 better auth

github-actions[bot] edited this page Nov 18, 2026 · 2 revisions

Accounts use Better Auth

Status: accepted · Implementation: done · Date: 2026-11-18

From LibreLifts ADR 0029, version 1.7.20. Better Auth had several security advisories in 2026, one of them critical. Built 2026-11-18 at 1.7.20, with the anonymous and Expo plugins and telemetry off. Two files in the API import it and one in the app.

Context

The API owns LibreBars' accounts (0015), and every install starts as a guest (0016). Something has to create those accounts, keep their sessions, and later turn a guest into a full account without losing its data.

Writing this by hand means owning the security of it. Hosted sign-in services would put the project's accounts in someone else's hands. Better Auth is an open-source library that runs inside the API and keeps its data in the project's own Postgres.

Decision

  • Accounts are handled by Better Auth, running inside the Fastify API and storing its data in Postgres.
  • Guests use its anonymous accounts.
  • The app uses its Expo support, which keeps the session in the device's secure storage. The website uses a session cookie from the API.
  • Its version is pinned exactly. An update is a change of its own, made after reading what changed.
  • As few files as possible import it: one in the app, and in the API the file that sets it up and the plugin that mounts it.
  • It sends nothing to its makers. Its telemetry is switched off.

Consequences

  • The parts that are easy to get wrong, such as sessions and sign-in methods, are not written here.
  • The project depends on a fast-moving library for something that must not break. Its advisories have to be watched.
  • Its tables live in the project's database, in a schema of their own, and are migrated with the rest.
  • If it has to be replaced, accounts are rows in the project's own Postgres and can be read without it.

LibreBars

Clone this wiki locally