goharbor / harbor-cli

[Sandbox] Official Harbor CLI
Apache License 2.0
41 stars 45 forks source link

The test username does not meet the username requirements #234

Closed JianMinTang closed 3 days ago

JianMinTang commented 3 weeks ago

the user requirements:

image

the ValidateUserName funtion

image

the username for testing:

image

We need to standardize these validation requirements, eg harbor-cli can't work on this ValidationUserName function. @Vad1mo @bupd

Roaster05 commented 2 weeks ago

Hey @JianMinTang @Vad1mo @bupd,

I would like to work on this issue. I am thinking of adding the following symbols to the username validation pattern:

Additionally, I propose enforcing a rule that disallows consecutive symbols in usernames. Valid usernames will start and end with alphanumeric characters and may have symbols in between, ensuring that patterns like abc--bacd are rejected, while formats like xyz.symbol.abc are accepted.

Vad1mo commented 2 weeks ago

Hey @JianMinTang @Vad1mo @bupd,

I would like to work on this issue. I am thinking of adding the following symbols to the username validation pattern:

  • Period (.): Allows separation of words for better readability and supports email-like usernames.

  • Underscore (_): Widely used to enhance clarity and readability without introducing ambiguity.

  • Hyphen (-): Links multiple words, improving visual structure while maintaining compatibility with URLs and CLI.

Additionally, I propose enforcing a rule that disallows consecutive symbols in usernames. Valid usernames will start and end with alphanumeric characters and may have symbols in between, ensuring that patterns like abc--bacd are rejected, while formats like xyz.symbol.abc are accepted.

The rules on the CLI should simply match with the rules on Harbor Server side.

Roaster05 commented 2 weeks ago

Hey @JianMinTang @Vad1mo @bupd, I would like to work on this issue. I am thinking of adding the following symbols to the username validation pattern:

  • Period (.): Allows separation of words for better readability and supports email-like usernames.
  • Underscore (_): Widely used to enhance clarity and readability without introducing ambiguity.
  • Hyphen (-): Links multiple words, improving visual structure while maintaining compatibility with URLs and CLI.

Additionally, I propose enforcing a rule that disallows consecutive symbols in usernames. Valid usernames will start and end with alphanumeric characters and may have symbols in between, ensuring that patterns like abc--bacd are rejected, while formats like xyz.symbol.abc are accepted.

The rules on the CLI should simply match with the rules on Harbor Server side.

To align with this, the current server-side username validation logic uses a function to detect illegal characters. You can check the relevant code here. It references an illegal character list in the constants file here. We can implement a similar validation function to ensure consistency across the CLI and server.

Vad1mo commented 2 weeks ago

Exactly

Roaster05 commented 2 weeks ago

@Vad1mo I have submitted a PR to address this issue. Could you please take a look at it? Thank you!