Repository navigation
Open sign-up with admin approval; fix OAuth linking, duplicate usernames, root container - #41
Merged
Merged
Conversation
…container Registration: open again by default. A new account is unapproved (users.is_approved) and only gets its own todo list, notes and draft posts. Only approved accounts and the admin can use the rule buttons that change the network filter (disable_ai, exec_rules), trigger email/Discord notifications, or publish public blog posts. The admin approves accounts in a new Accounts card on MGMT. ALLOW_REGISTRATION=False still closes sign-up. OAuth: Google/GitHub sign-in only uses a provider-verified email (GitHub no longer falls back to an unverified address; Google must report email_verified). An existing account is matched by email only if it was itself created by a provider, so a later Google login can't land in an account someone pre-registered with the victim's address and their own password. Usernames: Google/GitHub display names that are taken get a suffix (Alex-2), because todo lists are keyed by username. migrate.py adds a unique index on users.username, skipped with a notice while duplicates exist. Container: the app runs as an unprivileged user (APP_UID/APP_GID, default 1000) instead of root, and the SSH mount is SSH_KEY_DIR (default ~/.ssh) at /home/app/.ssh so a dedicated deploy key can be used. migrate.py must be run after deploying: the app now reads users.is_approved. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_012k19dCKBK4J2UdDMJd5gLv
Codex Review Summary: ✅ CompletedThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 5d2e001f62
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
The README quickstart loaded scripts/schema.sql and stopped, but that snapshot has no users.is_approved (nor lotto_photos), so login would fail on a database built that way. The quickstart now runs migrate.py and says why it is required. Also write the PL/pgSQL block's final END with a semicolon. PostgreSQL 16 accepted it without one, but the terminated form is the documented one. Verified on PostgreSQL 16: schema.sql + migrate.py (run twice), then register and login succeed and the new account is unapproved. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_012k19dCKBK4J2UdDMJd5gLv
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.
Summary
Fixes four medium findings from the security audit.
1. Open registration, safely
Open sign-up was never the problem; the problem was that any new account could touch the family's shared filter.
ALLOW_REGISTRATION=Falsestill closes it).users.is_approved). They get their own todo list, notes and draft blog posts, and nothing else./rules_toggle/disable_ai,/exec_rules/...)POST /users/<id>/approve, admin only).2. Google/GitHub sign-in no longer links by unverified email
email_verified.3. Unique usernames
Alex-2), because todo lists are keyed by username.migrate.pyadds a unique index onusers.username. If duplicates already exist, it skips the index and prints a notice instead of failing.User.iddefault is now a UUID string, not a UUID object (same stored value on Postgres; fixes SQLite in tests).4. Container no longer runs as root
Dockerfile: the app runs as unprivileged userapp(APP_UID/APP_GIDbuild args, default 1000). Playwright's Firefox is installed to a shared path so that user can launch it; gitsafe.directoryis set for the mounted rules repo.docker-compose.yml: the SSH mount is${SSH_KEY_DIR:-~/.ssh}→/home/app/.ssh:ro. The README explains using a folder with only a deploy key for the rules repository.Deploy steps
docker exec safefamily_app python scripts/migrate.py. The app readsusers.is_approved, so pages error until it has run.id -uon the server isn't 1000, setAPP_UID/APP_GIDin.envbefore rebuilding. If./logswas created by the old root container:sudo chown -R $(id -u):$(id -g) logs.Testing
pytest -q: 485 passed, coverage 89%.ruff check .clean on 0.17.4.tests/test_accounts.py(25 tests):Generated by Claude Code