Skip to content

Commit 3c96967

Browse files
getvictormna
authored andcommitted
Okta conditional access configs (#34566)
<!-- Add the related story/sub-task/bug number, like Resolves #123, or remove if NA --> **Related issue:** Resolves #34533 This is the first sub-task out of several. Changes file will be added in a subsequent PR. # Checklist for submitter If some of the following don't apply, delete the relevant line. - [x] Input data is properly validated, `SELECT *` is avoided, SQL injection is prevented (using placeholders for values in statements) ## Testing - [x] Added/updated automated tests - [x] QA'd all new/changed functionality manually ## New Fleet configuration settings - [x] Setting(s) is/are explicitly **excluded** from GitOps <!-- This is an auto-generated comment: release notes by coderabbit.ai --> ## Summary by CodeRabbit * **New Features** * Added Okta Conditional Access support (IDP, ACS URL, audience, certificate) and exposed conditional access in AppConfig/API * App activity logging for adding/removing Okta conditional access * **Bug Fixes** * Fixed typo in conditional access validation messaging * **Tests** * Added tests for Okta Conditional Access lifecycle, license gating, and GitOps export exclusion * **Documentation** * Added audit-log entries for Okta conditional access add/delete <!-- end of auto-generated comment: release notes by coderabbit.ai -->
1 parent 6e869c0 commit 3c96967

20 files changed

+585
-34
lines changed

cmd/fleetctl/fleetctl/generate_gitops_test.go

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ import (
1717
"github.com/fleetdm/fleet/v4/server/ptr"
1818
"github.com/ghodss/yaml"
1919
"github.com/google/uuid"
20+
"github.com/stretchr/testify/assert"
2021
"github.com/stretchr/testify/require"
2122
"github.com/urfave/cli/v2"
2223
)
@@ -758,6 +759,56 @@ func TestGeneratedOrgSettingsNoSSO(t *testing.T) {
758759
require.NoError(t, err)
759760
}
760761

762+
func TestGeneratedOrgSettingsOktaConditionalAccessNotIncluded(t *testing.T) {
763+
// Get the test app config.
764+
fleetClient := &MockClient{}
765+
appConfig, err := fleetClient.GetAppConfig()
766+
require.NoError(t, err)
767+
768+
// Set Okta conditional access fields (these should NOT appear in GitOps output)
769+
appConfig.ConditionalAccess = &fleet.ConditionalAccessSettings{
770+
MicrosoftEntraTenantID: "test-tenant-id",
771+
MicrosoftEntraConnectionConfigured: true,
772+
OktaIDPID: optjson.SetString("https://okta.example.com/idp"),
773+
OktaAssertionConsumerServiceURL: optjson.SetString("https://okta.example.com/acs"),
774+
OktaAudienceURI: optjson.SetString("https://okta.example.com/audience"),
775+
OktaCertificate: optjson.SetString("-----BEGIN CERTIFICATE-----\ntest\n-----END CERTIFICATE-----"),
776+
}
777+
778+
// Create the command.
779+
cmd := &GenerateGitopsCommand{
780+
Client: fleetClient,
781+
CLI: cli.NewContext(&cli.App{}, nil, nil),
782+
Messages: Messages{},
783+
FilesToWrite: make(map[string]interface{}),
784+
AppConfig: appConfig,
785+
}
786+
787+
// Generate the org settings.
788+
orgSettingsRaw, err := cmd.generateOrgSettings()
789+
require.NoError(t, err)
790+
require.NotNil(t, orgSettingsRaw)
791+
var orgSettings map[string]any
792+
b, err := yaml.Marshal(orgSettingsRaw)
793+
require.NoError(t, err)
794+
err = yaml.Unmarshal(b, &orgSettings)
795+
require.NoError(t, err)
796+
797+
// Verify that conditional_access section does not exist in the output
798+
// (Okta configs are not supported in GitOps)
799+
_, hasConditionalAccess := orgSettings["conditional_access"]
800+
assert.False(t, hasConditionalAccess, "conditional_access section should not be present in GitOps output as Okta configs are not supported")
801+
802+
// Also verify by checking the YAML string directly
803+
yamlStr := string(b)
804+
assert.NotContains(t, yamlStr, "okta_idp_id", "Okta IDP ID should not be in GitOps output")
805+
assert.NotContains(t, yamlStr, "okta_assertion_consumer_service_url", "Okta ACS URL should not be in GitOps output")
806+
assert.NotContains(t, yamlStr, "okta_audience_uri", "Okta Audience URI should not be in GitOps output")
807+
assert.NotContains(t, yamlStr, "okta_certificate", "Okta Certificate should not be in GitOps output")
808+
assert.NotContains(t, yamlStr, "microsoft_entra_tenant_id", "Microsoft Entra Tenant ID should not be in GitOps output")
809+
assert.NotContains(t, yamlStr, "microsoft_entra_connection_configured", "Microsoft Entra connection status should not be in GitOps output")
810+
}
811+
761812
func TestGenerateOrgSettingsInsecure(t *testing.T) {
762813
// Get the test app config.
763814
fleetClient := &MockClient{}

cmd/fleetctl/fleetctl/testdata/expectedGetConfigAppConfigJson.json

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,14 @@
4141
"activity_expiry_enabled": false,
4242
"activity_expiry_window": 0
4343
},
44+
"conditional_access": {
45+
"microsoft_entra_tenant_id": "",
46+
"microsoft_entra_connection_configured": false,
47+
"okta_idp_id": null,
48+
"okta_assertion_consumer_service_url": null,
49+
"okta_audience_uri": null,
50+
"okta_certificate": null
51+
},
4452
"features": {
4553
"enable_host_users": true,
4654
"enable_software_inventory": false

cmd/fleetctl/fleetctl/testdata/expectedGetConfigAppConfigTeamMaintainerJson.json

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,14 @@
2626
"activity_expiry_enabled": false,
2727
"activity_expiry_window": 0
2828
},
29+
"conditional_access": {
30+
"microsoft_entra_tenant_id": "",
31+
"microsoft_entra_connection_configured": false,
32+
"okta_idp_id": null,
33+
"okta_assertion_consumer_service_url": null,
34+
"okta_audience_uri": null,
35+
"okta_certificate": null
36+
},
2937
"features": {
3038
"enable_host_users": true,
3139
"enable_software_inventory": false

cmd/fleetctl/fleetctl/testdata/expectedGetConfigAppConfigTeamMaintainerYaml.yml

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,13 @@ spec:
1010
activity_expiry_settings:
1111
activity_expiry_enabled: false
1212
activity_expiry_window: 0
13+
conditional_access:
14+
microsoft_entra_tenant_id: ""
15+
microsoft_entra_connection_configured: false
16+
okta_idp_id: null
17+
okta_assertion_consumer_service_url: null
18+
okta_audience_uri: null
19+
okta_certificate: null
1320
features:
1421
enable_host_users: true
1522
enable_software_inventory: false

cmd/fleetctl/fleetctl/testdata/expectedGetConfigAppConfigYaml.yml

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,13 @@ spec:
1010
activity_expiry_settings:
1111
activity_expiry_enabled: false
1212
activity_expiry_window: 0
13+
conditional_access:
14+
microsoft_entra_tenant_id: ""
15+
microsoft_entra_connection_configured: false
16+
okta_idp_id: null
17+
okta_assertion_consumer_service_url: null
18+
okta_audience_uri: null
19+
okta_certificate: null
1320
features:
1421
enable_host_users: true
1522
enable_software_inventory: false

cmd/fleetctl/fleetctl/testdata/expectedGetConfigIncludeServerConfigJson.json

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,14 @@
4141
"activity_expiry_enabled": false,
4242
"activity_expiry_window": 0
4343
},
44+
"conditional_access": {
45+
"microsoft_entra_tenant_id": "",
46+
"microsoft_entra_connection_configured": false,
47+
"okta_idp_id": null,
48+
"okta_assertion_consumer_service_url": null,
49+
"okta_audience_uri": null,
50+
"okta_certificate": null
51+
},
4452
"features": {
4553
"enable_host_users": true,
4654
"enable_software_inventory": false

cmd/fleetctl/fleetctl/testdata/expectedGetConfigIncludeServerConfigYaml.yml

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,13 @@ spec:
1010
activity_expiry_settings:
1111
activity_expiry_enabled: false
1212
activity_expiry_window: 0
13+
conditional_access:
14+
microsoft_entra_tenant_id: ""
15+
microsoft_entra_connection_configured: false
16+
okta_idp_id: null
17+
okta_assertion_consumer_service_url: null
18+
okta_audience_uri: null
19+
okta_certificate: null
1320
features:
1421
enable_host_users: true
1522
enable_software_inventory: false

cmd/fleetctl/fleetctl/testdata/macosSetupExpectedAppConfigEmpty.yml

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,13 @@ spec:
1313
activity_expiry_settings:
1414
activity_expiry_enabled: false
1515
activity_expiry_window: 0
16+
conditional_access:
17+
microsoft_entra_tenant_id: ""
18+
microsoft_entra_connection_configured: false
19+
okta_idp_id: null
20+
okta_assertion_consumer_service_url: null
21+
okta_audience_uri: null
22+
okta_certificate: null
1623
integrations:
1724
conditional_access_enabled: null
1825
google_calendar: null

cmd/fleetctl/fleetctl/testdata/macosSetupExpectedAppConfigSet.yml

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,13 @@ spec:
1313
activity_expiry_settings:
1414
activity_expiry_enabled: false
1515
activity_expiry_window: 0
16+
conditional_access:
17+
microsoft_entra_tenant_id: ""
18+
microsoft_entra_connection_configured: false
19+
okta_idp_id: null
20+
okta_assertion_consumer_service_url: null
21+
okta_audience_uri: null
22+
okta_certificate: null
1623
integrations:
1724
conditional_access_enabled: null
1825
google_calendar: null

docs/Contributing/reference/audit-logs.md

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2068,6 +2068,18 @@ Generated when Microsoft Entra is integration is disconnected.
20682068

20692069
This activity does not contain any detail fields.
20702070

2071+
## added_conditional_access_okta
2072+
2073+
Generated when Okta is configured or edited for conditional access.
2074+
2075+
This activity does not contain any detail fields.
2076+
2077+
## deleted_conditional_access_okta
2078+
2079+
Generated when Okta conditional access configuration is removed.
2080+
2081+
This activity does not contain any detail fields.
2082+
20712083
## enabled_conditional_access_automations
20722084

20732085
Generated when conditional access automations are enabled for a team.

0 commit comments

Comments
 (0)