Skip to content

[feat] Add DB Users#148

Merged
crespire merged 9 commits into
mainfrom
crespire/feat-rails-users
Jul 11, 2026
Merged

[feat] Add DB Users#148
crespire merged 9 commits into
mainfrom
crespire/feat-rails-users

Conversation

@crespire

Copy link
Copy Markdown
Contributor

Adding DB users seeded from credentials because I want to use autofill to log in for event ops.

crespire added 4 commits July 11, 2026 11:19
Introduces the persistence layer for admin auth: bcrypt-backed
password_digest, a rotatable session_token from has_secure_token, and
Active Record Encryption on both. An admins:sync rake task upserts
admins from Rails.application.credentials.admins; db/seeds.rb and the
docker entrypoint both invoke it so admin credentials propagate on
every deploy without touching event fixtures. Encryption keys and the
admins list live in encrypted credentials; the previous auth: entry
(used by HTTP basic) is removed in the same edit.
Admin::BaseController now runs before_action :authenticate_admin!
instead of http_basic_authenticate_with. Sessions are keyed on the
user's session_token (not user id) and looked up via .sole so any
duplicate raises rather than silently signing someone in. Sign-in
rotates the token; sign-out nils it, revoking the cookie server-side.
Adds a sign-out button to the navigation partial when signed_in?, and
a minimal Tailwind login view at /login.
Adds a sign_in_as helper to test_helper for integration tests, rewrites
Admin::EventsControllerTest to sign in through /login instead of
sending Authorization headers, and adds SessionsControllerTest covering
GET/POST/DELETE plus the unauthenticated redirect and username
normalization paths.
Notes that admin users and Active Record Encryption keys live in
encrypted credentials, and points at credentials:edit + db:seed as the
workflow for adding or rotating admins.
@crespire
crespire force-pushed the crespire/feat-rails-users branch from c436c8d to 92545b3 Compare July 11, 2026 15:20
crespire added 5 commits July 11, 2026 11:44
CI has no master.key, so Rails can't decrypt credentials at boot and
the User model's encrypts declarations fail with MissingKeyError. Test
data is throwaway; fixed keys in test.rb keep the suite bootable
without exposing the production master key to CI.
Calling Rails.application.load_tasks from within db:seed re-appends
another load_seed action to db:seed's action list; rake then executes
the appended action, which reruns seeds.rb, which calls load_tasks
again, and the action list doubles on every pass. The rake task
remains for manual invocation and the docker entrypoint.
@crespire
crespire merged commit 166bca7 into main Jul 11, 2026
1 check passed
@crespire
crespire deleted the crespire/feat-rails-users branch July 11, 2026 16:03
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant