Skip to content

fix(user): allow email-length usernames and passwords up to 72 characters - #2120

Merged
0xJacky merged 1 commit into
0xJacky:devfrom
bardrop-oss:fix/oidc-username-length
Nov 15, 2026
Merged

0xJacky merged 1 commit into
0xJacky:devfrom
bardrop-oss:fix/oidc-username-length

Conversation

@bardrop

@bardrop bardrop commented Nov 13, 2026

Copy link
Copy Markdown
Contributor

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_username on Entra ID). So an admin could not create a user named first.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:

  1. POST /api/users with {"name":"first.lastname@corp.example.onmicrosoft.com","password":"password","status":true}.
  2. Expected: user created. Actual: 406 {"name":"max=20"}.

Fix

  • model/user.go: Name max 20 → 255 (the install API already allows a 255-character username). Password max 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.GenerateFromPassword returns ErrPasswordTooLong past 72 bytes, so the API now refuses those up front with a validation error instead.

Also:

  • i18n: the install form message changed from "20 characters" to "72 characters". I updated the msgid in messages.pot and every .po file 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.md said 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 TestManageUserAcceptsEmailLengthNameAndLongPassword in api/user/security_test.go:

  • creates a user with a 43-character email name and a 72-character password, checks the stored bcrypt hash matches, then renames it to another long email with another 72-character password;
  • a 73-character password is refused and no user is stored.

On dev the test fails with 406 {"name":"max=20","password":"required,max=20"}; with this change it passes.

GOWORK=off go test -tags=unembed -count=1 ./... passes locally (and -race on api/user, api/system, model).

…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 0xJacky added go Pull requests that update Go code javascript Pull requests that update Javascript code labels Nov 14, 2026

@0xJacky 0xJacky left a comment

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks — a clean, root-cause fix with thorough coverage. What we verified:

  • TestManageUserAcceptsEmailLengthNameAndLongPassword fails on dev with 406 {"name":"max=20","password":"required,max=20"} and passes with your change.
  • Full backend suite (-race -count=1) on this PR merged into dev shows no new failures versus dev (the only failures, in internal/plugin/capability, are a pre-existing macOS unix-socket-path limitation and are unrelated).
  • bun run lint, typecheck, and build all pass; all 16 .po files plus messages.pot keep 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.

@0xJacky 0xJacky left a comment •

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

go Pull requests that update Go code javascript Pull requests that update Javascript code

Projects

None yet

Development

Successfully merging this pull request may close these issues.

OIDC: 20-character username limit blocks email/UPN identifiers (Entra ID)

2 participants