Skip to content
This repository was archived by the owner on Mar 8, 2022. It is now read-only.

Commit cbecf8d

Browse files
committed
Merge branch 'bishtawi-sb/tenant-flags'
2 parents 64f569b + a8875ab commit cbecf8d

File tree

3 files changed

+173
-12
lines changed

3 files changed

+173
-12
lines changed

README.md

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,6 @@ Examples of resources can be found in the [examples directory](example/). The cu
6565
- [ ] [Guardian](https://auth0.com/docs/api/management/v2#!/Guardian/get_factors)
6666
- [ ] [Jobs](https://auth0.com/docs/api/management/v2#!/Jobs/get_jobs_by_id)
6767
- [X] [Tenants](https://auth0.com/docs/api/management/v2#!/Tenants/get_settings)
68-
- Missing attributes: `flags`, `universal_login`, `idle_session_lifetime`.
6968
- [ ] [Tickets](https://auth0.com/docs/api/management/v2#!/Tickets/post_email_verification)
7069

7170
Developing the Provider

auth0/resource_auth0_tenant.go

Lines changed: 153 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -111,6 +111,85 @@ func newTenant() *schema.Resource {
111111
Optional: true,
112112
Computed: true,
113113
},
114+
"idle_session_lifetime": {
115+
Type: schema.TypeInt,
116+
Optional: true,
117+
},
118+
"flags": {
119+
Type: schema.TypeList,
120+
Optional: true,
121+
MaxItems: 1,
122+
Elem: &schema.Resource{
123+
Schema: map[string]*schema.Schema{
124+
"change_pwd_flow_v1": {
125+
Type: schema.TypeBool,
126+
Optional: true,
127+
},
128+
"enable_client_connections": {
129+
Type: schema.TypeBool,
130+
Optional: true,
131+
},
132+
"enable_apis_section": {
133+
Type: schema.TypeBool,
134+
Optional: true,
135+
},
136+
"enable_pipeline2": {
137+
Type: schema.TypeBool,
138+
Optional: true,
139+
},
140+
"enable_dynamic_client_registration": {
141+
Type: schema.TypeBool,
142+
Optional: true,
143+
},
144+
"enable_custom_domain_in_emails": {
145+
Type: schema.TypeBool,
146+
Optional: true,
147+
},
148+
"universal_login": {
149+
Type: schema.TypeBool,
150+
Optional: true,
151+
},
152+
"enable_legacy_logs_search_v2": {
153+
Type: schema.TypeBool,
154+
Optional: true,
155+
},
156+
"disable_clickjack_protection_headers": {
157+
Type: schema.TypeBool,
158+
Optional: true,
159+
},
160+
"enable_public_signup_user_exists_error": {
161+
Type: schema.TypeBool,
162+
Optional: true,
163+
},
164+
},
165+
},
166+
},
167+
"universal_login": {
168+
Type: schema.TypeList,
169+
Optional: true,
170+
MaxItems: 1,
171+
Elem: &schema.Resource{
172+
Schema: map[string]*schema.Schema{
173+
"colors": {
174+
Type: schema.TypeList,
175+
Optional: true,
176+
MaxItems: 1,
177+
Elem: &schema.Resource{
178+
Schema: map[string]*schema.Schema{
179+
"primary": {
180+
Type: schema.TypeString,
181+
Optional: true,
182+
},
183+
"page_background": {
184+
Type: schema.TypeString,
185+
Optional: true,
186+
},
187+
},
188+
},
189+
},
190+
},
191+
},
192+
},
114193
},
115194
}
116195
}
@@ -165,6 +244,39 @@ func readTenant(d *schema.ResourceData, m interface{}) error {
165244
d.Set("allowed_logout_urls", t.AllowedLogoutURLs)
166245
d.Set("session_lifetime", t.SessionLifetime)
167246
d.Set("sandbox_version", t.SandboxVersion)
247+
d.Set("idle_session_lifetime", t.IdleSessionLifetime)
248+
249+
if flags := t.Flags; flags != nil {
250+
d.Set("flags", []map[string]interface{}{
251+
{
252+
"change_pwd_flow_v1": flags.ChangePasswordFlowV1,
253+
"enable_client_connections": flags.EnableClientConnections,
254+
"enable_apis_section": flags.EnableAPIsSection,
255+
"enable_pipeline2": flags.EnablePipeline2,
256+
"enable_dynamic_client_registration": flags.EnableDynamicClientRegistration,
257+
"enable_custom_domain_in_emails": flags.EnableCustomDomainInEmails,
258+
"universal_login": flags.UniversalLogin,
259+
"enable_legacy_logs_search_v2": flags.EnableLegacyLogsSearchV2,
260+
"disable_clickjack_protection_headers": flags.DisableClickjackProtectionHeaders,
261+
"enable_public_signup_user_exists_error": flags.EnablePublicSignupUserExistsError,
262+
},
263+
})
264+
}
265+
266+
if universalLogin := t.UniversalLogin; universalLogin != nil {
267+
if colors := universalLogin.Colors; colors != nil {
268+
d.Set("universal_login", []map[string]interface{}{
269+
{
270+
"colors": []map[string]interface{}{
271+
{
272+
"primary": universalLogin.Colors.Primary,
273+
"page_background": universalLogin.Colors.PageBackground,
274+
},
275+
},
276+
},
277+
})
278+
}
279+
}
168280

169281
return nil
170282
}
@@ -186,15 +298,16 @@ func deleteTenant(d *schema.ResourceData, m interface{}) error {
186298

187299
func buildTenant(d *schema.ResourceData) *management.Tenant {
188300
t := &management.Tenant{
189-
DefaultAudience: String(d, "default_audience"),
190-
DefaultDirectory: String(d, "default_directory"),
191-
FriendlyName: String(d, "friendly_name"),
192-
PictureURL: String(d, "picture_url"),
193-
SupportEmail: String(d, "support_email"),
194-
SupportURL: String(d, "support_url"),
195-
AllowedLogoutURLs: Slice(d, "allowed_logout_urls"),
196-
SessionLifetime: Int(d, "session_lifetime"),
197-
SandboxVersion: String(d, "sandbox_version"),
301+
DefaultAudience: String(d, "default_audience"),
302+
DefaultDirectory: String(d, "default_directory"),
303+
FriendlyName: String(d, "friendly_name"),
304+
PictureURL: String(d, "picture_url"),
305+
SupportEmail: String(d, "support_email"),
306+
SupportURL: String(d, "support_url"),
307+
AllowedLogoutURLs: Slice(d, "allowed_logout_urls"),
308+
SessionLifetime: Int(d, "session_lifetime"),
309+
SandboxVersion: String(d, "sandbox_version"),
310+
IdleSessionLifetime: Int(d, "idle_session_lifetime"),
198311
}
199312

200313
List(d, "change_password").First(func(v interface{}) {
@@ -225,5 +338,36 @@ func buildTenant(d *schema.ResourceData) *management.Tenant {
225338
}
226339
})
227340

341+
List(d, "flags").First(func(v interface{}) {
342+
m := v.(map[string]interface{})
343+
344+
t.Flags = &management.TenantFlags{
345+
ChangePasswordFlowV1: Bool(MapData(m), "change_pwd_flow_v1"),
346+
EnableClientConnections: Bool(MapData(m), "enable_client_connections"),
347+
EnableAPIsSection: Bool(MapData(m), "enable_apis_section"),
348+
EnablePipeline2: Bool(MapData(m), "enable_pipeline2"),
349+
EnableDynamicClientRegistration: Bool(MapData(m), "enable_dynamic_client_registration"),
350+
EnableCustomDomainInEmails: Bool(MapData(m), "enable_custom_domain_in_emails"),
351+
UniversalLogin: Bool(MapData(m), "universal_login"),
352+
EnableLegacyLogsSearchV2: Bool(MapData(m), "enable_legacy_logs_search_v2"),
353+
DisableClickjackProtectionHeaders: Bool(MapData(m), "disable_clickjack_protection_headers"),
354+
EnablePublicSignupUserExistsError: Bool(MapData(m), "enable_public_signup_user_exists_error"),
355+
}
356+
})
357+
358+
List(d, "universal_login").First(func(v interface{}) {
359+
m := v.(map[string]interface{})
360+
361+
t.UniversalLogin = &management.TenantUniversalLogin{}
362+
363+
List(MapData(m), "colors").First(func(v interface{}) {
364+
m := v.(map[string]interface{})
365+
t.UniversalLogin.Colors = &management.TenantUniversalLoginColors{
366+
Primary: String(MapData(m), "primary"),
367+
PageBackground: String(MapData(m), "page_background"),
368+
}
369+
})
370+
})
371+
228372
return t
229373
}

auth0/resource_auth0_tenant_test.go

Lines changed: 20 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,8 +31,14 @@ func TestAccTenant(t *testing.T) {
3131
resource.TestCheckResourceAttr("auth0_tenant.my_tenant", "support_email", "[email protected]"),
3232
resource.TestCheckResourceAttr("auth0_tenant.my_tenant", "support_url", "https://mycompany.org/support"),
3333
resource.TestCheckResourceAttr("auth0_tenant.my_tenant", "allowed_logout_urls.0", "https://mycompany.org/logoutCallback"),
34-
resource.TestCheckResourceAttr("auth0_tenant.my_tenant", "session_lifetime", "168"),
34+
resource.TestCheckResourceAttr("auth0_tenant.my_tenant", "session_lifetime", "1080"),
3535
resource.TestCheckResourceAttr("auth0_tenant.my_tenant", "sandbox_version", "8"),
36+
resource.TestCheckResourceAttr("auth0_tenant.my_tenant", "idle_session_lifetime", "720"),
37+
resource.TestCheckResourceAttr("auth0_tenant.my_tenant", "flags.0.universal_login", "true"),
38+
resource.TestCheckResourceAttr("auth0_tenant.my_tenant", "flags.0.disable_clickjack_protection_headers", "true"),
39+
resource.TestCheckResourceAttr("auth0_tenant.my_tenant", "flags.0.enable_public_signup_user_exists_error", "true"),
40+
resource.TestCheckResourceAttr("auth0_tenant.my_tenant", "universal_login.0.colors.0.primary", "#0059d6"),
41+
resource.TestCheckResourceAttr("auth0_tenant.my_tenant", "universal_login.0.colors.0.page_background", "#000000"),
3642
),
3743
},
3844
},
@@ -65,7 +71,19 @@ resource "auth0_tenant" "my_tenant" {
6571
allowed_logout_urls = [
6672
"https://mycompany.org/logoutCallback"
6773
]
68-
session_lifetime = 168
74+
session_lifetime = 1080
6975
sandbox_version = "8"
76+
idle_session_lifetime = 720
77+
flags {
78+
universal_login = true
79+
disable_clickjack_protection_headers = true
80+
enable_public_signup_user_exists_error = true
81+
}
82+
universal_login {
83+
colors {
84+
primary = "#0059d6"
85+
page_background = "#000000"
86+
}
87+
}
7088
}
7189
`

0 commit comments

Comments
 (0)