GRPC Server: Add signedInUser to context (#56059)

This commit is contained in:
Todd Treece
2022-10-04 16:31:02 -04:00
committed by GitHub
parent ba97b268d0
commit 4163f31d76
6 changed files with 182 additions and 29 deletions
@@ -0,0 +1,25 @@
package grpccontext
import (
"context"
"github.com/grafana/grafana/pkg/infra/log"
"github.com/grafana/grafana/pkg/infra/tracing"
"github.com/grafana/grafana/pkg/services/user"
)
type grpcContextKey struct{}
type GRPCServerContext struct {
SignedInUser *user.SignedInUser
Tracer tracing.Tracer
Logger log.Logger
}
func FromContext(ctx context.Context) *GRPCServerContext {
grpcContext, ok := ctx.Value(grpcContextKey{}).(*GRPCServerContext)
if !ok {
return nil
}
return grpcContext
}