Files
grafana/pkg/registry/apps/logsdrilldown/strategy.go
T
Liza Detrick a112c6c169 Logs Explore: logsdrilldown authorizer permissions, rtkq (#114320)
* Logs Explore: logsdrilldown app platform authorizer permissions, rtkq
---------

Co-authored-by: Austin Pond <austin.pond@grafana.com>
2025-12-02 09:07:36 -08:00

41 lines
803 B
Go

package logsdrilldown
import (
"errors"
"strings"
"github.com/grafana/grafana/pkg/apimachinery/identity"
)
func compareResourceNameAndUserUID(name string, u identity.Requester) bool {
parsedName, err := parseName(name)
if err != nil {
return false
}
// u.GetUID() returns user:<user_uid> so we need to remove the user: prefix
userUID := strings.Split(u.GetUID(), ":")
if len(userUID) != 2 {
return false
}
return parsedName.UID == userUID[1]
}
type storageObjectName struct {
Service string
UID string
}
func parseName(name string) (*storageObjectName, error) {
vals := strings.Split(name, ":")
if len(vals) != 2 {
return nil, errors.New("name must be in the format <service>:<user_uid>")
}
return &storageObjectName{
Service: vals[0],
UID: vals[1],
}, nil
}