@@ -92,7 +92,7 @@ func CheckACLPermission(ctx context.Context, path string, requiredPerm int32) (*
9292
9393 for _ , rule := range allRules {
9494 // Check if rule applies to any of the user's roles
95- if ! containsRole (userRoles , rule .Role ) {
95+ if ! containsRole (userRoles , rule .Role , rule . IsRegex ) {
9696 continue
9797 }
9898
@@ -125,6 +125,7 @@ func CheckACLPermission(ctx context.Context, path string, requiredPerm int32) (*
125125 ruleInfo := & errs.ACLRuleInfo {
126126 RulePath : matchedRule .Path ,
127127 Role : matchedRule .Role ,
128+ IsRegex : matchedRule .IsRegex ,
128129 Permissions : getPermissionNames (matchedRule .Permissions ),
129130 Priority : matchedRule .Priority ,
130131 }
@@ -180,7 +181,7 @@ func GetMatchedACLRule(ctx context.Context, path string) (*model.ACLMatchedRule,
180181 normalizedPath := normalizePath (path )
181182
182183 for _ , rule := range allRules {
183- if ! containsRole (userRoles , rule .Role ) {
184+ if ! containsRole (userRoles , rule .Role , rule . IsRegex ) {
184185 continue
185186 }
186187
@@ -227,10 +228,19 @@ func getUserRoles(user *model.User) []string {
227228 return roles
228229}
229230
230- func containsRole (roles []string , role string ) bool {
231+ func containsRole (roles []string , role string , isRegex bool ) bool {
231232 if role == "*" {
232233 return true
233234 }
235+ if isRegex {
236+ for _ , r := range roles {
237+ matched , err := utils .RegexMatch (role , r )
238+ if err == nil && matched {
239+ return true
240+ }
241+ }
242+ return false
243+ }
234244 return slices .Contains (roles , role )
235245}
236246
0 commit comments