AccessControl: Add metadata to search result (#48879)
* Add access control metadata to search hits if access control query string is passed
This commit is contained in:
@@ -213,6 +213,20 @@ func GetResourcesMetadata(ctx context.Context, permissions map[string][]string,
|
||||
return result
|
||||
}
|
||||
|
||||
// MergeMeta will merge actions matching prefix of second metadata into first
|
||||
func MergeMeta(prefix string, first Metadata, second Metadata) Metadata {
|
||||
if first == nil {
|
||||
first = Metadata{}
|
||||
}
|
||||
|
||||
for key := range second {
|
||||
if strings.HasPrefix(key, prefix) {
|
||||
first[key] = true
|
||||
}
|
||||
}
|
||||
return first
|
||||
}
|
||||
|
||||
func ManagedUserRoleName(userID int64) string {
|
||||
return fmt.Sprintf("managed:users:%d:permissions", userID)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user