Identity: accounts, sign-in and sessions through better-auth #10

Merged
alex merged 8 commits from feat/identity into docs/progress-log 2026-10-31 08:59:10 +01:00
Owner

Stacked on #9.

Backend (Identity context, wrapper over better-auth 1.7.10):

  • Local accounts with email and password (at least 10 characters). AUTH_LOCAL_SIGNUP=closed turns self sign-up off.
  • External OpenID Connect providers from AUTH_OIDC_PROVIDERS (better-auth's generic OAuth plugin with discovery and PKCE), for Pocket ID. Configured, not yet tried against a real provider.
  • User ids are ULIDs, so every context keeps naming users urn:habitea:identity:user:<ULID>. No other context changed.
  • better-auth's tables live in the identity schema. Our migrate step runs better-auth's own migration planner; it reports what it applied and refuses unsafe changes.
  • SessionActorResolver turns the session cookie into an Actor for the existing ActorGuard. AUTH_MODE=dev also accepts the x-dev-user-id header for scripts; production refuses it (now the default is session).
  • GET /api/identity/sign-in-options tells the app which providers to show and whether sign-up is open.
  • better-auth is mounted at /api/auth/* before the JSON body parser. Telemetry is off.
  • New config: AUTH_SECRET, AUTH_BASE_URL, AUTH_LOCAL_SIGNUP, AUTH_OIDC_PROVIDERS, documented in .env.example.

Web:

  • The session is asked for before the first route. Every feature route is guarded, and a visitor who is not signed in goes to Sign in.
  • Sign-in, sign-up and account pages with Signal Forms validation; a button per provider.
  • better-auth's refusal codes become Habitea's (identity.invalid_credentials, ...) in the HTTP adapter, so nothing past it knows the library.
  • Signing out is refused while changes wait in the offline queue, so they are never sent as the next person.
  • The app starts afresh after signing in or out.
  • config.json now defaults to authMode: session.

Checked:

  • API: sign-up, session, 200 with the cookie and 401 without, wrong password refused, sign-out and sign-in.
  • Integration test against Postgres: migrations (and a no-op second run), sign-up with a ULID id, the session recognised, closed sign-up refused.
  • Browser: guard redirect, refusal message, password validation, a new account's first habits, check-in and apiary, sign-out and back.
  • State specs: refusals and the sign-out rule.
  • All 44 projects pass lint, typecheck, test and build.

A dev-only demo account is recorded in tools/dev/demo-accounts.json.

Not yet: passkeys (they need HTTPS), invites, email verification and password reset (they need email), UserRegisteredV1 and UserDeletedV1, account deletion.

🤖 Generated with Claude Code

Stacked on #9. **Backend (Identity context, wrapper over better-auth 1.7.10):** - Local accounts with email and password (at least 10 characters). `AUTH_LOCAL_SIGNUP=closed` turns self sign-up off. - External OpenID Connect providers from `AUTH_OIDC_PROVIDERS` (better-auth's generic OAuth plugin with discovery and PKCE), for Pocket ID. Configured, not yet tried against a real provider. - User ids are ULIDs, so every context keeps naming users `urn:habitea:identity:user:<ULID>`. No other context changed. - better-auth's tables live in the `identity` schema. Our migrate step runs better-auth's own migration planner; it reports what it applied and refuses unsafe changes. - `SessionActorResolver` turns the session cookie into an `Actor` for the existing `ActorGuard`. `AUTH_MODE=dev` also accepts the `x-dev-user-id` header for scripts; production refuses it (now the default is `session`). - `GET /api/identity/sign-in-options` tells the app which providers to show and whether sign-up is open. - better-auth is mounted at `/api/auth/*` before the JSON body parser. Telemetry is off. - New config: `AUTH_SECRET`, `AUTH_BASE_URL`, `AUTH_LOCAL_SIGNUP`, `AUTH_OIDC_PROVIDERS`, documented in `.env.example`. **Web:** - The session is asked for before the first route. Every feature route is guarded, and a visitor who is not signed in goes to Sign in. - Sign-in, sign-up and account pages with Signal Forms validation; a button per provider. - better-auth's refusal codes become Habitea's (`identity.invalid_credentials`, ...) in the HTTP adapter, so nothing past it knows the library. - Signing out is refused while changes wait in the offline queue, so they are never sent as the next person. - The app starts afresh after signing in or out. - `config.json` now defaults to `authMode: session`. **Checked:** - API: sign-up, session, 200 with the cookie and 401 without, wrong password refused, sign-out and sign-in. - Integration test against Postgres: migrations (and a no-op second run), sign-up with a ULID id, the session recognised, closed sign-up refused. - Browser: guard redirect, refusal message, password validation, a new account's first habits, check-in and apiary, sign-out and back. - State specs: refusals and the sign-out rule. - All 44 projects pass lint, typecheck, test and build. A dev-only demo account is recorded in `tools/dev/demo-accounts.json`. **Not yet:** passkeys (they need HTTPS), invites, email verification and password reset (they need email), `UserRegisteredV1` and `UserDeletedV1`, account deletion. 🤖 Generated with [Claude Code](https://claude.com/claude-code)
The Identity context wraps better-auth inside the API: email and password
accounts, external OpenID Connect providers from configuration, cookie
sessions, ULID user ids, tables in the identity schema planned by better-auth
and applied by our migrate step, telemetry off. A session actor resolver
feeds the existing ActorGuard; AUTH_MODE=dev keeps the header for scripts.
The web app gains sign-in, sign-up and account pages, guarded routes, a
session loaded before the first route, and refuses to sign out while changes
wait in the offline queue.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Breeding costs 15 pollen and raises a queen from a mother colony on an open
flight (Andalusia's wild drones) or a controlled one: half of each trait from
each side, seeded mutations, reproducible from the breeding's id. Queens wait
in a reserve and can head the hive; the replaced queen returns to the reserve.
New species are discovered along the way. Each step is its own transaction,
chained by the apiary's own events. The app breeds, installs, waits for the
server to catch up, and tints the bees with their queen's colours.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The hive scene becomes a floating voxel island in Andalusia: grass, dirt and
stone blocks, an olive tree, a lavender crop, and a wooden hive whose workers
beat their wings in their queen's colours. Every texture is painted at start-up
from pixel maps and scaled up without smoothing.

The whole Apiary page wears a new pixel skin from the design system: bevelled
panels, inventory slots, segmented bars, pixel buttons and notes, and the
Pixelify Sans font. A bee codex shows the species found so far. The look takes
after the Minecraft bee mods that inspired the game, with art of our own.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The voxel island now fills the page at the largest whole-number scale that
still shows it, under a sky with distant islets. A heads-up display sits over
the scene: the hive and its harvest, the stores, a hotbar of menus, and the
biome. The queen, breeding, reserve and codex open as pixel drawers that slide
in from the left or the right; Escape closes them.

The design system gains hab-game-layout, hab-pixel-drawer and hab-slot-button,
and the pixel panel can go without a heading or with compact padding.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Reviewed-on: https://git.selene.acl.sh/Habitea/App/pulls/12
Reviewed-on: https://git.selene.acl.sh/Habitea/App/pulls/11
alex merged commit a1e7623983 into docs/progress-log 2026-10-31 08:59:10 +01:00
Sign in to join this conversation.
No reviewers
No labels
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set

Reference
Habitea/App!10
No description provided.