mirror of
https://github.com/grafana/grafana.git
synced 2025-02-25 18:55:37 -06:00
Direct DB perm checks: check that the namespaces match (#97828)
check that the namespace of the caller matches the namespace in the request
This commit is contained in:
parent
f710573b37
commit
32554c78a8
@ -78,10 +78,17 @@ func (s *Service) validateRequest(ctx context.Context, req *authzv1.CheckRequest
|
||||
if req.GetNamespace() == "" {
|
||||
return nil, status.Error(codes.InvalidArgument, "namespace is required")
|
||||
}
|
||||
namespace := req.GetNamespace()
|
||||
ns, err := claims.ParseNamespace(namespace)
|
||||
authInfo, has := claims.From(ctx)
|
||||
if !has {
|
||||
return nil, status.Error(codes.Internal, "could not get auth info from context")
|
||||
}
|
||||
if !claims.NamespaceMatches(authInfo.GetNamespace(), req.GetNamespace()) {
|
||||
return nil, status.Error(codes.PermissionDenied, "namespace does not match")
|
||||
}
|
||||
|
||||
ns, err := claims.ParseNamespace(req.GetNamespace())
|
||||
if err != nil {
|
||||
ctxLogger.Error("could not parse namespace", "namespace", namespace, "error", err)
|
||||
ctxLogger.Error("could not parse namespace", "namespace", req.GetNamespace(), "error", err)
|
||||
return nil, err
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user