Unverified Commit bbded584 authored by George Wu's avatar George Wu Committed by GitHub

fix: user resource names can be uuidv4 from idp sub claim (#5856)

parent f8a304ba
......@@ -3,5 +3,5 @@ package base
import "regexp"
var (
UIDMatcher = regexp.MustCompile("^[a-zA-Z0-9]([a-zA-Z0-9-]{0,30}[a-zA-Z0-9])?$")
UIDMatcher = regexp.MustCompile("^[a-zA-Z0-9]([a-zA-Z0-9-]{0,34}[a-zA-Z0-9])?$")
)
......@@ -22,6 +22,8 @@ func TestUIDMatcher(t *testing.T) {
{"a1234567890123456789012345678901", true},
{"abc123", true},
{"abc123-", false},
{"123e4567-e89b-12d3-a456-426614174000", true}, // UUID v4 from IDP
{"a123456789012345678901234567890123456", false}, // 37 characters (too long)
}
for _, test := range tests {
......
......@@ -143,7 +143,7 @@ func ValidateAndGenerateUID(provided string) (string, error) {
return shortuuid.New(), nil
}
if !base.UIDMatcher.MatchString(uid) {
return "", status.Errorf(codes.InvalidArgument, "invalid ID format: must be 1-32 characters, alphanumeric and hyphens only, cannot start or end with hyphen")
return "", status.Errorf(codes.InvalidArgument, "invalid ID format: must be 1-36 characters, alphanumeric and hyphens only, cannot start or end with hyphen")
}
return uid, nil
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment