mirror of
https://github.com/grafana/grafana.git
synced 2025-02-25 18:55:37 -06:00
Add Auth func overrides
This commit is contained in:
parent
6032ab3ae1
commit
4b73a93883
@ -20,6 +20,7 @@ type legacyServer struct {
|
|||||||
acSvc accesscontrol.Service
|
acSvc accesscontrol.Service
|
||||||
logger log.Logger
|
logger log.Logger
|
||||||
tracer tracing.Tracer
|
tracer tracing.Tracer
|
||||||
|
cfg *Cfg
|
||||||
}
|
}
|
||||||
|
|
||||||
func newLegacyServer(
|
func newLegacyServer(
|
||||||
@ -34,6 +35,7 @@ func newLegacyServer(
|
|||||||
acSvc: acSvc,
|
acSvc: acSvc,
|
||||||
logger: log.New("authz-grpc-server"),
|
logger: log.New("authz-grpc-server"),
|
||||||
tracer: tracer,
|
tracer: tracer,
|
||||||
|
cfg: cfg,
|
||||||
}
|
}
|
||||||
|
|
||||||
if cfg.listen {
|
if cfg.listen {
|
||||||
@ -43,12 +45,26 @@ func newLegacyServer(
|
|||||||
return s, nil
|
return s, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// AuthFuncOverride
|
// AuthFuncOverride is a function that allows to override the default auth function.
|
||||||
// FIXME(drclau): make sure we only run this when app_mode = development
|
// This override is only allowed in development mode as we skip all authentication checks.
|
||||||
func (s *legacyServer) AuthFuncOverride(ctx context.Context, _ string) (context.Context, error) {
|
func (s *legacyServer) AuthFuncOverride(ctx context.Context, _ string) (context.Context, error) {
|
||||||
|
if !s.cfg.allowInsecure {
|
||||||
|
s.logger.Error("AuthFuncOverride is not allowed in production mode")
|
||||||
|
return nil, tracing.Errorf(nil, "AuthFuncOverride is not allowed in production mode")
|
||||||
|
}
|
||||||
return ctx, nil
|
return ctx, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// AuthorizeFuncOverride is a function that allows to override the default authorize function that checks the namespace of the caller.
|
||||||
|
// We skip all authorization checks in development mode. Once we have access tokens, we need to do namespace validation in the Read handler.
|
||||||
|
func (s *legacyServer) AuthorizeFuncOverride(ctx context.Context) error {
|
||||||
|
if !s.cfg.allowInsecure {
|
||||||
|
s.logger.Error("AuthorizeFuncOverride is not allowed in production mode")
|
||||||
|
return tracing.Errorf(nil, "AuthorizeFuncOverride is not allowed in production mode")
|
||||||
|
}
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
func (s *legacyServer) Read(ctx context.Context, req *authzv1.ReadRequest) (*authzv1.ReadResponse, error) {
|
func (s *legacyServer) Read(ctx context.Context, req *authzv1.ReadRequest) (*authzv1.ReadResponse, error) {
|
||||||
ctx, span := s.tracer.Start(ctx, "authz.grpc.Read")
|
ctx, span := s.tracer.Start(ctx, "authz.grpc.Read")
|
||||||
defer span.End()
|
defer span.End()
|
||||||
|
Loading…
Reference in New Issue
Block a user