-
Notifications
You must be signed in to change notification settings - Fork 207
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #714 from okta/app_signon_policy_rule
Added new 'okta_app_signon_policy' and 'okta_app_sign_on_policy_rule' resources
- Loading branch information
Showing
21 changed files
with
1,136 additions
and
32 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
resource "okta_app_saml" "test" { | ||
label = "testAcc_replace_with_uuid" | ||
sso_url = "http://google.com" | ||
recipient = "http://here.com" | ||
destination = "http://its-about-the-journey.com" | ||
audience = "http://audience.com" | ||
subject_name_id_template = "$${user.userName}" | ||
subject_name_id_format = "urn:oasis:names:tc:SAML:1.1:nameid-format:emailAddress" | ||
response_signed = true | ||
signature_algorithm = "RSA_SHA256" | ||
digest_algorithm = "SHA256" | ||
honor_force_authn = false | ||
authn_context_class_ref = "urn:oasis:names:tc:SAML:2.0:ac:classes:PasswordProtectedTransport" | ||
single_logout_issuer = "https://dunshire.okta.com" | ||
single_logout_url = "https://dunshire.okta.com/logout" | ||
single_logout_certificate = "MIIFnDCCA4QCCQDBSLbiON2T1zANBgkqhkiG9w0BAQsFADCBjzELMAkGA1UEBhMCVVMxDjAMBgNV\r\nBAgMBU1haW5lMRAwDgYDVQQHDAdDYXJpYm91MRcwFQYDVQQKDA5Tbm93bWFrZXJzIEluYzEUMBIG\r\nA1UECwwLRW5naW5lZXJpbmcxDTALBgNVBAMMBFNub3cxIDAeBgkqhkiG9w0BCQEWEWVtYWlsQGV4\r\nYW1wbGUuY29tMB4XDTIwMTIwMzIyNDY0M1oXDTMwMTIwMTIyNDY0M1owgY8xCzAJBgNVBAYTAlVT\r\nMQ4wDAYDVQQIDAVNYWluZTEQMA4GA1UEBwwHQ2FyaWJvdTEXMBUGA1UECgwOU25vd21ha2Vycy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CK3yRry+aWtppc58P81KYabUlCfFXfhJ9E\r\nP72ffN4jVHpX3lxxYh7FKAdiKbY2FYzjsc7RdgKI1R3iAAZUCGBTvezNzaetGzTUjjl/g1tcVYij\r\nltH9ZOQBPlUMI88lxUxqgRTerpPmAJH00CACx4JFiZrweLM1trZyy06wNDQgLrqHr3EOagBF/O2h\r\nhfTehNdVr6iq3YhKWBo4/+RL0RCzHMh4u86VbDDnDn4Y6HzLuyIAtBFoikoKM6UHTOa0Pqv2bBr5\r\nwbkRkVUxl9yJJw/HmTCdfnsM9dTOJUKzEglnGF2184Gg+qJDZB6fSf0EAO1F6sTqiSswl+uHQZiy\r\nDaZzyU7Gg5seKOZ20zTRaX3Ihj9Zij/ORnrARE7eM/usKMECp+7syUwAUKxDCZkGiUdskmOhhBGL\r\nJtbyK3F2UvoJoLsm3pIcvMak9KwMjSTGJB47ABUP1+w+zGcNk0D5Co3IJ6QekiLfWJyQ+kKsWLKt\r\nzOYQQatrnBagM7MI2/T4\r\n" | ||
|
||
attribute_statements { | ||
type = "GROUP" | ||
name = "groups" | ||
filter_type = "REGEX" | ||
filter_value = ".*" | ||
} | ||
} | ||
|
||
data "okta_app_signon_policy" "test" { | ||
app_id = okta_app_saml.test.id | ||
} | ||
|
||
resource "okta_app_signon_policy_rule" "test" { | ||
policy_id = data.okta_app_signon_policy.test.id | ||
name = "testAcc_replace_with_uuid" | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,143 @@ | ||
resource "okta_app_saml" "test" { | ||
label = "testAcc_replace_with_uuid" | ||
sso_url = "http://google.com" | ||
recipient = "http://here.com" | ||
destination = "http://its-about-the-journey.com" | ||
audience = "http://audience.com" | ||
subject_name_id_template = "$${user.userName}" | ||
subject_name_id_format = "urn:oasis:names:tc:SAML:1.1:nameid-format:emailAddress" | ||
response_signed = true | ||
signature_algorithm = "RSA_SHA256" | ||
digest_algorithm = "SHA256" | ||
honor_force_authn = false | ||
authn_context_class_ref = "urn:oasis:names:tc:SAML:2.0:ac:classes:PasswordProtectedTransport" | ||
single_logout_issuer = "https://dunshire.okta.com" | ||
single_logout_url = "https://dunshire.okta.com/logout" | ||
single_logout_certificate = "MIIFnDCCA4QCCQDBSLbiON2T1zANBgkqhkiG9w0BAQsFADCBjzELMAkGA1UEBhMCVVMxDjAMBgNV\r\nBAgMBU1haW5lMRAwDgYDVQQHDAdDYXJpYm91MRcwFQYDVQQKDA5Tbm93bWFrZXJzIEluYzEUMBIG\r\nA1UECwwLRW5naW5lZXJpbmcxDTALBgNVBAMMBFNub3cxIDAeBgkqhkiG9w0BCQEWEWVtYWlsQGV4\r\nYW1wbGUuY29tMB4XDTIwMTIwMzIyNDY0M1oXDTMwMTIwMTIyNDY0M1owgY8xCzAJBgNVBAYTAlVT\r\nMQ4wDAYDVQQIDAVNYWluZTEQMA4GA1UEBwwHQ2FyaWJvdTEXMBUGA1UECgwOU25vd21ha2VycyBJ\r\nbmMxFDASBgNVBAsMC0VuZ2luZWVyaW5nMQ0wCwYDVQQDDARTbm93MSAwHgYJKoZIhvcNAQkBFhFl\r\nbWFpbEBleGFtcGxlLmNvbTCCAiIwDQYJKoZIhvcNAQEBBQADggIPADCCAgoCggIBANMmWDjXPdoa\r\nPyzIENqeY9njLan2FqCbQPSestWUUcb6NhDsJVGSQ7XR+ozQA5TaJzbP7cAJUj8vCcbqMZsgOQAu\r\nO/pzYyQEKptLmrGvPn7xkJ1A1xLkp2NY18cpDTeUPueJUoidZ9EJwEuyUZIktzxNNU1pA1lGijiu\r\n2XNxs9d9JR/hm3tCu9Im8qLVB4JtX80YUa6QtlRjWR/H8a373AYCOASdoB3c57fIPD8ATDNy2w/c\r\nfCVGiyKDMFB+GA/WTsZpOP3iohRp8ltAncSuzypcztb2iE+jijtTsiC9kUA2abAJqqpoCJubNShi\r\nVff4822czpziS44MV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6QekiLfWJyQ+kKsWLKt\r\nzOYQQatrnBagM7MI2/T4\r\n" | ||
|
||
attribute_statements { | ||
type = "GROUP" | ||
name = "groups" | ||
filter_type = "REGEX" | ||
filter_value = ".*" | ||
} | ||
} | ||
|
||
data "okta_app_signon_policy" "test" { | ||
app_id = okta_app_saml.test.id | ||
} | ||
|
||
resource "okta_user" "test" { | ||
count = 5 | ||
first_name = "TestAcc" | ||
last_name = "Smith" | ||
login = "testAcc_${count.index}@example.com" | ||
email = "testAcc_${count.index}@example.com" | ||
} | ||
|
||
resource "okta_group" "this" { | ||
count = 5 | ||
name = "testAcc_${count.index}" | ||
description = "testAcc_${count.index}" | ||
} | ||
|
||
resource "okta_user_type" "test" { | ||
name = "testAcc_replace_with_uuid" | ||
display_name = "Terraform Acceptance Test User Type Updated" | ||
description = "Terraform Acceptance Test User Type Updated" | ||
} | ||
|
||
resource "okta_network_zone" "test" { | ||
name = "testAcc_replace_with_uuid" | ||
type = "IP" | ||
gateways = ["1.2.3.4/24", "2.3.4.5-2.3.4.15"] | ||
proxies = ["2.2.3.4/24", "3.3.4.5-3.3.4.15"] | ||
} | ||
|
||
data "okta_user_type" "default" { | ||
name = "user" | ||
} | ||
|
||
resource "okta_app_signon_policy_rule" "test" { | ||
name = "testAcc_replace_with_uuid" | ||
policy_id = data.okta_app_signon_policy.test.id | ||
access = "ALLOW" | ||
custom_expression = "user.status == \"ACTIVE\"" | ||
device_is_managed = false | ||
device_is_registered = true | ||
factor_mode = "2FA" | ||
groups_excluded = [ | ||
okta_group.this[2].id, | ||
okta_group.this[3].id, | ||
okta_group.this[4].id | ||
] | ||
groups_included = [ | ||
okta_group.this[0].id, | ||
okta_group.this[1].id | ||
] | ||
inactivity_re_authentication_frequency = "PT10H" | ||
network_connection = "ZONE" | ||
network_includes = [ | ||
okta_network_zone.test.id | ||
] | ||
platform_include { | ||
os_type = "ANDROID" | ||
type = "MOBILE" | ||
} | ||
platform_include { | ||
os_type = "IOS" | ||
type = "MOBILE" | ||
} | ||
platform_include { | ||
os_type = "MACOS" | ||
type = "DESKTOP" | ||
} | ||
platform_include { | ||
os_type = "OTHER" | ||
type = "DESKTOP" | ||
} | ||
platform_include { | ||
os_type = "OTHER" | ||
type = "MOBILE" | ||
} | ||
platform_include { | ||
os_type = "WINDOWS" | ||
type = "DESKTOP" | ||
} | ||
priority = 98 | ||
re_authentication_frequency = "PT43800H" | ||
type = "ASSURANCE" | ||
user_types_excluded = [ | ||
okta_user_type.test.id | ||
] | ||
user_types_included = [ | ||
data.okta_user_type.default.id | ||
] | ||
users_excluded = [ | ||
okta_user.test[2].id, | ||
okta_user.test[3].id, | ||
okta_user.test[4].id | ||
] | ||
users_included = [ | ||
okta_user.test[0].id, | ||
okta_user.test[1].id | ||
] | ||
constraints = [ | ||
jsonencode({ | ||
"knowledge" : { | ||
"reauthenticateIn" : "PT2H", | ||
"types" : ["password"] | ||
}, | ||
"possession" : { | ||
"deviceBound" : "REQUIRED" | ||
} | ||
}), | ||
jsonencode({ | ||
"possession" : { | ||
"deviceBound" : "REQUIRED", | ||
"hardwareProtection" : "REQUIRED", | ||
"userPresence" : "OPTIONAL" | ||
} | ||
}) | ||
] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
package okta | ||
|
||
import ( | ||
"context" | ||
"path" | ||
|
||
"github.com/hashicorp/terraform-plugin-sdk/v2/diag" | ||
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" | ||
"github.com/okta/okta-sdk-golang/v2/okta" | ||
) | ||
|
||
func dataSourceAppSignOnPolicy() *schema.Resource { | ||
return &schema.Resource{ | ||
ReadContext: dataSourceAppSignOnPolicyRead, | ||
Schema: map[string]*schema.Schema{ | ||
"app_id": { | ||
Type: schema.TypeString, | ||
Required: true, | ||
Description: "App ID", | ||
}, | ||
"name": { | ||
Type: schema.TypeString, | ||
Computed: true, | ||
Description: "Policy name", | ||
}, | ||
}, | ||
} | ||
} | ||
|
||
func dataSourceAppSignOnPolicyRead(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics { | ||
app := okta.NewApplication() | ||
_, _, err := getOktaClientFromMetadata(m).Application.GetApplication(ctx, d.Get("app_id").(string), app, nil) | ||
if err != nil { | ||
return diag.Errorf("failed get app by ID: %v", err) | ||
} | ||
accessPolicy := linksValue(app.Links, "accessPolicy", "href") | ||
if accessPolicy == "" { | ||
return diag.Errorf("app does not support sign-on policy or this feature is not available") | ||
} | ||
policy, _, err := getOktaClientFromMetadata(m).Policy.GetPolicy(ctx, path.Base(accessPolicy), nil) | ||
if err != nil { | ||
return diag.Errorf("failed get policy by ID: %v", err) | ||
} | ||
d.SetId(policy.Id) | ||
_ = d.Set("name", policy.Name) | ||
return nil | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.