Skip to content

fixed-username-checks - #5503

Merged
ispeakc0de merged 21 commits into
litmuschaos:masterfrom
yashgoyal0110:fix/username-checks-fixes
Jul 7, 2026
Merged

fixed-username-checks#5503
ispeakc0de merged 21 commits into
litmuschaos:masterfrom
yashgoyal0110:fix/username-checks-fixes

Conversation

@yashgoyal0110

@yashgoyal0110 yashgoyal0110 commented May 6, 2026

Copy link
Copy Markdown
Contributor

Proposed changes

Fixes #5413

The auth API's username validator (ValidateStrictUsername) enforced ^[a-zA-Z][a-zA-Z0-9_-]{2,15}$ — i.e., 3–16 chars, alphanumerics + _- only, must start with a letter. This made it impossible to pre-create a user whose username is their email address (e.g. john.smith.long@example.com), which is required to correlate Dex SSO logins with pre-created accounts. Dex sets Username = claims.Email in dex_auth_handler.go#L127, so any email longer than 16 characters or containing @/. was rejected by /create_user with 401 username_policy_violation.

Files touched

  • chaoscenter/authentication/pkg/utils/sanitizers.go
  • chaoscenter/authentication/pkg/utils/errors.go
  • chaoscenter/authentication/api/handlers/doc.go
  • chaoscenter/web/src/constants/validation.ts
  • chaoscenter/web/src/strings/strings.en.yaml
  • chaoscenter/web/src/views/CreateNewUser/CreateNewUser.tsx

Types of changes

  • Bugfix (non-breaking change which fixes an issue)

Checklist

  • I have read the CONTRIBUTING doc
  • I have signed the commit for DCO to be passed.
  • Lint and unit tests pass locally with my changes
  • I have added tests that prove my fix is effective or that my feature works (if appropriate)
  • I have added necessary documentation (if appropriate)

Signed-off-by: yashgoyal0110 <yg364550@gmail.com>
@yashgoyal0110
yashgoyal0110 force-pushed the fix/username-checks-fixes branch from bf6b909 to 56aa882 Compare May 6, 2026 18:20
Signed-off-by: yashgoyal0110 <yg364550@gmail.com>
Signed-off-by: yashgoyal0110 <yg364550@gmail.com>
Signed-off-by: yashgoyal0110 <yg364550@gmail.com>
Signed-off-by: yashgoyal0110 <yg364550@gmail.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

This PR relaxes username validation so pre-created users can use email-style usernames for Dex SSO correlation.

Changes:

  • Expands backend and frontend username validation from 3–16 chars to 3–254 chars.
  • Allows digits as the first character and permits . _ - @ + in usernames.
  • Updates user-facing validation/error text and API documentation examples.

Reviewed changes

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

Show a summary per file
File Description
chaoscenter/authentication/pkg/utils/sanitizers.go Updates strict username regex and validator error text.
chaoscenter/authentication/pkg/utils/errors.go Updates username policy violation description.
chaoscenter/authentication/api/handlers/doc.go Updates API documentation example for username validation errors.
chaoscenter/web/src/constants/validation.ts Updates frontend username regex.
chaoscenter/web/src/views/CreateNewUser/CreateNewUser.tsx Raises UI username max length to 254.
chaoscenter/web/src/strings/strings.en.yaml Updates username validation copy and reformats related strings.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread chaoscenter/authentication/pkg/utils/sanitizers.go Outdated
Comment thread chaoscenter/web/src/views/CreateNewUser/CreateNewUser.tsx
Comment thread chaoscenter/authentication/api/handlers/doc.go Outdated
Comment thread chaoscenter/authentication/pkg/utils/errors.go Outdated
Comment thread chaoscenter/authentication/api/handlers/doc.go Outdated
Comment thread chaoscenter/authentication/pkg/utils/sanitizers.go Outdated
@PriteshKiri

Copy link
Copy Markdown
Contributor

@yashgoyal0110 could you please review the comments by co-pilot?

@yashgoyal0110

Copy link
Copy Markdown
Contributor Author

@yashgoyal0110 could you please review the comments by co-pilot?

@PriteshKiri
fixed!

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 6 out of 6 changed files in this pull request and generated no new comments.

@PriteshKiri

Copy link
Copy Markdown
Contributor

@yashgoyal0110, could you please fix the CI check in a different PR and link it here?

@yashgoyal0110

Copy link
Copy Markdown
Contributor Author

Sure

@yashgoyal0110, could you please fix the CI check in a different PR and link it here?

Sure @PriteshKiri

@PriteshKiri

Copy link
Copy Markdown
Contributor

@yashgoyal0110, could you please ping me on the Kubernetes Slack workspace once the PR for the Trivy fix is up? Just in case I miss the GitHub notification.

@yashgoyal0110

Copy link
Copy Markdown
Contributor Author

@yashgoyal0110, could you please ping me on the Kubernetes Slack workspace once the PR for the Trivy fix is up? Just in case I miss the GitHub notification.

Ok, I will

@yashgoyal0110

Copy link
Copy Markdown
Contributor Author

@PriteshKiri
is CI causing issue again? it successfully passed for 463386a

@PriteshKiri

Copy link
Copy Markdown
Contributor

Hey @yashgoyal0110
Could you please make a different PR for the CI failure?

@yashgoyal0110

Copy link
Copy Markdown
Contributor Author

Hey @yashgoyal0110 Could you please make a different PR for the CI failure?

sure!

@yashgoyal0110
yashgoyal0110 force-pushed the fix/username-checks-fixes branch from e8d2acf to 987fc86 Compare July 4, 2026 17:40
Signed-off-by: yashgoyal0110 <yg364550@gmail.com>
Signed-off-by: yashgoyal0110 <yg364550@gmail.com>
@yashgoyal0110
yashgoyal0110 force-pushed the fix/username-checks-fixes branch from 987fc86 to 73b4873 Compare July 4, 2026 18:47
@ispeakc0de
ispeakc0de merged commit c5a4d97 into litmuschaos:master Jul 7, 2026
20 checks passed
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.

Cannot Use Email as Username Due to 16-Character Limit in User Creation API

4 participants