mirror of https://github.com/grafana/grafana
Object store: get user from context (#56346)
* GRPC Server: Add signedInUser to context after auth * add permissions to signedInUser * add access control permissions test * add additional signedInUser checks * get user from context * move `UserFromContext` to object/auth.go Co-authored-by: Todd Treece <todd.treece@grafana.com>pull/56419/head^2
parent
4a14d75086
commit
a94acb7f61
@ -0,0 +1,26 @@ |
||||
package object |
||||
|
||||
import ( |
||||
"context" |
||||
|
||||
"github.com/grafana/grafana/pkg/models" |
||||
"github.com/grafana/grafana/pkg/services/contexthandler/ctxkey" |
||||
grpccontext "github.com/grafana/grafana/pkg/services/grpcserver/context" |
||||
"github.com/grafana/grafana/pkg/services/user" |
||||
) |
||||
|
||||
// UserFromContext ** Experimental **
|
||||
// TODO: move to global infra package / new auth service
|
||||
func UserFromContext(ctx context.Context) *user.SignedInUser { |
||||
grpcCtx := grpccontext.FromContext(ctx) |
||||
if grpcCtx != nil { |
||||
return grpcCtx.SignedInUser |
||||
} |
||||
|
||||
c, ok := ctxkey.Get(ctx).(*models.ReqContext) |
||||
if !ok || c == nil || c.SignedInUser == nil { |
||||
return nil |
||||
} |
||||
|
||||
return c.SignedInUser |
||||
} |
Loading…
Reference in new issue