Skip to content

feat: the consumer username supports hyphens - #7825

Description

@AlinsRan

Background

Ref: apache/apisix-ingress-controller#2379

At apisix-ingress-controller, We want to isolate resources through k8s namespace, for example, construct such a name namespace_username to differentiate consumers.
K8s namespace supports hyphens -, but APISIX consumer username does not support https://github.com/apache/apisix/blob/master/apisix/schema_def.lua#L700.

$ url http://127.0.0.1:9080/apisix/admin/consumers \
 -H 'X-API-KEY: edd1c9f034335f136f87ad84b625c8f1' -X PUT -d '
 {
     "username": "namespace-1_jack",
     "plugins": {
         "key-auth": {
             "key": "auth-one"
         }
     }
}'
# response
{"error_msg":"invalid configuration: property \"username\" validation failed: failed to match pattern \"^[a-zA-Z0-9_]+$\" with \"namespace-1_jack\""}

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    Status
    ✅ Done

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions