Skip to content

Commit

Permalink
Add twoFactorOneTimeCodeIdTimeToLiveInSeconds (#235)
Browse files Browse the repository at this point in the history
* feat(resource_fusionauth_tenant): add two_factor_one_time_code_id_time_to_live_in_seconds

* chore(resource_fusionauth_tenant): fmt

* fix(resource_fusionauth_tenant): make two_factor_one_time_code_id_time_to_live_in_seconds optional

* docs(resource_fusionauth_tenant): spelling
  • Loading branch information
Akeboshiwind authored Oct 4, 2023
1 parent c858ef7 commit a7af842
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 9 deletions.
6 changes: 4 additions & 2 deletions docs/resources/tenant.md
Original file line number Diff line number Diff line change
Expand Up @@ -328,7 +328,8 @@ resource "fusionauth_tenant" "example" {
length = 6
type = "randomDigits"
}
two_factor_trust_id_time_to_live_in_seconds = 2592000
two_factor_one_time_code_id_time_to_live_in_seconds = 60
two_factor_trust_id_time_to_live_in_seconds = 2592000
}
failed_authentication_configuration {
action_duration = 3
Expand Down Expand Up @@ -526,7 +527,8 @@ resource "fusionauth_tenant" "example" {
- `two_factor_id_time_to_live_in_seconds` - (Required) The time in seconds until a two factor Id is no longer valid and cannot be used by the Two Factor Login API. Value must be greater than 0.
- `trust_token_time_to_live_in_seconds` - (Optional) The number of seconds before the Trust Token is no longer valid to complete a request that requires trust. Value must be greater than 0.
- `pending_account_link_time_to_live_in_seconds` - (Optional) The number of seconds before the pending account link identifier is no longer valid to complete an account link request. Value must be greater than 0.
- `two_factor_trust_id_time_to_live_in_seconds` - (Require) The time in seconds until an issued Two Factor trust Id is no longer valid and the User will be required to complete Two Factor authentication during the next authentication attempt. Value must be greater than 0.
- `two_factor_one_time_code_id_time_to_live_in_seconds` - (Optional) The number of seconds before the Two-Factor One Time Code used to enable or disable a two-factor method is no longer valid. Must be greater than 0.
- `two_factor_trust_id_time_to_live_in_seconds` - (Required) The time in seconds until an issued Two Factor trust Id is no longer valid and the User will be required to complete Two Factor authentication during the next authentication attempt. Value must be greater than 0.
- `two_factor_one_time_code_id_generator` - (Required)
- `length` - (Required) TThe length of the secure generator used for generating the the two factor code Id.
- `type` - (Optional) The type of the secure generator used for generating the two factor one time code Id.
Expand Down
6 changes: 6 additions & 0 deletions fusionauth/resource_fusionauth_tenant.go
Original file line number Diff line number Diff line change
Expand Up @@ -1220,6 +1220,12 @@ func newExternalIdentifierConfiguration() *schema.Resource {
ValidateFunc: validation.IntAtLeast(1),
Description: "The time in seconds until a two factor Id is no longer valid and cannot be used by the Two Factor Login API. Value must be greater than 0.",
},
"two_factor_one_time_code_id_time_to_live_in_seconds": {
Type: schema.TypeInt,
Optional: true,
ValidateFunc: validation.IntAtLeast(1),
Description: "The number of seconds before the Two-Factor One Time Code used to enable or disable a two-factor method is no longer valid. Must be greater than 0.",
},
"two_factor_trust_id_time_to_live_in_seconds": {
Type: schema.TypeInt,
Required: true,
Expand Down
14 changes: 9 additions & 5 deletions fusionauth/resource_fusionauth_tenant_helpers.go
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,9 @@ func buildTenant(data *schema.ResourceData) (fusionauth.Tenant, diag.Diagnostics
TwoFactorIdTimeToLiveInSeconds: data.Get(
"external_identifier_configuration.0.two_factor_id_time_to_live_in_seconds",
).(int),
TwoFactorOneTimeCodeIdTimeToLiveInSeconds: data.Get(
"external_identifier_configuration.0.two_factor_one_time_code_id_time_to_live_in_seconds",
).(int),
TwoFactorTrustIdTimeToLiveInSeconds: data.Get(
"external_identifier_configuration.0.two_factor_trust_id_time_to_live_in_seconds",
).(int),
Expand Down Expand Up @@ -499,11 +502,12 @@ func buildResourceDataFromTenant(t fusionauth.Tenant, data *schema.ResourceData)
"length": t.ExternalIdentifierConfiguration.SetupPasswordIdGenerator.Length,
"type": t.ExternalIdentifierConfiguration.SetupPasswordIdGenerator.Type,
}},
"setup_password_id_time_to_live_in_seconds": t.ExternalIdentifierConfiguration.SetupPasswordIdTimeToLiveInSeconds,
"trust_token_time_to_live_in_seconds": t.ExternalIdentifierConfiguration.TrustTokenTimeToLiveInSeconds,
"pending_account_link_time_to_live_in_seconds": t.ExternalIdentifierConfiguration.PendingAccountLinkTimeToLiveInSeconds,
"two_factor_id_time_to_live_in_seconds": t.ExternalIdentifierConfiguration.TwoFactorIdTimeToLiveInSeconds,
"two_factor_trust_id_time_to_live_in_seconds": t.ExternalIdentifierConfiguration.TwoFactorTrustIdTimeToLiveInSeconds,
"setup_password_id_time_to_live_in_seconds": t.ExternalIdentifierConfiguration.SetupPasswordIdTimeToLiveInSeconds,
"trust_token_time_to_live_in_seconds": t.ExternalIdentifierConfiguration.TrustTokenTimeToLiveInSeconds,
"pending_account_link_time_to_live_in_seconds": t.ExternalIdentifierConfiguration.PendingAccountLinkTimeToLiveInSeconds,
"two_factor_id_time_to_live_in_seconds": t.ExternalIdentifierConfiguration.TwoFactorIdTimeToLiveInSeconds,
"two_factor_one_time_code_id_time_to_live_in_seconds": t.ExternalIdentifierConfiguration.TwoFactorOneTimeCodeIdTimeToLiveInSeconds,
"two_factor_trust_id_time_to_live_in_seconds": t.ExternalIdentifierConfiguration.TwoFactorTrustIdTimeToLiveInSeconds,
"email_verification_one_time_code_generator": []map[string]interface{}{{
"length": t.ExternalIdentifierConfiguration.EmailVerificationOneTimeCodeGenerator.Length,
"type": t.ExternalIdentifierConfiguration.EmailVerificationOneTimeCodeGenerator.Type,
Expand Down
6 changes: 4 additions & 2 deletions fusionauth/resource_fusionauth_tenant_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -163,6 +163,7 @@ func testTenantAccTestCheckFuncs(
resource.TestCheckResourceAttr(tfResourcePath, "external_identifier_configuration.0.two_factor_one_time_code_id_generator.0.length", "8"),
resource.TestCheckResourceAttr(tfResourcePath, "external_identifier_configuration.0.two_factor_one_time_code_id_generator.0.type", "randomDigits"),
resource.TestCheckResourceAttr(tfResourcePath, "external_identifier_configuration.0.two_factor_id_time_to_live_in_seconds", "300"),
resource.TestCheckResourceAttr(tfResourcePath, "external_identifier_configuration.0.two_factor_one_time_code_id_time_to_live_in_seconds", "60"),
resource.TestCheckResourceAttr(tfResourcePath, "external_identifier_configuration.0.two_factor_trust_id_time_to_live_in_seconds", "2592000"),

// failed_authentication_configuration
Expand Down Expand Up @@ -555,8 +556,9 @@ resource "fusionauth_tenant" "test_%[1]s" {
length = 8
type = "randomDigits"
}
two_factor_id_time_to_live_in_seconds = 300
two_factor_trust_id_time_to_live_in_seconds = 2592000
two_factor_id_time_to_live_in_seconds = 300
two_factor_one_time_code_id_time_to_live_in_seconds = 60
two_factor_trust_id_time_to_live_in_seconds = 2592000
}
failed_authentication_configuration {
action_duration = 1
Expand Down

0 comments on commit a7af842

Please sign in to comment.