diff --git a/server/service/appconfig.go b/server/service/appconfig.go index 6983887bcf..ca71e3344c 100644 --- a/server/service/appconfig.go +++ b/server/service/appconfig.go @@ -403,7 +403,10 @@ func (svc *Service) ModifyAppConfig(ctx context.Context, p []byte, applyOpts fle } } - if oldAppConfig.MDM.EndUserAuthentication.SSOProviderSettings != appConfig.MDM.EndUserAuthentication.SSOProviderSettings { + mdmSSOSettingsChanged := oldAppConfig.MDM.EndUserAuthentication.SSOProviderSettings != + appConfig.MDM.EndUserAuthentication.SSOProviderSettings + serverURLChanged := oldAppConfig.ServerSettings.ServerURL != appConfig.ServerSettings.ServerURL + if (mdmSSOSettingsChanged || serverURLChanged) && license.Tier == "premium" { if err := svc.EnterpriseOverrides.MDMAppleSyncDEPPRofile(ctx); err != nil { return nil, ctxerr.Wrap(ctx, err, "sync DEP profile") } diff --git a/server/service/integration_mdm_test.go b/server/service/integration_mdm_test.go index cd9615bb23..73d6085dae 100644 --- a/server/service/integration_mdm_test.go +++ b/server/service/integration_mdm_test.go @@ -3791,4 +3791,12 @@ func (s *integrationMDMTestSuite) TestSSO() { } require.NoError(t, plist.Unmarshal(body, &profile)) require.Equal(t, apple_mdm.FleetPayloadIdentifier, profile.PayloadIdentifier) + + // changing the server URL also updates the remote DEP profile + acResp = appConfigResponse{} + s.DoJSON("PATCH", "/api/latest/fleet/config", json.RawMessage(`{ + "server_settings": {"server_url": "https://example.com"} + }`), http.StatusOK, &acResp) + require.Contains(t, lastSubmittedProfile.URL, "https://example.com/api/mdm/apple/enroll?token=") + require.Equal(t, "https://example.com/mdm/sso", lastSubmittedProfile.ConfigurationWebURL) }