-
Notifications
You must be signed in to change notification settings - Fork 51
/
schema_fusionauth_tenant.go
1324 lines (1278 loc) · 52.8 KB
/
schema_fusionauth_tenant.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
package fusionauth
import (
"fmt"
"github.com/FusionAuth/go-client/pkg/fusionauth"
"github.com/hashicorp/terraform-plugin-sdk/helper/schema"
"github.com/hashicorp/terraform-plugin-sdk/helper/validation"
)
func newTenant() *schema.Resource {
return &schema.Resource{
Create: createTenant,
Read: readTenant,
Update: updateTenant,
Delete: deleteTenant,
Schema: map[string]*schema.Schema{
"source_tentant_id": {
Type: schema.TypeString,
Optional: true,
Description: "The optional Id of an existing Tenant to make a copy of. If present, the tenant.id and tenant.name values of the request body will be applied to the new Tenant, all other values will be copied from the source Tenant to the new Tenant.",
ValidateFunc: validation.IsUUID,
},
"tenant_id": {
Type: schema.TypeString,
Optional: true,
Description: "The Id to use for the new Tenant. If not specified a secure random UUID will be generated.",
ValidateFunc: validation.IsUUID,
},
"data": {
Type: schema.TypeMap,
Optional: true,
Description: "An object that can hold any information about the Tenant that should be persisted.",
},
"email_configuration": {
Type: schema.TypeList,
MaxItems: 1,
Required: true,
Elem: newEmailConfiguration(),
},
"event_configuration": {
Type: schema.TypeSet,
Optional: true,
Elem: &schema.Resource{
Schema: map[string]*schema.Schema{
"event": {
Type: schema.TypeString,
Optional: true,
ValidateFunc: validation.StringInSlice([]string{
"user.action",
"user.bulk.create",
"user.create",
"user.email.verified",
"user.update",
"user.deactivate",
"user.reactivate",
"user.login.success",
"user.login.failed",
"user.password.breach",
"user.registration.create",
"user.registration.update",
"user.registration.delete",
"user.registration.verified",
"user.delete",
"jwt.public-key.update",
"jwt.refresh-token.revoke",
"jwt.refresh",
}, false),
Description: "the event type",
},
"enabled": {
Type: schema.TypeBool,
Optional: true,
Default: true,
Description: "Whether or not FusionAuth should send these types of events to any configured Webhooks.",
},
"transaction_type": {
Type: schema.TypeString,
Optional: true,
ValidateFunc: validation.StringInSlice([]string{
"None",
"Any",
"SimpleMajority",
"SuperMajority",
"AbsoluteMajority",
}, false),
Description: "The transaction type that FusionAuth uses when sending these types of events to any configured Webhooks.",
},
},
},
},
"external_identifier_configuration": {
Type: schema.TypeList,
MaxItems: 1,
Required: true,
Elem: newExternalIdentifierConfiguration(),
},
"failed_authentication_configuration": {
Type: schema.TypeList,
MaxItems: 1,
Optional: true,
Elem: newFailedAuthenticationConfiguration(),
},
"family_configuration": {
Type: schema.TypeList,
MaxItems: 1,
Optional: true,
Elem: newFamilyConfiguration(),
},
"http_session_max_inactive_interval": {
Type: schema.TypeInt,
Optional: true,
Default: 3600,
},
"issuer": {
Type: schema.TypeString,
Required: true,
Description: "The named issuer used to sign tokens, this is generally your public fully qualified domain.",
},
"jwt_configuration": {
Type: schema.TypeList,
Required: true,
Elem: &schema.Resource{
Schema: map[string]*schema.Schema{
"access_token_key_id": {
Type: schema.TypeString,
Required: true,
ValidateFunc: validation.IsUUID,
Description: "The unique id of the signing key used to sign the access token.",
},
"id_token_key_id": {
Type: schema.TypeString,
Required: true,
ValidateFunc: validation.IsUUID,
Description: "The unique id of the signing key used to sign the Id token.",
},
"refresh_token_expiration_policy": {
Type: schema.TypeString,
Optional: true,
Default: "Fixed",
ValidateFunc: validation.StringInSlice([]string{
"Fixed",
"SlidingWindow",
}, false),
Description: "The refresh token expiration policy.",
},
"refresh_token_revocation_policy_on_login_prevented": {
Type: schema.TypeBool,
Optional: true,
Description: "When enabled, the refresh token will be revoked when a user action, such as locking an account based on a number of failed login attempts, prevents user login.",
},
"refresh_token_revocation_policy_on_password_change": {
Type: schema.TypeBool,
Optional: true,
Description: "When enabled, the refresh token will be revoked when a user changes their password.",
},
"refresh_token_time_to_live_in_minutes": {
Type: schema.TypeInt,
Required: true,
Description: "The length of time in minutes a Refresh Token is valid from the time it was issued. Value must be greater than 0.",
ValidateFunc: validation.IntAtLeast(1),
},
"refresh_token_usage_policy": {
Type: schema.TypeString,
Optional: true,
Default: "Reusable",
ValidateFunc: validation.StringInSlice([]string{
"Reusable",
"OneTimeUse",
}, false),
Description: "The refresh token usage policy.",
},
"time_to_live_in_seconds": {
Type: schema.TypeInt,
Required: true,
Description: "The length of time in seconds this JWT is valid from the time it was issued. Value must be greater than 0.",
ValidateFunc: validation.IntAtLeast(1),
},
},
},
},
"logout_url": {
Optional: true,
Type: schema.TypeString,
Description: "The logout redirect URL when sending the user’s browser to the /oauth2/logout URI of the FusionAuth Front End. This value is only used when a logout URL is not defined in your Application.",
},
"maximum_password_age": {
Optional: true,
Type: schema.TypeList,
MaxItems: 1,
Elem: &schema.Resource{
Schema: map[string]*schema.Schema{
"days": {
Type: schema.TypeInt,
Optional: true,
Default: 180,
Description: "The password maximum age in days. The number of days after which FusionAuth will require a user to change their password. Required when systemConfiguration.maximumPasswordAge.enabled is set to true.",
},
"enabled": {
Type: schema.TypeBool,
Optional: true,
Default: false,
Description: "Indicates that the maximum password age is enabled and being enforced.",
},
},
},
},
"minimum_password_age": {
Optional: true,
Type: schema.TypeList,
MaxItems: 1,
Elem: &schema.Resource{
Schema: map[string]*schema.Schema{
"seconds": {
Type: schema.TypeInt,
Optional: true,
Default: 30,
Description: "e password minimum age in seconds. When enabled FusionAuth will not allow a password to be changed until it reaches this minimum age. Required when systemConfiguration.minimumPasswordAge.enabled is set to true.",
},
"enabled": {
Type: schema.TypeBool,
Optional: true,
Default: false,
Description: "Indicates that the minimum password age is enabled and being enforced.",
},
},
},
},
"name": {
Type: schema.TypeString,
Required: true,
Description: "The unique name of the Tenant.",
},
"password_encryption_configuration": {
Optional: true,
Type: schema.TypeList,
Elem: &schema.Resource{
Schema: map[string]*schema.Schema{
"encryption_scheme": {
Type: schema.TypeString,
Optional: true,
ValidateFunc: validation.StringInSlice([]string{
"salted-md5",
"salted-sha256",
"salted-hmac-sha256",
"salted-pbkdf2-hmac-sha256",
"bcrypt",
}, false),
Description: "The default method for encrypting the User’s password.",
},
"encryption_scheme_factor": {
Type: schema.TypeInt,
Optional: true,
Default: 24000,
Description: "The factor used by the password encryption scheme. If not provided, the PasswordEncryptor provides a default value. Generally this will be used as an iteration count to generate the hash. The actual use of this value is up to the PasswordEncryptor implementation.",
},
"modify_encryption_scheme_on_login": {
Type: schema.TypeBool,
Optional: true,
Default: false,
Description: "When enabled a user’s hash configuration will be modified to match these configured settings. This can be useful to increase a password hash strength over time or upgrade imported users to a more secure encryption scheme after an initial import.",
},
},
},
},
"password_validation_rules": {
Type: schema.TypeList,
MaxItems: 1,
Optional: true,
Elem: newPasswordValidationRules(),
},
"theme_id": {
Type: schema.TypeString,
Required: true,
Description: "The unique Id of the theme to be used to style the login page and other end user templates.",
ValidateFunc: validation.IsUUID,
},
"user_delete_policy": {
Optional: true,
Type: schema.TypeList,
MaxItems: 1,
Elem: &schema.Resource{
Schema: map[string]*schema.Schema{
"unverified_enabled": {
Type: schema.TypeBool,
Optional: true,
Default: false,
Description: "Indicates that users without a verified email address will be permanently deleted after tenant.userDeletePolicy.unverified.numberOfDaysToRetain days.",
},
"unverified_number_of_days_to_retain": {
Type: schema.TypeInt,
Optional: true,
Description: "The number of days from creation users will be retained before being deleted for not completing email verification. This field is required when tenant.userDeletePolicy.unverified.enabled is set to true. Value must be greater than 0.",
ValidateFunc: validation.IntAtLeast(1),
},
},
},
},
},
Importer: &schema.ResourceImporter{
State: schema.ImportStatePassthrough,
},
}
}
func newFamilyConfiguration() *schema.Resource {
return &schema.Resource{
Schema: map[string]*schema.Schema{
"allow_child_registrations": {
Type: schema.TypeBool,
Optional: true,
Default: true,
Description: "Whether to allow child registrations.",
},
"confirm_child_email_template_id": {
Type: schema.TypeString,
Optional: true,
ValidateFunc: validation.IsUUID,
Description: "The unique Id of the email template to use when confirming a child.",
},
"delete_orphaned_accounts": {
Type: schema.TypeBool,
Optional: true,
Default: false,
Description: "Indicates that child users without parental verification will be permanently deleted after tenant.familyConfiguration.deleteOrphanedAccountsDays days.",
},
"delete_orphaned_accounts_days": {
Type: schema.TypeInt,
Optional: true,
Default: 30,
Description: "The number of days from creation child users will be retained before being deleted for not completing parental verification. Value must be greater than 0.",
ValidateFunc: validation.IntAtLeast(1),
},
"enabled": {
Type: schema.TypeBool,
Optional: true,
Default: false,
Description: "Whether family configuration is enabled.",
},
"family_request_email_template_id": {
Type: schema.TypeString,
Optional: true,
ValidateFunc: validation.IsUUID,
Description: "The unique Id of the email template to use when a family request is made.",
},
"maximum_child_age": {
Type: schema.TypeInt,
Optional: true,
Default: 12,
ValidateFunc: validation.IntAtLeast(1),
Description: "The maximum age of a child. Value must be greater than 0.",
},
"minimum_owner_age": {
Type: schema.TypeInt,
Optional: true,
ValidateFunc: validation.IntAtLeast(1),
Default: 21,
Description: "The minimum age to be an owner. Value must be greater than 0.",
},
"parent_email_required": {
Type: schema.TypeBool,
Optional: true,
Default: false,
Description: "Whether a parent email is required.",
},
"parent_registration_email_template_id": {
Type: schema.TypeString,
Optional: true,
ValidateFunc: validation.IsUUID,
Description: "The unique Id of the email template to use for parent registration.",
},
},
}
}
func newFailedAuthenticationConfiguration() *schema.Resource {
return &schema.Resource{
Schema: map[string]*schema.Schema{
"action_duration": {
Type: schema.TypeInt,
Required: true,
ValidateFunc: validation.IntAtLeast(1),
Description: "The duration of the User Action. This value along with the actionDurationUnit will be used to set the duration of the User Action. Value must be greater than 0.",
},
"action_duration_unit": {
Type: schema.TypeString,
Optional: true,
ValidateFunc: validation.StringInSlice([]string{
"MINUTES",
"HOURS",
"DAYS",
"WEEKS",
"MONTHS",
"YEARS",
}, false),
Default: "MINUTES",
Description: "The unit of time associated with a duration.",
},
"reset_count_in_seconds": {
Type: schema.TypeInt,
Optional: true,
Default: 60,
Description: "The length of time in seconds before the failed authentication count will be reset. Value must be greater than 0.",
ValidateFunc: validation.IntAtLeast(1),
},
"too_many_attempts": {
Type: schema.TypeInt,
Optional: true,
Default: 5,
Description: "The number of failed attempts considered to be too many. Once this threshold is reached the specified User Action will be applied to the user for the duration specified. Value must be greater than 0.",
ValidateFunc: validation.IntAtLeast(1),
},
"user_action_id": {
Type: schema.TypeString,
Optional: true,
Description: "The Id of the User Action that is applied when the threshold is reached for too many failed authentication attempts.",
ValidateFunc: validation.IsUUID,
},
},
}
}
func newExternalIdentifierConfiguration() *schema.Resource {
return &schema.Resource{
Schema: map[string]*schema.Schema{
"authorization_grant_id_time_to_live_in_seconds": {
Type: schema.TypeInt,
Required: true,
Description: "The time in seconds until a OAuth authorization code in no longer valid to be exchanged for an access token. This is essentially the time allowed between the start of an Authorization request during the Authorization code grant and when you request an access token using this authorization code on the Token endpoint.",
ValidateFunc: validation.IntBetween(1, 600),
},
"change_password_id_generator": {
Type: schema.TypeList,
MaxItems: 1,
Required: true,
Elem: &schema.Resource{
Schema: map[string]*schema.Schema{
"length": {
Type: schema.TypeInt,
Required: true,
Description: "The length of the secure generator used for generating the change password Id.",
},
"type": {
Type: schema.TypeString,
Required: true,
ValidateFunc: validation.StringInSlice([]string{
"randomAlpha",
"randomAlphaNumeric",
"randomBytes",
"randomDigits.",
}, false),
Description: "The type of the secure generator used for generating the change password Id.",
},
},
},
},
"change_password_id_time_to_live_in_seconds": {
Type: schema.TypeInt,
Required: true,
Description: "The time in seconds until a change password Id is no longer valid and cannot be used by the Change Password API. Value must be greater than 0.",
ValidateFunc: validation.IntAtLeast(1),
},
"device_code_time_to_live_in_seconds": {
Type: schema.TypeInt,
Required: true,
Description: "The time in seconds until a device code Id is no longer valid and cannot be used by the Token API. Value must be greater than 0.",
ValidateFunc: validation.IntAtLeast(1),
},
"device_user_code_id_generator": {
Type: schema.TypeList,
MaxItems: 1,
Required: true,
Elem: &schema.Resource{
Schema: map[string]*schema.Schema{
"length": {
Type: schema.TypeInt,
Required: true,
Description: "The length of the secure generator used for generating the change password Id.",
},
"type": {
Type: schema.TypeString,
Required: true,
ValidateFunc: validation.StringInSlice([]string{
"randomAlpha",
"randomAlphaNumeric",
"randomBytes",
"randomDigits.",
}, false),
Description: "The type of the secure generator used for generating the change password Id.",
},
},
},
},
"email_verification_id_generator": {
Type: schema.TypeList,
MaxItems: 1,
Required: true,
Elem: &schema.Resource{
Schema: map[string]*schema.Schema{
"length": {
Type: schema.TypeInt,
Required: true,
Description: "The length of the secure generator used for generating the change password Id.",
},
"type": {
Type: schema.TypeString,
Required: true,
ValidateFunc: validation.StringInSlice([]string{
"randomAlpha",
"randomAlphaNumeric",
"randomBytes",
"randomDigits.",
}, false),
Description: "The type of the secure generator used for generating the change password Id.",
},
},
},
},
"email_verification_id_time_to_live_in_seconds": {
Type: schema.TypeInt,
Required: true,
Description: "The time in seconds until a email verification Id is no longer valid and cannot be used by the Verify Email API. Value must be greater than 0.",
ValidateFunc: validation.IntAtLeast(1),
},
"external_authentication_id_time_to_live_in_seconds": {
Type: schema.TypeInt,
Required: true,
Description: "The time in seconds until an external authentication Id is no longer valid and cannot be used by the Token API. Value must be greater than 0.",
ValidateFunc: validation.IntAtLeast(1),
},
"one_time_password_time_to_live_in_seconds": {
Type: schema.TypeInt,
Required: true,
Description: "The time in seconds until a One Time Password is no longer valid and cannot be used by the Login API. Value must be greater than 0.",
ValidateFunc: validation.IntAtLeast(1),
},
"passwordless_login_generator": {
Type: schema.TypeList,
MaxItems: 1,
Required: true,
Elem: &schema.Resource{
Schema: map[string]*schema.Schema{
"length": {
Type: schema.TypeInt,
Required: true,
Description: "The length of the secure generator used for generating the change password Id.",
},
"type": {
Type: schema.TypeString,
Required: true,
ValidateFunc: validation.StringInSlice([]string{
"randomAlpha",
"randomAlphaNumeric",
"randomBytes",
"randomDigits.",
}, false),
Description: "The type of the secure generator used for generating the change password Id.",
},
},
},
},
"passwordless_login_time_to_live_in_seconds": {
Type: schema.TypeInt,
Required: true,
Description: "The time in seconds until a passwordless code is no longer valid and cannot be used by the Passwordless API. Value must be greater than 0.",
ValidateFunc: validation.IntAtLeast(1),
},
"registration_verification_id_generator": {
Type: schema.TypeList,
MaxItems: 1,
Required: true,
Elem: &schema.Resource{
Schema: map[string]*schema.Schema{
"length": {
Type: schema.TypeInt,
Required: true,
Description: "The length of the secure generator used for generating the change password Id.",
},
"type": {
Type: schema.TypeString,
Required: true,
ValidateFunc: validation.StringInSlice([]string{
"randomAlpha",
"randomAlphaNumeric",
"randomBytes",
"randomDigits.",
}, false),
Description: "The type of the secure generator used for generating the change password Id.",
},
},
},
},
"registration_verification_id_time_to_live_in_seconds": {
Type: schema.TypeInt,
Required: true,
Description: "The time in seconds until a registration verification Id is no longer valid and cannot be used by the Verify Registration API. Value must be greater than 0.",
ValidateFunc: validation.IntAtLeast(1),
},
"setup_password_id_generator": {
Type: schema.TypeList,
MaxItems: 1,
Required: true,
Elem: &schema.Resource{
Schema: map[string]*schema.Schema{
"length": {
Type: schema.TypeInt,
Required: true,
Description: "The length of the secure generator used for generating the change password Id.",
},
"type": {
Type: schema.TypeString,
Required: true,
ValidateFunc: validation.StringInSlice([]string{
"randomAlpha",
"randomAlphaNumeric",
"randomBytes",
"randomDigits.",
}, false),
Description: "The type of the secure generator used for generating the change password Id.",
},
},
},
},
"setup_password_id_time_to_live_in_seconds": {
Type: schema.TypeInt,
Required: true,
ValidateFunc: validation.IntAtLeast(1),
Description: "The time in seconds until a setup password Id is no longer valid and cannot be used by the Change Password API. Value must be greater than 0.",
},
"two_factor_id_time_to_live_in_seconds": {
Type: schema.TypeInt,
Required: true,
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_trust_id_time_to_live_in_seconds": {
Type: schema.TypeInt,
Required: true,
ValidateFunc: validation.IntAtLeast(1),
Description: "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.",
},
},
}
}
func newEmailConfiguration() *schema.Resource {
return &schema.Resource{
Schema: map[string]*schema.Schema{
"default_from_name": {
Type: schema.TypeString,
Optional: true,
Description: "The default From Name used in sending emails when a from name is not provided on an individual email template. This is the display name part of the email address ( i.e. Jared Dunn <jared@piedpiper.com>).",
},
"default_from_email": {
Type: schema.TypeString,
Optional: true,
Description: "The default email address that emails will be sent from when a from address is not provided on an individual email template. This is the address part email address (i.e. Jared Dunn <jared@piedpiper.com>).",
},
"forgot_password_email_template_id": {
Type: schema.TypeString,
Optional: true,
Description: "The Id of the Email Template that is used when a user is sent a forgot password email.",
},
"host": {
Type: schema.TypeString,
Required: true,
Description: "The host name of the SMTP server that FusionAuth will use.",
},
"password": {
Type: schema.TypeString,
Optional: true,
Sensitive: true,
Description: "An optional password FusionAuth will use to authenticate with the SMTP server.",
},
"passwordless_email_template_id": {
Type: schema.TypeString,
Optional: true,
Description: "The Id of the Passwordless Email Template.",
},
"port": {
Type: schema.TypeInt,
Required: true,
Description: "The port of the SMTP server that FusionAuth will use.",
},
"properties": {
Type: schema.TypeString,
Optional: true,
Sensitive: true,
Description: "Additional Email Configuration in a properties file formatted String.",
},
"security": {
Type: schema.TypeString,
Optional: true,
ValidateFunc: validation.StringInSlice([]string{
"NONE",
"SSL",
"TLS",
}, false),
Default: "NONE",
Description: "The type of security protocol FusionAuth will use when connecting to the SMTP server.",
},
"set_password_email_template_id": {
Type: schema.TypeString,
Optional: true,
Description: "The Id of the Email Template that is used when a user had their account created for them and they must set their password manually and they are sent an email to set their password.",
},
"username": {
Type: schema.TypeString,
Optional: true,
Description: "An optional username FusionAuth will to authenticate with the SMTP server.",
},
"verification_email_template_id": {
Type: schema.TypeString,
Optional: true,
Description: "The If of the Email Template that is used to send the verification emails to users. These emails are used to verify that a user’s email address is valid. If either the verifyEmail or verifyEmailWhenChanged fields are true this field is required.",
},
"verify_email": {
Type: schema.TypeBool,
Optional: true,
Default: false,
Description: "Whether the user’s email addresses are verified when the registers with your application.",
},
"verify_email_when_changed": {
Type: schema.TypeBool,
Optional: true,
Default: false,
Description: "Whether the user’s email addresses are verified when the user changes them.",
},
},
}
}
func newPasswordValidationRules() *schema.Resource {
return &schema.Resource{
Schema: map[string]*schema.Schema{
"breach_detection": {
Optional: true,
Type: schema.TypeList,
MaxItems: 1,
Computed: true,
ConfigMode: schema.SchemaConfigModeAttr,
Elem: &schema.Resource{
Schema: map[string]*schema.Schema{
"enabled": {
Type: schema.TypeBool,
Optional: true,
Default: false,
Description: "Whether to enable Reactor breach detection. Requires an activated license.",
},
"match_mode": {
Type: schema.TypeString,
Optional: true,
ValidateFunc: validation.StringInSlice([]string{
"High",
"Medium",
"Low",
}, false),
Description: "The level of severity where Reactor will consider a breach.",
},
"notify_user_email_template_id": {
Type: schema.TypeString,
Optional: true,
ValidateFunc: validation.IsUUID,
Description: "The Id of the email template to use when notifying user of breached password. Required if tenant.passwordValidationRules.breachDetection.onLogin is set to NotifyUser.",
},
"on_login": {
Type: schema.TypeString,
Optional: true,
ValidateFunc: validation.StringInSlice([]string{
"Off",
"RecordOnly",
"NotifyUser",
"RequireChange",
}, false),
Description: "The behavior when detecting breaches at time of user login",
},
},
},
},
"max_length": {
Type: schema.TypeInt,
Optional: true,
Default: 256,
},
"min_length": {
Type: schema.TypeInt,
Optional: true,
Default: 8,
},
"remember_previous_passwords": {
Optional: true,
Type: schema.TypeList,
MaxItems: 1,
Elem: &schema.Resource{
Schema: map[string]*schema.Schema{
"count": {
Type: schema.TypeInt,
Optional: true,
Description: "The number of previous passwords to remember. Value must be greater than 0.",
ValidateFunc: validation.IntAtLeast(1),
},
"enabled": {
Type: schema.TypeBool,
Optional: true,
Default: false,
Description: "Whether to prevent a user from using any of their previous passwords.",
},
},
},
},
"required_mixed_case": {
Type: schema.TypeBool,
Optional: true,
Description: "Whether to force the user to use at least one uppercase and one lowercase character.",
},
"require_non_alpha": {
Type: schema.TypeBool,
Optional: true,
Description: "Whether to force the user to use at least one non-alphanumeric character.",
},
"require_number": {
Type: schema.TypeBool,
Optional: true,
Description: "Whether to force the user to use at least one number.",
},
"validate_on_login": {
Type: schema.TypeBool,
Optional: true,
Description: "When enabled the user’s password will be validated during login. If the password does not meet the currently configured validation rules the user will be required to change their password.",
},
},
}
}
func buildTentant(data *schema.ResourceData) fusionauth.Tenant {
return fusionauth.Tenant{
Data: data.Get("data").(map[string]interface{}),
EmailConfiguration: fusionauth.EmailConfiguration{
ForgotPasswordEmailTemplateId: data.Get("email_configuration.0.forgot_password_email_template_id").(string),
Host: data.Get("email_configuration.0.host").(string),
Password: data.Get("email_configuration.0.password").(string),
PasswordlessEmailTemplateId: data.Get("email_configuration.0.passwordless_email_template_id").(string),
Port: data.Get("email_configuration.0.port").(int),
Properties: data.Get("email_configuration.0.properties").(string),
Security: fusionauth.EmailSecurityType(data.Get("email_configuration.0.security").(string)),
SetPasswordEmailTemplateId: data.Get("email_configuration.0.set_password_email_template_id").(string),
Username: data.Get("email_configuration.0.username").(string),
VerificationEmailTemplateId: data.Get("email_configuration.0.verification_email_template_id").(string),
VerifyEmail: data.Get("email_configuration.0.verify_email").(bool),
VerifyEmailWhenChanged: data.Get("email_configuration.0.verify_email_when_changed").(bool),
DefaultFromEmail: data.Get("email_configuration.0.default_from_email").(string),
DefaultFromName: data.Get("email_configuration.0.default_from_name").(string),
},
EventConfiguration: buildEventConfiguration("event_configuration", data),
ExternalIdentifierConfiguration: fusionauth.ExternalIdentifierConfiguration{
AuthorizationGrantIdTimeToLiveInSeconds: data.Get(
"external_identifier_configuration.0.authorization_grant_id_time_to_live_in_seconds",
).(int),
ChangePasswordIdGenerator: fusionauth.SecureGeneratorConfiguration{
Length: data.Get("external_identifier_configuration.0.change_password_id_generator.0.length").(int),
Type: fusionauth.SecureGeneratorType(
data.Get("external_identifier_configuration.0.change_password_id_generator.0.type").(string),
),
},
ChangePasswordIdTimeToLiveInSeconds: data.Get(
"external_identifier_configuration.0.change_password_id_time_to_live_in_seconds",
).(int),
DeviceCodeTimeToLiveInSeconds: data.Get(
"external_identifier_configuration.0.device_code_time_to_live_in_seconds",
).(int),
DeviceUserCodeIdGenerator: fusionauth.SecureGeneratorConfiguration{
Length: data.Get("external_identifier_configuration.0.device_user_code_id_generator.0.length").(int),
Type: fusionauth.SecureGeneratorType(
data.Get("external_identifier_configuration.0.device_user_code_id_generator.0.type").(string),
),
},
EmailVerificationIdGenerator: fusionauth.SecureGeneratorConfiguration{
Length: data.Get("external_identifier_configuration.0.email_verification_id_generator.0.length").(int),
Type: fusionauth.SecureGeneratorType(
data.Get("external_identifier_configuration.0.email_verification_id_generator.0.type").(string),
),
},
EmailVerificationIdTimeToLiveInSeconds: data.Get(
"external_identifier_configuration.0.email_verification_id_time_to_live_in_seconds",
).(int),
ExternalAuthenticationIdTimeToLiveInSeconds: data.Get(
"external_identifier_configuration.0.external_authentication_id_time_to_live_in_seconds",
).(int),
OneTimePasswordTimeToLiveInSeconds: data.Get(
"external_identifier_configuration.0.one_time_password_time_to_live_in_seconds",
).(int),
PasswordlessLoginGenerator: fusionauth.SecureGeneratorConfiguration{
Length: data.Get("external_identifier_configuration.0.passwordless_login_generator.0.length").(int),
Type: fusionauth.SecureGeneratorType(
data.Get("external_identifier_configuration.0.passwordless_login_generator.0.type").(string),
),
},
PasswordlessLoginTimeToLiveInSeconds: data.Get(
"external_identifier_configuration.0.passwordless_login_time_to_live_in_seconds").(int),
RegistrationVerificationIdGenerator: fusionauth.SecureGeneratorConfiguration{
Length: data.Get("external_identifier_configuration.0.registration_verification_id_generator.0.length").(int),
Type: fusionauth.SecureGeneratorType(
data.Get("external_identifier_configuration.0.registration_verification_id_generator.0.type").(string),
),
},
RegistrationVerificationIdTimeToLiveInSeconds: data.Get(
"external_identifier_configuration.0.registration_verification_id_time_to_live_in_seconds",
).(int),
SetupPasswordIdGenerator: fusionauth.SecureGeneratorConfiguration{
Length: data.Get("external_identifier_configuration.0.setup_password_id_generator.0.length").(int),
Type: fusionauth.SecureGeneratorType(
data.Get("external_identifier_configuration.0.setup_password_id_generator.0.type").(string),
),
},
SetupPasswordIdTimeToLiveInSeconds: data.Get(
"external_identifier_configuration.0.setup_password_id_time_to_live_in_seconds",
).(int),
TwoFactorIdTimeToLiveInSeconds: data.Get(
"external_identifier_configuration.0.two_factor_id_time_to_live_in_seconds",
).(int),
TwoFactorTrustIdTimeToLiveInSeconds: data.Get(
"external_identifier_configuration.0.two_factor_trust_id_time_to_live_in_seconds",
).(int),
},
FailedAuthenticationConfiguration: fusionauth.FailedAuthenticationConfiguration{
ActionDuration: int64(data.Get("failed_authentication_configuration.0.action_duration").(int)),
ActionDurationUnit: fusionauth.ExpiryUnit(
data.Get("failed_authentication_configuration.0.action_duration_unit").(string),
),
ResetCountInSeconds: data.Get("failed_authentication_configuration.0.reset_count_in_seconds").(int),
TooManyAttempts: data.Get("failed_authentication_configuration.0.too_many_attempts").(int),
UserActionId: data.Get("failed_authentication_configuration.0.user_action_id").(string),
},
FamilyConfiguration: fusionauth.FamilyConfiguration{
AllowChildRegistrations: data.Get("family_configuration.0.allow_child_registrations").(bool),
ConfirmChildEmailTemplateId: data.Get("family_configuration.0.confirm_child_email_template_id").(string),
DeleteOrphanedAccounts: data.Get("family_configuration.0.delete_orphaned_accounts").(bool),
DeleteOrphanedAccountsDays: data.Get("family_configuration.0.delete_orphaned_accounts_days").(int),
Enableable: buildEnableable("family_configuration.0.enabled", data),
FamilyRequestEmailTemplateId: data.Get("family_configuration.0.family_request_email_template_id").(string),
MaximumChildAge: data.Get("family_configuration.0.maximum_child_age").(int),
MinimumOwnerAge: data.Get("family_configuration.0.minimum_owner_age").(int),
ParentEmailRequired: data.Get("family_configuration.0.parent_email_required").(bool),
ParentRegistrationEmailTemplateId: data.Get("family_configuration.0.parent_registration_email_template_id").(string),
},
HttpSessionMaxInactiveInterval: data.Get("http_session_max_inactive_interval").(int),
Issuer: data.Get("issuer").(string),
JwtConfiguration: fusionauth.JWTConfiguration{
AccessTokenKeyId: data.Get("jwt_configuration.0.access_token_key_id").(string),
IdTokenKeyId: data.Get("jwt_configuration.0.id_token_key_id").(string),
RefreshTokenExpirationPolicy: fusionauth.RefreshTokenExpirationPolicy(data.Get("jwt_configuration.0.refresh_token_expiration_policy").(string)),
RefreshTokenRevocationPolicy: fusionauth.RefreshTokenRevocationPolicy{
OnLoginPrevented: data.Get("jwt_configuration.0.refresh_token_revocation_policy_on_login_prevented").(bool),
OnPasswordChanged: data.Get("jwt_configuration.0.refresh_token_revocation_policy_on_password_change").(bool),
},
RefreshTokenTimeToLiveInMinutes: data.Get("jwt_configuration.0.refresh_token_time_to_live_in_minutes").(int),
RefreshTokenUsagePolicy: fusionauth.RefreshTokenUsagePolicy(data.Get("jwt_configuration.0.refresh_token_usage_policy").(string)),
TimeToLiveInSeconds: data.Get("jwt_configuration.0.time_to_live_in_seconds").(int),
},
LogoutURL: data.Get("logout_url").(string),
MaximumPasswordAge: fusionauth.MaximumPasswordAge{
Enableable: buildEnableable("maximum_password_age.0.enabled", data),
Days: data.Get("maximum_password_age.0.days").(int),
},
MinimumPasswordAge: fusionauth.MinimumPasswordAge{
Enableable: buildEnableable("minimum_password_age.0.enabled", data),
Seconds: data.Get("minimum_password_age.0.seconds").(int),
},
Name: data.Get("name").(string),
PasswordEncryptionConfiguration: fusionauth.PasswordEncryptionConfiguration{
EncryptionScheme: data.Get("password_encryption_configuration.0.encryption_scheme").(string),
EncryptionSchemeFactor: data.Get("password_encryption_configuration.0.encryption_scheme_factor").(int),
ModifyEncryptionSchemeOnLogin: data.Get(
"password_encryption_configuration.0.modify_encryption_scheme_on_login",
).(bool),
},
PasswordValidationRules: fusionauth.PasswordValidationRules{
BreachDetection: fusionauth.PasswordBreachDetection{
Enableable: buildEnableable("password_validation_rules.0.breach_detection.0.enabled", data),
MatchMode: fusionauth.BreachMatchMode(
data.Get("password_validation_rules.0.breach_detection.0.match_mode").(string),
),
NotifyUserEmailTemplateId: data.Get(
"password_validation_rules.0.breach_detection.0.notify_user_email_template_id",
).(string),
OnLogin: fusionauth.BreachAction(
data.Get("password_validation_rules.0.breach_detection.0.on_login").(string),
),
},
MaxLength: data.Get("password_validation_rules.0.max_length").(int),
MinLength: data.Get("password_validation_rules.0.min_length").(int),
RememberPreviousPasswords: fusionauth.RememberPreviousPasswords{
Enableable: buildEnableable("password_validation_rules.0.remember_previous_passwords.0.enabled", data),
Count: data.Get("password_validation_rules.0.remember_previous_passwords.0.count").(int),
},
RequireMixedCase: data.Get("password_validation_rules.0.required_mixed_case").(bool),
RequireNonAlpha: data.Get("password_validation_rules.0.require_non_alpha").(bool),
RequireNumber: data.Get("password_validation_rules.0.require_number").(bool),
ValidateOnLogin: data.Get("password_validation_rules.0.validate_on_login").(bool),
},