-
Notifications
You must be signed in to change notification settings - Fork 60
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fixed username validator #239
Conversation
pattern := `^[a-zA-Z0-9]{1,255}$` | ||
re := regexp.MustCompile(pattern) | ||
return re.MatchString(username) | ||
return len(username) >= 1 && len(username) <= 255 && !strings.ContainsAny(username, `,"~#%$`) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, it meets the username validators, but it also satisfy certain requirements outlined in the issue #195.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just to confirm, should I add space trimming and an empty-check to the username validation here to fully meet issue #195 requirements, or handle that separately?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think it would be better to validate and trim spaces in the input fields here.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@JianMinTang @bupd is it fine now?
Signed-off-by: Roaster05 <[email protected]> Signed-off-by: Roaster05 <[email protected]>
Signed-off-by: Roaster05 <[email protected]>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
reverting back as test fail. |
pattern := `^[a-zA-Z0-9]{1,255}$` | ||
re := regexp.MustCompile(pattern) | ||
return re.MatchString(username) | ||
username = strings.TrimSpace(username) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this code may not work as expected. If you enter harbor-cli
with extra spaces, the strings.TrimSpace(username)
doesn't properly store the value in the login.LoginView
variable. Could you please fix this if you still want to continue? @Roaster05
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
.
Signed-off-by: Patrick Eschenbach <[email protected]>
This reverts commit d059ef2. Signed-off-by: Patrick Eschenbach <[email protected]>
The username validator previously implemented only allowed alphanumeric characters, which resulted in rejecting valid usernames accepted by the server, such as
harbor-cli
. This inconsistency also caused failures in login tests.To resolve this, the current implementation of the validator has been aligned with the server's username validation criteria. You can view the server-side validator here.
This PR references issue #234