add missing IDP required check for OTA profiles (#44644)
Found this missed TODO from some old story work. <!-- This is an auto-generated comment: release notes by coderabbit.ai --> ## Summary by CodeRabbit * **Bug Fixes** * Enhanced OTA enrollment profile validation to properly enforce end-user authentication requirements when configured, now returning appropriate error responses for requests missing required authentication credentials. <!-- end of auto-generated comment: release notes by coderabbit.ai -->
This commit is contained in:
@@ -6961,8 +6961,17 @@ func (svc *Service) GetOTAProfile(ctx context.Context, enrollSecret, idpUUID str
|
||||
return nil, ctxerr.Wrap(ctx, err, "getting app config to get org name")
|
||||
}
|
||||
|
||||
// TODO(IB): Validate that the IdpUUID should be populated based on the criteria for showing the SSO in the first place
|
||||
// Should be added with the work of #30660 or afterwars.
|
||||
requiresIDPUUID, err := shared_mdm.RequiresEnrollOTAAuthentication(ctx, svc.ds, enrollSecret, cfg.MDM.MacOSSetup.EnableEndUserAuthentication)
|
||||
if err != nil {
|
||||
return nil, ctxerr.Wrap(ctx, err, "checking if IDP UUID is required for OTA enrollment")
|
||||
}
|
||||
if requiresIDPUUID && idpUUID == "" {
|
||||
return nil, ctxerr.Wrap(
|
||||
ctx,
|
||||
authz.ForbiddenWithInternal("required idp uuid to be set, but none found", nil, nil, nil),
|
||||
"missing required idp uuid",
|
||||
)
|
||||
}
|
||||
|
||||
profBytes, err := apple_mdm.GenerateOTAEnrollmentProfileMobileconfig(cfg.OrgInfo.OrgName, cfg.MDMUrl(), enrollSecret, idpUUID)
|
||||
if err != nil {
|
||||
|
||||
@@ -6410,6 +6410,19 @@ func (s *integrationMDMTestSuite) TestOTAProfile() {
|
||||
require.NotContains(t, string(b), "idp_uuid=")
|
||||
require.Contains(t, string(b), cfg.OrgInfo.OrgName)
|
||||
})
|
||||
|
||||
t.Run("returns 403 if no idp_uuid is set when required by config", func(t *testing.T) {
|
||||
// update config to require idp_uuid
|
||||
cfg.MDM.MacOSSetup.EnableEndUserAuthentication = true
|
||||
err := s.ds.SaveAppConfig(ctx, cfg)
|
||||
require.NoError(t, err)
|
||||
t.Cleanup(func() {
|
||||
cfg.MDM.MacOSSetup.EnableEndUserAuthentication = false
|
||||
err := s.ds.SaveAppConfig(ctx, cfg)
|
||||
require.NoError(t, err)
|
||||
})
|
||||
s.Do("GET", "/api/latest/fleet/enrollment_profiles/ota", &getOTAProfileRequest{}, http.StatusForbidden, "enroll_secret", globalEnrollSec)
|
||||
})
|
||||
}
|
||||
|
||||
// TestAppleDDMSecretVariablesUpload tests uploading DDM profiles with secrets via the /configuration_profiles endpoint
|
||||
|
||||
Reference in New Issue
Block a user