Increment 2 - Step 1: Authentication Schema - #12
Merged
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Increment 2 – Step 1: Authentication Schema
First step of the auth & RBAC increment: the database schema that users, roles and sessions will be built on.
What's new
db/migrations/0002_auth.sql(append-only, applied to bothmodulo_devandmodulo_test):users- uuid primary key, case-insensitivecitextemail (unique), display name, Argon2id password hash,disabled_atfor lock-out, not-blank checks.roles- fixed catalogue with stable ids (1 = admin,2 = user) anduser_roleslinking table (cascades on user deletion).sessions- stores only the SHA-256 digest of each opaque bearer token (a check constraint enforces exactly 32 bytes), slidingexpires_at,last_seen_at,revoked_at, plus a partial index on active sessions per user for "log out everywhere".set_updated_at()trigger function that later tables will attach as well.docs/high_level_design.md- new Data model section with an ER diagram of every table, cross-checked against the migrations and the live database.v0.1.0shipped / Increment 2 in progress, table of contents, log row 2.1.Notes
pgcryptois not enabled:gen_random_uuid()is built into PostgreSQL 13+ and password hashing happens in libsodium on the server, so onlycitextis added.Verified: migration applied and re-run as a no-op; constraint probe in a rolled-back transaction - duplicate email differing only by case rejected, short token rejected, user deletion cascades to sessions and roles,
updated_attrigger overrides manual values;ctest --preset all7/7.