automatically update the remote DEP profile when the server URL changes (#11423)

#11414
This commit is contained in:
Roberto Dip 2023-04-28 15:26:38 -03:00 committed by GitHub
parent bd372346ed
commit 5029ed5daf
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 12 additions and 1 deletions

View file

@ -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")
}

View file

@ -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)
}