Skip to content

Allow null on UserOptions.AllowedUserNameCharacters#67731

Open
justindbaur wants to merge 3 commits into
dotnet:mainfrom
justindbaur:resolve-64078
Open

Allow null on UserOptions.AllowedUserNameCharacters#67731
justindbaur wants to merge 3 commits into
dotnet:mainfrom
justindbaur:resolve-64078

Conversation

@justindbaur

@justindbaur justindbaur commented Jul 10, 2026

Copy link
Copy Markdown
Contributor

Allow null on UserOptions.AllowedUserNameCharacters

  • You've read the Contributor Guide and Code of Conduct.
  • You've included unit or integration tests for your change, where applicable.
  • You've included inline docs for your change, where applicable.
  • There's an open issue for the PR that you are making. If you'd like to propose a new feature or change, please open an issue to discuss the change or find an existing issue.

Allow null on UserOptions.AllowedUserNameCharacters to denote that all characters are allowed in a user name.

Description

There are already tests validating that when null is set to this option that non-alphanumeric characters are allowed in user names. This just makes it clear from the type system that null is allowed here and has a meaning.

manager.Options.User.AllowedUserNameCharacters = null;

Fixes #64078

Copilot AI review requested due to automatic review settings July 10, 2026 13:32
@dotnet-policy-service dotnet-policy-service Bot added the community-contribution Indicates that the PR has been added by a community member label Jul 10, 2026
@dotnet-policy-service

Copy link
Copy Markdown
Contributor

Thanks for your PR, @justindbaur. Someone from the team will get assigned to your PR shortly and we'll get it reviewed.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

This PR updates ASP.NET Core Identity’s UserOptions.AllowedUserNameCharacters to explicitly allow null (via nullable reference types) to represent “no character restrictions,” aligning the API contract with existing runtime behavior.

Changes:

  • Update UserOptions.AllowedUserNameCharacters from string to string?.
  • Add XML documentation clarifying the meaning of null for the option.

Comment thread src/Identity/Extensions.Core/src/UserOptions.cs
/// The list of allowed characters in the username used to validate user names.
/// </value>
public string AllowedUserNameCharacters { get; set; } = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789-._@+";
public string? AllowedUserNameCharacters { get; set; } = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789-._@+";
justindbaur and others added 2 commits July 10, 2026 09:41
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 3 out of 3 changed files in this pull request and generated 2 comments.

Microsoft.AspNetCore.Identity.UserManager<TUser>.ValidateUserAsync(TUser! user) -> System.Threading.Tasks.Task<Microsoft.AspNetCore.Identity.IdentityResult!>!
Microsoft.AspNetCore.Identity.UserOptions
Microsoft.AspNetCore.Identity.UserOptions.AllowedUserNameCharacters.get -> string!
Microsoft.AspNetCore.Identity.UserOptions.AllowedUserNameCharacters.set -> void
Comment on lines 1 to 4
#nullable enable
Microsoft.AspNetCore.Identity.UserOptions.AllowedUserNameCharacters.get -> string?
Microsoft.AspNetCore.Identity.UserPasskeyInfo.Aaguid.get -> byte[]?
Microsoft.AspNetCore.Identity.UserPasskeyInfo.Aaguid.set -> void
@@ -1,3 +1,4 @@
#nullable enable
Microsoft.AspNetCore.Identity.UserOptions.AllowedUserNameCharacters.get -> string?

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Thanks for doing this! I think the correct syntax for modifying the nullability of an existing member is this:

Suggested change
Microsoft.AspNetCore.Identity.UserOptions.AllowedUserNameCharacters.get -> string?
*REMOVED*Microsoft.AspNetCore.Identity.UserOptions.AllowedUserNameCharacters.get -> string!
Microsoft.AspNetCore.Identity.UserOptions.AllowedUserNameCharacters.get -> string?

Then you can undo the changes is PublicAPI.Shipped.txt.

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

Labels

community-contribution Indicates that the PR has been added by a community member

Projects

None yet

Development

Successfully merging this pull request may close these issues.

UserOptions.AllowedUserNameCharacters should be marked as allowing null.

3 participants