Repository navigation
fix(user): allow email-length usernames and passwords up to 72 characters - #2120
Conversation
…ters User names were capped at 20 characters, so an OIDC identifier that is an email address or UPN could never match a local user. Passwords were capped at 20 too, which blocks password-manager passwords. Raise the name limit to 255 (same as the install API) and the password limit to 72, the bcrypt input limit. The change-password endpoint had no limit, so longer passwords failed inside bcrypt with a 500; it now uses the same limit. Closes #2119
0xJacky
left a comment
There was a problem hiding this comment.
Thanks — a clean, root-cause fix with thorough coverage. What we verified:
TestManageUserAcceptsEmailLengthNameAndLongPasswordfails ondevwith406 {"name":"max=20","password":"required,max=20"}and passes with your change.- Full backend suite (
-race -count=1) on this PR merged intodevshows no new failures versusdev(the only failures, ininternal/plugin/capability, are a pre-existing macOS unix-socket-path limitation and are unrelated). bun run lint,typecheck, andbuildall pass; all 16.pofiles plusmessages.potkeep their translations with the number updated.
One non-blocking note: max=72 counts characters, while bcrypt's limit is 72 bytes, so a password of 72 multi-byte characters could still exceed it. The common (ASCII) case is exactly right, so this is fine to merge as-is; we can tighten it later if needed.
There was a problem hiding this comment.
Thanks for the thorough fix and the regression test. Confirmed the root cause: model/user.go capped Name/Password at 20, which blocked OIDC email/UPN usernames (#2119) and password-manager passwords. The approach is right — Name to 255 (fits RFC 5321's 254-char address) and Password to 72 (bcrypt's input limit).
Verified against dev: the new TestManageUserAcceptsEmailLengthNameAndLongPassword fails on the old code (HTTP 406, max=20) and passes with your change; the full backend suite, go vet, gofmt, and the frontend lint/typecheck/build are all clean. Name has no DB column-size or index constraint, so 255 is safe, and the .po edits match the new source string.
This is already merged to dev as 5135a11 — thanks again for the fix and the regression test.
Problem
Closes #2119.
User names were capped at 20 characters (
model/user.go). OIDC signs a user in only when the identifier claim equals an existing user name, and that claim is usually an email address or a UPN (preferred_usernameon Entra ID). So an admin could not create a user namedfirst.lastname@corp.example.onmicrosoft.com, and that person could never log in through OIDC.Passwords were capped at 20 characters too (user add/modify and the install form), which blocks generated passwords from password managers.
Steps to reproduce:
POST /api/userswith{"name":"first.lastname@corp.example.onmicrosoft.com","password":"password","status":true}.{"name":"max=20"}.Fix
model/user.go:Namemax 20 → 255 (the install API already allows a 255-character username).Passwordmax 20 → 72.api/system/install.go, install form: password max 20 → 72.api/user/current_user.go: the change-password endpoint had no max at all, so a long new password reached bcrypt and failed with a 500. It now has the same max of 72.72 is the bcrypt input limit:
bcrypt.GenerateFromPasswordreturnsErrPasswordTooLongpast 72 bytes, so the API now refuses those up front with a validation error instead.Also:
messages.potand every.pofile and changed the number in each existing translation (and the noun form in ru/uk), so no language loses its string.docs/guide/config-oidc.mdsaid usernames are limited to 20 characters; it now says up to 255.I left out the optional case-insensitive OIDC match from the issue. It changes who can log in, so it seems better as its own change.
Tests
New
TestManageUserAcceptsEmailLengthNameAndLongPasswordinapi/user/security_test.go:On
devthe test fails with406 {"name":"max=20","password":"required,max=20"}; with this change it passes.GOWORK=off go test -tags=unembed -count=1 ./...passes locally (and-raceonapi/user,api/system,model).