AuthN: Support reloading SSO config after the sso settings have changed (#80734)
* Add AuthNSvc reload handling * Working, need to add test * Remove commented out code * Add Reload implementation to connectors * Align and add tests, refactor * Add more tests, linting * Add extra checks + tests to oauth client * Clean up based on reviews * Move config instantiation into newSocialBase * Use specific error
This commit is contained in:
@@ -84,7 +84,7 @@ func (s *SSOSettingsStore) List(ctx context.Context) ([]*models.SSOSettings, err
|
||||
return result, nil
|
||||
}
|
||||
|
||||
func (s *SSOSettingsStore) Upsert(ctx context.Context, settings models.SSOSettings) error {
|
||||
func (s *SSOSettingsStore) Upsert(ctx context.Context, settings *models.SSOSettings) error {
|
||||
if settings.Provider == "" {
|
||||
return ssosettings.ErrNotFound
|
||||
}
|
||||
@@ -110,13 +110,10 @@ func (s *SSOSettingsStore) Upsert(ctx context.Context, settings models.SSOSettin
|
||||
}
|
||||
_, err = sess.UseBool(isDeletedColumn).Update(updated, existing)
|
||||
} else {
|
||||
_, err = sess.Insert(&models.SSOSettings{
|
||||
ID: uuid.New().String(),
|
||||
Provider: settings.Provider,
|
||||
Settings: settings.Settings,
|
||||
Created: now,
|
||||
Updated: now,
|
||||
})
|
||||
settings.ID = uuid.New().String()
|
||||
settings.Created = now
|
||||
settings.Updated = now
|
||||
_, err = sess.Insert(settings)
|
||||
}
|
||||
|
||||
return err
|
||||
|
||||
@@ -105,7 +105,7 @@ func TestIntegrationUpsertSSOSettings(t *testing.T) {
|
||||
},
|
||||
}
|
||||
|
||||
err := ssoSettingsStore.Upsert(context.Background(), settings)
|
||||
err := ssoSettingsStore.Upsert(context.Background(), &settings)
|
||||
require.NoError(t, err)
|
||||
|
||||
actual, err := getSSOSettingsByProvider(sqlStore, settings.Provider, false)
|
||||
@@ -143,7 +143,7 @@ func TestIntegrationUpsertSSOSettings(t *testing.T) {
|
||||
"client_secret": "this-is-a-new-secret",
|
||||
},
|
||||
}
|
||||
err = ssoSettingsStore.Upsert(context.Background(), newSettings)
|
||||
err = ssoSettingsStore.Upsert(context.Background(), &newSettings)
|
||||
require.NoError(t, err)
|
||||
|
||||
actual, err := getSSOSettingsByProvider(sqlStore, provider, false)
|
||||
@@ -181,7 +181,7 @@ func TestIntegrationUpsertSSOSettings(t *testing.T) {
|
||||
},
|
||||
}
|
||||
|
||||
err = ssoSettingsStore.Upsert(context.Background(), newSettings)
|
||||
err = ssoSettingsStore.Upsert(context.Background(), &newSettings)
|
||||
require.NoError(t, err)
|
||||
|
||||
actual, err := getSSOSettingsByProvider(sqlStore, provider, false)
|
||||
@@ -217,7 +217,7 @@ func TestIntegrationUpsertSSOSettings(t *testing.T) {
|
||||
"client_secret": "this-is-my-new-secret",
|
||||
},
|
||||
}
|
||||
err = ssoSettingsStore.Upsert(context.Background(), newSettings)
|
||||
err = ssoSettingsStore.Upsert(context.Background(), &newSettings)
|
||||
require.NoError(t, err)
|
||||
|
||||
actual, err := getSSOSettingsByProvider(sqlStore, providers[0], false)
|
||||
@@ -254,7 +254,7 @@ func TestIntegrationUpsertSSOSettings(t *testing.T) {
|
||||
},
|
||||
}
|
||||
|
||||
err = ssoSettingsStore.Upsert(context.Background(), settings)
|
||||
err = ssoSettingsStore.Upsert(context.Background(), &settings)
|
||||
require.Error(t, err)
|
||||
require.ErrorIs(t, err, ssosettings.ErrNotFound)
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user