RBAC: No need to filter permissions on cache hit (#87941)

This commit is contained in:
Gabriel MABILLE 2024-05-16 09:53:20 +02:00 committed by GitHub
parent 431fdd4bab
commit e7d5622969
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -578,17 +578,10 @@ func (s *Service) searchUserPermissionsFromCache(orgID int64, searchOptions acce
return nil, false
}
s.log.Debug("Using cached permissions", "key", key)
metrics.MAccessSearchUserPermissionsCacheUsage.WithLabelValues(accesscontrol.CacheHit).Inc()
s.log.Debug("Using cached permissions", "key", key)
filteredPermissions := make([]accesscontrol.Permission, 0)
for _, permission := range permissions.([]accesscontrol.Permission) {
if PermissionMatchesSearchOptions(permission, &searchOptions) {
filteredPermissions = append(filteredPermissions, permission)
}
}
return filteredPermissions, true
return permissions.([]accesscontrol.Permission), true
}
func PermissionMatchesSearchOptions(permission accesscontrol.Permission, searchOptions *accesscontrol.SearchOptions) bool {