mirror of
https://github.com/grafana/grafana.git
synced 2024-11-26 02:40:26 -06:00
Update pkg/services/authn/grpcutils/grpc_authenticator.go
Co-authored-by: Gabriel MABILLE <gamab@users.noreply.github.com>
This commit is contained in:
parent
562d499e85
commit
b5209dba64
@ -93,18 +93,14 @@ func NewGrpcAuthenticatorWithFallback(cfg *setting.Cfg, reg prometheus.Registere
|
||||
}
|
||||
|
||||
func (f *AuthenticatorWithFallback) Authenticate(ctx context.Context) (context.Context, error) {
|
||||
origCtx := ctx
|
||||
// Try to authenticate with the new authenticator first
|
||||
ctx, err := f.authenticator.Authenticate(ctx)
|
||||
if err == nil {
|
||||
// If successful, return the context
|
||||
return ctx, nil
|
||||
} else if f.fallbackEnabled {
|
||||
// If the new authenticator failed and the fallback is enabled, try the legacy authenticator
|
||||
ctx, err = f.legacyAuthenticator.Authenticate(origCtx)
|
||||
newCtx, err := f.authenticator.Authenticate(ctx)
|
||||
// If allowed fallback to the legacy authenticator
|
||||
if err != nil && f.fallbackEnabled {
|
||||
newCtx, err = f.legacyAuthenticator.Authenticate(ctx)
|
||||
f.metrics.fallbackCounter.WithLabelValues(fmt.Sprintf("%t", err == nil)).Inc()
|
||||
}
|
||||
return ctx, err
|
||||
return newCtx, err
|
||||
}
|
||||
|
||||
const (
|
||||
|
Loading…
Reference in New Issue
Block a user