Skip to content

Commit

Permalink
AUTH-5608 added warp auth fields to access organizations and apps
Browse files Browse the repository at this point in the history
  • Loading branch information
rkernscloudflaretest committed Feb 5, 2024
1 parent 34a4599 commit 3e1dca8
Show file tree
Hide file tree
Showing 7 changed files with 38 additions and 1 deletion.
7 changes: 7 additions & 0 deletions .changelog/3103.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
```release-note:enhancement
resource/cloudflare_access_application: adds the ability to set allow_authenticate_via_warp.
```

```release-note:enhancement
resource/cloudflare_access_organization: adds the ability to set allow_authenticate_via_warp and warp_auth_session_duration.
```
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ func resourceCloudflareAccessApplicationCreate(ctx context.Context, d *schema.Re
SkipInterstitial: cloudflare.BoolPtr(d.Get("skip_interstitial").(bool)),
AppLauncherVisible: cloudflare.BoolPtr(d.Get("app_launcher_visible").(bool)),
ServiceAuth401Redirect: cloudflare.BoolPtr(d.Get("service_auth_401_redirect").(bool)),
AllowAuthenticateViaWarp: cloudflare.BoolPtr(d.Get("allow_authenticate_via_warp").(bool)),

Check failure on line 56 in internal/sdkv2provider/resource_cloudflare_access_application.go

View workflow job for this annotation

GitHub Actions / test

unknown field AllowAuthenticateViaWarp in struct literal of type cloudflare.CreateAccessApplicationParams

Check failure on line 56 in internal/sdkv2provider/resource_cloudflare_access_application.go

View workflow job for this annotation

GitHub Actions / tfproviderlint (ubuntu-latest)

unknown field AllowAuthenticateViaWarp in struct literal of type cloudflare.CreateAccessApplicationParams

Check failure on line 56 in internal/sdkv2provider/resource_cloudflare_access_application.go

View workflow job for this annotation

GitHub Actions / tfproviderlint (ubuntu-latest)

unknown field AllowAuthenticateViaWarp in struct literal of type cloudflare.CreateAccessApplicationParams
}

if value, ok := d.GetOk("allowed_idps"); ok {
Expand Down Expand Up @@ -159,6 +160,7 @@ func resourceCloudflareAccessApplicationRead(ctx context.Context, d *schema.Reso
d.Set("bg_color", accessApplication.AccessAppLauncherCustomization.BackgroundColor)
d.Set("header_bg_color", accessApplication.AccessAppLauncherCustomization.HeaderBackgroundColor)
d.Set("app_launcher_logo_url", accessApplication.AccessAppLauncherCustomization.LogoURL)
d.Set("allow_authenticate_via_warp", accessApplication.AllowAuthenticateViaWarp)

Check failure on line 163 in internal/sdkv2provider/resource_cloudflare_access_application.go

View workflow job for this annotation

GitHub Actions / test

accessApplication.AllowAuthenticateViaWarp undefined (type cloudflare.AccessApplication has no field or method AllowAuthenticateViaWarp)

Check failure on line 163 in internal/sdkv2provider/resource_cloudflare_access_application.go

View workflow job for this annotation

GitHub Actions / tfproviderlint (ubuntu-latest)

accessApplication.AllowAuthenticateViaWarp undefined (type cloudflare.AccessApplication has no field or method AllowAuthenticateViaWarp)

Check failure on line 163 in internal/sdkv2provider/resource_cloudflare_access_application.go

View workflow job for this annotation

GitHub Actions / tfproviderlint (ubuntu-latest)

accessApplication.AllowAuthenticateViaWarp undefined (type cloudflare.AccessApplication has no field or method AllowAuthenticateViaWarp)

if _, ok := d.GetOk("footer_links"); ok {
footerLinks := convertFooterLinksStructToSchema(d, accessApplication.AccessAppLauncherCustomization.FooterLinks)
Expand Down Expand Up @@ -213,6 +215,7 @@ func resourceCloudflareAccessApplicationUpdate(ctx context.Context, d *schema.Re
SkipInterstitial: cloudflare.BoolPtr(d.Get("skip_interstitial").(bool)),
AppLauncherVisible: cloudflare.BoolPtr(d.Get("app_launcher_visible").(bool)),
ServiceAuth401Redirect: cloudflare.BoolPtr(d.Get("service_auth_401_redirect").(bool)),
AllowAuthenticateViaWarp: cloudflare.BoolPtr(d.Get("allow_authenticate_via_warp").(bool)),

Check failure on line 218 in internal/sdkv2provider/resource_cloudflare_access_application.go

View workflow job for this annotation

GitHub Actions / test

unknown field AllowAuthenticateViaWarp in struct literal of type cloudflare.UpdateAccessApplicationParams

Check failure on line 218 in internal/sdkv2provider/resource_cloudflare_access_application.go

View workflow job for this annotation

GitHub Actions / tfproviderlint (ubuntu-latest)

unknown field AllowAuthenticateViaWarp in struct literal of type cloudflare.UpdateAccessApplicationParams

Check failure on line 218 in internal/sdkv2provider/resource_cloudflare_access_application.go

View workflow job for this annotation

GitHub Actions / tfproviderlint (ubuntu-latest)

unknown field AllowAuthenticateViaWarp in struct literal of type cloudflare.UpdateAccessApplicationParams
}

if appType != "saas" {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,7 @@ func TestAccCloudflareAccessApplication_BasicZone(t *testing.T) {
resource.TestCheckResourceAttr(name, "cors_headers.#", "0"),
resource.TestCheckResourceAttr(name, "saas_app.#", "0"),
resource.TestCheckResourceAttr(name, "auto_redirect_to_identity", "false"),
resource.TestCheckResourceAttr(name, "allow_authenticate_via_warp", "true"),
),
},
},
Expand Down Expand Up @@ -126,6 +127,7 @@ func TestAccCloudflareAccessApplication_BasicAccount(t *testing.T) {
resource.TestCheckResourceAttr(name, "cors_headers.#", "0"),
resource.TestCheckResourceAttr(name, "sass_app.#", "0"),
resource.TestCheckResourceAttr(name, "auto_redirect_to_identity", "false"),
resource.TestCheckResourceAttr(name, "allow_authenticate_via_warp", "true"),
),
},
},
Expand Down Expand Up @@ -641,6 +643,7 @@ resource "cloudflare_access_application" "%[1]s" {
type = "self_hosted"
session_duration = "24h"
auto_redirect_to_identity = false
allow_authenticate_via_warp = true
}
`, rnd, domain, identifier.Type, identifier.Identifier)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,8 @@ func resourceCloudflareAccessOrganizationRead(ctx context.Context, d *schema.Res
d.Set("user_seat_expiration_inactive_time", organization.UserSeatExpirationInactiveTime)
d.Set("auto_redirect_to_identity", organization.AutoRedirectToIdentity)
d.Set("session_duration", organization.SessionDuration)
d.Set("warp_auth_session_duration", organization.WarpAuthSessionDuration)

Check failure on line 64 in internal/sdkv2provider/resource_cloudflare_access_organization.go

View workflow job for this annotation

GitHub Actions / test

organization.WarpAuthSessionDuration undefined (type cloudflare.AccessOrganization has no field or method WarpAuthSessionDuration)

Check failure on line 64 in internal/sdkv2provider/resource_cloudflare_access_organization.go

View workflow job for this annotation

GitHub Actions / tfproviderlint (ubuntu-latest)

organization.WarpAuthSessionDuration undefined (type cloudflare.AccessOrganization has no field or method WarpAuthSessionDuration)
d.Set("allow_authenticate_via_warp", organization.AllowAuthenticateViaWarp)

Check failure on line 65 in internal/sdkv2provider/resource_cloudflare_access_organization.go

View workflow job for this annotation

GitHub Actions / test

organization.AllowAuthenticateViaWarp undefined (type cloudflare.AccessOrganization has no field or method AllowAuthenticateViaWarp)

Check failure on line 65 in internal/sdkv2provider/resource_cloudflare_access_organization.go

View workflow job for this annotation

GitHub Actions / tfproviderlint (ubuntu-latest)

organization.AllowAuthenticateViaWarp undefined (type cloudflare.AccessOrganization has no field or method AllowAuthenticateViaWarp)

loginDesign := convertLoginDesignStructToSchema(ctx, d, &organization.LoginDesign)
if loginDesignErr := d.Set("login_design", loginDesign); loginDesignErr != nil {
Expand All @@ -87,6 +89,8 @@ func resourceCloudflareAccessOrganizationUpdate(ctx context.Context, d *schema.R
UserSeatExpirationInactiveTime: d.Get("user_seat_expiration_inactive_time").(string),
AutoRedirectToIdentity: cloudflare.BoolPtr(d.Get("auto_redirect_to_identity").(bool)),
SessionDuration: cloudflare.StringPtr(d.Get("session_duration").(string)),
WarpAuthSessionDuration: cloudflare.StringPtr(d.Get("warp_auth_session_duration").(string)),

Check failure on line 92 in internal/sdkv2provider/resource_cloudflare_access_organization.go

View workflow job for this annotation

GitHub Actions / test

unknown field WarpAuthSessionDuration in struct literal of type cloudflare.UpdateAccessOrganizationParams

Check failure on line 92 in internal/sdkv2provider/resource_cloudflare_access_organization.go

View workflow job for this annotation

GitHub Actions / tfproviderlint (ubuntu-latest)

unknown field WarpAuthSessionDuration in struct literal of type cloudflare.UpdateAccessOrganizationParams
AllowAuthenticateViaWarp: cloudflare.BoolPtr(d.Get("allow_authenticate_via_warp").(bool)),

Check failure on line 93 in internal/sdkv2provider/resource_cloudflare_access_organization.go

View workflow job for this annotation

GitHub Actions / test

unknown field AllowAuthenticateViaWarp in struct literal of type cloudflare.UpdateAccessOrganizationParams

Check failure on line 93 in internal/sdkv2provider/resource_cloudflare_access_organization.go

View workflow job for this annotation

GitHub Actions / tfproviderlint (ubuntu-latest)

unknown field AllowAuthenticateViaWarp in struct literal of type cloudflare.UpdateAccessOrganizationParams
}
loginDesign := convertLoginDesignSchemaToStruct(d)
updatedAccessOrganization.LoginDesign = *loginDesign
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,8 @@ func TestAccCloudflareAccessOrganization(t *testing.T) {
resource.TestCheckResourceAttr(name, "login_design.0.header_text", "My header text"),
resource.TestCheckResourceAttr(name, "login_design.0.footer_text", "My footer text"),
resource.TestCheckResourceAttr(name, "session_duration", "12h"),
resource.TestCheckResourceAttr(name, "warp_auth_session_duration", "36h"),
resource.TestCheckResourceAttr(name, "allow_authenticate_via_warp", "false"),
),
ResourceName: name,
ImportState: true,
Expand Down Expand Up @@ -86,6 +88,8 @@ func testAccCloudflareAccessOrganizationConfigBasic(rnd, accountID string) strin
user_seat_expiration_inactive_time = "1460h"
auto_redirect_to_identity = false
session_duration = "12h"
warp_auth_session_duration = "36h"
allow_authenticate_via_warp = false
login_design {
background_color = "#FFFFFF"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,10 @@ package sdkv2provider

import (
"fmt"
"github.com/cloudflare/cloudflare-go"
"time"

"github.com/cloudflare/cloudflare-go"

"github.com/cloudflare/terraform-provider-cloudflare/internal/consts"
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/validation"
Expand Down Expand Up @@ -386,6 +387,11 @@ func resourceCloudflareAccessApplicationSchema() map[string]*schema.Schema {
},
},
},
"allow_authenticate_via_warp": {
Type: schema.TypeBool,
Optional: true,
Description: "When set to true, users can authenticate to this application using their WARP session. When set to false this application will always require direct IdP authentication. This setting always overrides the organization setting for WARP authentication.",
},
}
}

Expand Down
10 changes: 10 additions & 0 deletions internal/sdkv2provider/schema_cloudflare_access_organization.go
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,16 @@ func resourceCloudflareAccessOrganizationSchema() map[string]*schema.Schema {
},
},
},
"allow_authenticate_via_warp": {
Type: schema.TypeBool,
Optional: true,
Description: "When set to true, users can authenticate via WARP for any application in your organization. Application settings will take precedence over this value.",
},
"warp_auth_session_duration": {
Type: schema.TypeString,
Optional: true,
Description: "The amount of time that tokens issued for applications will be valid. Must be in the format 30m or 2h45m. Valid time units are: m, h.",
},
}
}

Expand Down

0 comments on commit 3e1dca8

Please sign in to comment.