Skip to content

Commit

Permalink
Added new parameter to waf_entity_url resource
Browse files Browse the repository at this point in the history
  • Loading branch information
urohit011 committed May 3, 2024
1 parent 0090fa4 commit bc24218
Show file tree
Hide file tree
Showing 3 changed files with 76 additions and 3 deletions.
47 changes: 47 additions & 0 deletions bigip/datasource_bigip_waf_entity_url.go
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,35 @@ func dataSourceBigipWafEntityUrl() *schema.Resource {
},
},
},
"cross_domain_allowed_origins": {
Type: schema.TypeList,
Optional: true,
Elem: &schema.Resource{
Schema: map[string]*schema.Schema{
"include_subdomains": {
Type: schema.TypeBool,
Optional: true,
Default: false,
Description: "Specifies whether the subdomains are allowed to receive data from the web application.",
},
"origin_name": {
Type: schema.TypeString,
Required: true,
Description: "Specifies the name of the origin with which you want to share your data.",
},
"origin_port": {
Type: schema.TypeString,
Required: true,
Description: "Specifies the port that other web applications are allowed to use to request data from your web application.",
},
"origin_protocol": {
Type: schema.TypeString,
Required: true,
Description: "Specifies the protocol that other web applications are allowed to use to request data from your web application.",
},
},
},
},
"signature_overrides_disable": {
Type: schema.TypeList,
Optional: true,
Expand Down Expand Up @@ -131,6 +160,24 @@ func dataSourceBigipWafEntityUrlRead(ctx context.Context, d *schema.ResourceData
urlJson.MethodsOverrideOnUrlCheck = true
}

allowedOriginsCount := d.Get("cross_domain_allowed_origins.#").(int)
if allowedOriginsCount > 0 {
urlJson.HTML5CrossOriginRequestsEnforcement.EnforcementMode = "enforce"

allowedOrigins := make([]bigip.WafUrlAllowedOrigins, 0, allowedOriginsCount)

Check failure on line 167 in bigip/datasource_bigip_waf_entity_url.go

View workflow job for this annotation

GitHub Actions / golint

undefined: bigip.WafUrlAllowedOrigins

Check failure on line 167 in bigip/datasource_bigip_waf_entity_url.go

View workflow job for this annotation

GitHub Actions / golint

undefined: bigip.WafUrlAllowedOrigins
for i := 0; i < allowedOriginsCount; i++ {
var a bigip.WafUrlAllowedOrigins

Check failure on line 169 in bigip/datasource_bigip_waf_entity_url.go

View workflow job for this annotation

GitHub Actions / golint

undefined: bigip.WafUrlAllowedOrigins

Check failure on line 169 in bigip/datasource_bigip_waf_entity_url.go

View workflow job for this annotation

GitHub Actions / golint

undefined: bigip.WafUrlAllowedOrigins
prefix := fmt.Sprintf("cross_domain_allowed_origins.%d", i)
a.IncludeSubdomains = d.Get(prefix + ".include_subdomains").(bool)
a.OriginName = d.Get(prefix + ".origin_name").(string)
a.OriginPort = d.Get(prefix + ".origin_port").(string)
a.OriginProtocol = d.Get(prefix + ".origin_protocol").(string)
allowedOrigins = append(allowedOrigins, a)
}

urlJson.HTML5CrossOriginRequestsEnforcement.AllowerOrigins = allowedOrigins

Check failure on line 178 in bigip/datasource_bigip_waf_entity_url.go

View workflow job for this annotation

GitHub Actions / golint

urlJson.HTML5CrossOriginRequestsEnforcement.AllowerOrigins undefined (type struct{EnforcementMode string "json:\"enforcementMode,omitempty\""} has no field or method AllowerOrigins)) (typecheck)

Check failure on line 178 in bigip/datasource_bigip_waf_entity_url.go

View workflow job for this annotation

GitHub Actions / golint

urlJson.HTML5CrossOriginRequestsEnforcement.AllowerOrigins undefined (type struct{EnforcementMode string "json:\"enforcementMode,omitempty\""} has no field or method AllowerOrigins) (typecheck)
}

jsonString, err := json.Marshal(urlJson)
if err != nil {
return diag.FromErr(err)
Expand Down
18 changes: 18 additions & 0 deletions docs/data-sources/bigip_waf_entity_url.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,18 @@ data "bigip_waf_entity_url" "WAFURL1" {
allow = true
method = "BDELETE"
}
cross_domain_allowed_origins {
include_subdomains = true
origin_name = "app1.com"
origin_port = "80"
origin_protocol = "http"
}
cross_domain_allowed_origins {
include_subdomains = true
origin_name = "app2.com"
origin_port = "443"
origin_protocol = "http"
}
}
```
Expand All @@ -46,6 +58,12 @@ data "bigip_waf_entity_url" "WAFURL1" {
* `method_overrides` - (Optional) A list of methods that are allowed or disallowed for a specific URL.
* `allow` - (Required) Specifies that the system allows or disallows a method for this URL
* `method` - (Required) Specifies an HTTP method.
* `cross_domain_allowed_origins` - (Optional) A list of options that enables your web-application to share data with a website hosted on a
different domain.
* `include_subdomains` - (Required) Determines whether the subdomains are allowed to receive data from the web application.
* `origin_name` - (Required) Specifies the name of the origin with which you want to share your data.
* `origin_port` - (Required) Specifies the port that other web applications are allowed to use to request data from your web application.
* `origin_protocol` - (Required) Specifies the protocol that other web applications are allowed to use to request data from your web application.


## Attributes Reference
Expand Down
14 changes: 11 additions & 3 deletions vendor/github.com/f5devcentral/go-bigip/awaf.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit bc24218

Please sign in to comment.