Skip to content

fix: enforce 12-char minimum for admin password on Setup page#59

Merged
andregoepel merged 1 commit into
mainfrom
bugfix/setup-admin-password-policy
Jul 4, 2026
Merged

fix: enforce 12-char minimum for admin password on Setup page#59
andregoepel merged 1 commit into
mainfrom
bugfix/setup-admin-password-policy

Conversation

@andregoepel

Copy link
Copy Markdown
Owner

Closes #56 (F7 — weak password floor for the root administrator).

What

Setup.razor (the initial admin-creation page) advertised and client-validated a 6-character password minimum. Meanwhile AndreGoepel.Marten.Identity already enforces options.Password.RequiredLength = 12 server-side, so a 6–11 char password passed local validation only to be rejected by UserManager.CreateAsync.

This change surfaces the real policy on the page:

  • Inject IOptions<IdentityOptions> and add MinPasswordLength => IdentityOptions.Value.Password.RequiredLength.
  • Drive RadzenLengthValidator from Min="@MinPasswordLength" with dynamic text (so an integrator override of the policy is reflected in the UI).
  • Raise the InputModel.Password data-annotation floor from 6 to 12.

Why

The most privileged account in the system (root, non-deletable Administrator) could be attempted with a weak password, and the mismatch between client (6) and server (12) produced a confusing rejection. Aligning the page with the enforced policy fixes both.

Pattern

Mirrors the existing convention in marten-identity (ResetPassword.razor, SetPassword.razor, ChangePassword.razor): a static MinimumLength = 12 data-annotation floor plus a RadzenLengthValidator bound to Password.RequiredLength.

Verification

  • dotnet build -c Release — 0 errors.
  • dotnet test -c Release — 54/54 passing.
  • csharpier formatted; single-file change (line-ending churn on unrelated files was reverted).

Reviewer notes

  • One file changed: src/AndreGoepel.AppFoundation/Components/Pages/Setup.razor (+6 / -2).
  • Server-side enforcement is unchanged (it lives in the identity package); this is the UI/validation alignment.

The Setup page advertised and client-validated a 6-character minimum,
while AndreGoepel.Marten.Identity already enforces RequiredLength = 12
server-side. The form passed local validation only to be rejected by
UserManager.CreateAsync.

Surface the real policy: inject IOptions<IdentityOptions>, drive the
RadzenLengthValidator from Password.RequiredLength (reflecting any
integrator override), and raise the InputModel floor to 12 — mirroring
the pattern used by the identity Blazor pages (ResetPassword, etc.).

Closes #56
@andregoepel
andregoepel merged commit 6b2bc9a into main Jul 4, 2026
3 checks passed
@andregoepel
andregoepel deleted the bugfix/setup-admin-password-policy branch July 5, 2026 07:31
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Security] Weak password floor for the root administrator (F7)

1 participant