Auth: remove id token flag (#92209)
This commit is contained in:
@@ -18,7 +18,6 @@ import (
|
||||
"github.com/grafana/grafana/pkg/services/apiserver/endpoints/request"
|
||||
"github.com/grafana/grafana/pkg/services/auth"
|
||||
"github.com/grafana/grafana/pkg/services/authn"
|
||||
"github.com/grafana/grafana/pkg/services/featuremgmt"
|
||||
"github.com/grafana/grafana/pkg/setting"
|
||||
)
|
||||
|
||||
@@ -31,8 +30,9 @@ const (
|
||||
var _ auth.IDService = (*Service)(nil)
|
||||
|
||||
func ProvideService(
|
||||
cfg *setting.Cfg, signer auth.IDSigner, cache remotecache.CacheStorage,
|
||||
features featuremgmt.FeatureToggles, authnService authn.Service,
|
||||
cfg *setting.Cfg, signer auth.IDSigner,
|
||||
cache remotecache.CacheStorage,
|
||||
authnService authn.Service,
|
||||
reg prometheus.Registerer,
|
||||
) *Service {
|
||||
s := &Service{
|
||||
@@ -42,9 +42,7 @@ func ProvideService(
|
||||
nsMapper: request.GetNamespaceMapper(cfg),
|
||||
}
|
||||
|
||||
if features.IsEnabledGlobally(featuremgmt.FlagIdForwarding) {
|
||||
authnService.RegisterPostAuthHook(s.hook, 140)
|
||||
}
|
||||
authnService.RegisterPostAuthHook(s.hook, 140)
|
||||
|
||||
return s
|
||||
}
|
||||
|
||||
@@ -15,15 +15,12 @@ import (
|
||||
"github.com/grafana/grafana/pkg/services/auth/idtest"
|
||||
"github.com/grafana/grafana/pkg/services/authn"
|
||||
"github.com/grafana/grafana/pkg/services/authn/authntest"
|
||||
"github.com/grafana/grafana/pkg/services/featuremgmt"
|
||||
"github.com/grafana/grafana/pkg/services/login"
|
||||
"github.com/grafana/grafana/pkg/setting"
|
||||
)
|
||||
|
||||
func Test_ProvideService(t *testing.T) {
|
||||
t.Run("should register post auth hook when feature flag is enabled", func(t *testing.T) {
|
||||
features := featuremgmt.WithFeatures(featuremgmt.FlagIdForwarding)
|
||||
|
||||
t.Run("should register post auth hook", func(t *testing.T) {
|
||||
var hookRegistered bool
|
||||
authnService := &authntest.MockService{
|
||||
RegisterPostAuthHookFunc: func(_ authn.PostAuthHookFn, _ uint) {
|
||||
@@ -31,23 +28,9 @@ func Test_ProvideService(t *testing.T) {
|
||||
},
|
||||
}
|
||||
|
||||
_ = ProvideService(setting.NewCfg(), nil, nil, features, authnService, nil)
|
||||
_ = ProvideService(setting.NewCfg(), nil, nil, authnService, nil)
|
||||
assert.True(t, hookRegistered)
|
||||
})
|
||||
|
||||
t.Run("should not register post auth hook when feature flag is disabled", func(t *testing.T) {
|
||||
features := featuremgmt.WithFeatures()
|
||||
|
||||
var hookRegistered bool
|
||||
authnService := &authntest.MockService{
|
||||
RegisterPostAuthHookFunc: func(_ authn.PostAuthHookFn, _ uint) {
|
||||
hookRegistered = true
|
||||
},
|
||||
}
|
||||
|
||||
_ = ProvideService(setting.NewCfg(), nil, nil, features, authnService, nil)
|
||||
assert.False(t, hookRegistered)
|
||||
})
|
||||
}
|
||||
|
||||
func TestService_SignIdentity(t *testing.T) {
|
||||
@@ -67,7 +50,6 @@ func TestService_SignIdentity(t *testing.T) {
|
||||
t.Run("should sign identity", func(t *testing.T) {
|
||||
s := ProvideService(
|
||||
setting.NewCfg(), signer, remotecache.NewFakeCacheStorage(),
|
||||
featuremgmt.WithFeatures(featuremgmt.FlagIdForwarding),
|
||||
&authntest.FakeService{}, nil,
|
||||
)
|
||||
token, _, err := s.SignIdentity(context.Background(), &authn.Identity{ID: "1", Type: claims.TypeUser})
|
||||
@@ -78,7 +60,6 @@ func TestService_SignIdentity(t *testing.T) {
|
||||
t.Run("should sign identity with authenticated by if user is externally authenticated", func(t *testing.T) {
|
||||
s := ProvideService(
|
||||
setting.NewCfg(), signer, remotecache.NewFakeCacheStorage(),
|
||||
featuremgmt.WithFeatures(featuremgmt.FlagIdForwarding),
|
||||
&authntest.FakeService{}, nil,
|
||||
)
|
||||
token, _, err := s.SignIdentity(context.Background(), &authn.Identity{
|
||||
@@ -104,7 +85,6 @@ func TestService_SignIdentity(t *testing.T) {
|
||||
t.Run("should sign identity with authenticated by if user is externally authenticated", func(t *testing.T) {
|
||||
s := ProvideService(
|
||||
setting.NewCfg(), signer, remotecache.NewFakeCacheStorage(),
|
||||
featuremgmt.WithFeatures(featuremgmt.FlagIdForwarding),
|
||||
&authntest.FakeService{}, nil,
|
||||
)
|
||||
_, gotClaims, err := s.SignIdentity(context.Background(), &authn.Identity{
|
||||
|
||||
@@ -28,10 +28,6 @@ type LocalSigner struct {
|
||||
}
|
||||
|
||||
func (s *LocalSigner) SignIDToken(ctx context.Context, claims *auth.IDClaims) (string, error) {
|
||||
if !s.features.IsEnabled(ctx, featuremgmt.FlagIdForwarding) {
|
||||
return "", nil
|
||||
}
|
||||
|
||||
signer, err := s.getSigner(ctx)
|
||||
if err != nil {
|
||||
return "", err
|
||||
|
||||
Reference in New Issue
Block a user