feat: username policy — length cap, substring blocklist, reserved words - #144
Merged
Conversation
The username rules had no maximum length (the client capped at 30, the
server accepted anything), and the forbidden list was exact-match only, so
"saltybytesadmin" and "adm1n" both sailed through.
- Cap usernames at 30 characters, matching the existing client rule in
register_screen.dart so old app builds stay in step.
- Split the blocklist in two: forbiddenSubstrings for distinctive terms that
may not appear anywhere (brand, owner handles, admin, moderator), and
forbiddenExact for reserved words too common to match as substrings.
Matching "test" or "user" anywhere would reject "sweetestchef" and
"validuser123", so those stay exact-only.
- Fold leetspeak digits before matching, so "4dm1n" and "s4l7ybyte5" are
caught as "admin" and "saltybytes".
- Broaden the reserved words: roles, auth surface, infra/mail, support,
billing and tier names, product routes, placeholders. Dropped the entries
that can never match ("test_user", "saltybytes-admin") — non-alphanumeric
names are rejected before the list is consulted.
- Run the local rules before the uniqueness check, so a junk username no
longer costs a database round trip, and build the profanity detector once
instead of per signup.
"julian" and "yana" remain deliberately available.
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_0194PdH4wDTnz5SWfzyoKagc
|
You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard. |
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.
What
Usernames had no maximum length on the server (the client caps at 30, the API accepted a 5,000-character name), and the forbidden list was exact-match only — so
saltybytesadmin,admin1andadm1nall sailed straight through.Changes
register_screen.dart— no app change needed, and builds already in App Review stay in step.forbiddenSubstringsholds distinctive terms that may not appear anywhere (brand, owner handles,admin,moderator);forbiddenExactholds reserved words that are only a problem when they are the whole name. A blanket "contains" check is the obvious move here and it's wrong: matchingtestanywhere rejectssweetestchefandthegreatest, anduserrejectsvaliduser123— which is an existing passing test.4dm1n→adminands4l7ybyte5→saltybytes.unlimitedtier), product routes, placeholders. Dropped entries that can never match (test_user,saltybytes-admin) — non-alphanumeric names are rejected before the list is consulted.julianandyanaremain deliberately available.Verification
go test ./... -count=1green. New table tests cover the length bounds, leetspeak evasion, and the near-miss names that a naive substring match would eat. Spot-checked verdicts on ~50 realistic names:testkitchen,sweetestchef,grassroots,unofficialchef,arsenalsupporter,validuser123,homecook,julian,yanaadmin,sysadmin,administrator,4dm1n,saltybytes,thesaltybytesguy,saltybytesadmin,s4l7ybyte5,r00t,windoze95,russianminx,moderatorNote
Signup is the only place a username is set (
PUT /users/meonly updates first name and email), so this one gate covers it. Existing accounts are unaffected — the rules run at creation only.🤖 Generated with Claude Code
https://claude.ai/code/session_0194PdH4wDTnz5SWfzyoKagc