[feat] Add DB Users#148
Merged
Merged
Conversation
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
force-pushed
the
crespire/feat-rails-users
branch
from
July 11, 2026 15:20
c436c8d to
92545b3
Compare
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.
This was referenced Jul 11, 2026
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.
Adding DB users seeded from credentials because I want to use autofill to log in for event ops.