Repository: cloudflare/cloudflare-go
Pull request #1281 (2023-05-16 16:11:36)

Add support for self_hosted_domains in access applications
The ZT access team recently shipped support for multiple domains in self hosted apps.
The array self_hosted_domains defined the set of domains that access will match this app for.


## Has your change been tested?
unit tests

## Screenshots (if appropriate):

## Types of changes

What sort of change does your code introduce/modify?

- [ ] Bug fix (non-breaking change which fixes an issue)
- [X] New feature (non-breaking change which adds functionality)
- [ ] Breaking change (fix or feature that would cause existing functionality to change)

## Checklist:

- [X] My code follows the code style of this project.
- [ ] My change requires a change to the documentation.
- [ ] I have updated the documentation accordingly.
- [X] I have added tests to cover my changes.
- [X] All new and existing tests passed.
- [X] This change is using publicly documented (api.cloudflare.com or developers.cloudflare.com) and stable APIs.

[1]: https://help.github.com/articles/closing-issues-using-keywords/


github-actions[bot]: Oops! It looks like no changelog entry is attached to this PR. Please include a release note as described in https://github.com/cloudflare/cloudflare-go/blob/master/docs/changelog-process.md.

Example: 

~~~
```release-note:TYPE
Release note
```
~~~

If you do not require a release note to be included, please add the `workflow/skip-changelog-entry` label.

Patch:
diff --git a/.changelog/1281.txt b/.changelog/1281.txt
new file mode 100644
index 000000000..9fb7f58d3
--- /dev/null
+++ b/.changelog/1281.txt
@@ -0,0 +1,3 @@
+```release-note:enhancement
+Added self_hosted_domains to access apps
+```
diff --git a/access_application.go b/access_application.go
index e627fca27..bd49cf2c3 100644
--- a/access_application.go
+++ b/access_application.go
@@ -31,6 +31,7 @@ type AccessApplication struct {
 	LogoURL                 string                         `json:"logo_url,omitempty"`
 	AUD                     string                         `json:"aud,omitempty"`
 	Domain                  string                         `json:"domain"`
+	SelfHostedDomains       []string                       `json:"self_hosted_domains"`
 	Type                    AccessApplicationType          `json:"type,omitempty"`
 	SessionDuration         string                         `json:"session_duration,omitempty"`
 	SameSiteCookieAttribute string                         `json:"same_site_cookie_attribute,omitempty"`


Test patch:
diff --git a/access_application_test.go b/access_application_test.go
index ce488347d..4275f4525 100644
--- a/access_application_test.go
+++ b/access_application_test.go
@@ -116,6 +116,7 @@ func TestAccessApplication(t *testing.T) {
 				"aud": "737646a56ab1df6ec9bddc7e5ca84eaf3b0768850f3ffb5d74f1534911fe3893",
 				"name": "Admin Site",
 				"domain": "test.example.com/admin",
+				"self_hosted_domains": ["test.example.com/admin", "test.example.com/admin2"],
 				"type": "self_hosted",
 				"session_duration": "24h",
 				"allowed_idps": ["f174e90a-fafe-4643-bbbc-4a0ed4fc8415"],
@@ -144,6 +145,7 @@ func TestAccessApplication(t *testing.T) {
 		AUD:                     "737646a56ab1df6ec9bddc7e5ca84eaf3b0768850f3ffb5d74f1534911fe3893",
 		Name:                    "Admin Site",
 		Domain:                  "test.example.com/admin",
+		SelfHostedDomains:       []string{"test.example.com/admin", "test.example.com/admin2"},
 		Type:                    "self_hosted",
 		SessionDuration:         "24h",
 		AllowedIdps:             []string{"f174e90a-fafe-4643-bbbc-4a0ed4fc8415"},
@@ -194,6 +196,7 @@ func TestCreateAccessApplications(t *testing.T) {
 				"aud": "737646a56ab1df6ec9bddc7e5ca84eaf3b0768850f3ffb5d74f1534911fe3893",
 				"name": "Admin Site",
 				"domain": "test.example.com/admin",
+				"self_hosted_domains": ["test.example.com/admin", "test.example.com/admin2"],
 				"type": "self_hosted",
 				"session_duration": "24h",
 				"allowed_idps": ["f174e90a-fafe-4643-bbbc-4a0ed4fc8415"],
@@ -216,6 +219,7 @@ func TestCreateAccessApplications(t *testing.T) {
 		ID:                     "480f4f69-1a28-4fdd-9240-1ed29f0ac1db",
 		Name:                   "Admin Site",
 		Domain:                 "test.example.com/admin",
+		SelfHostedDomains:      []string{"test.example.com/admin", "test.example.com/admin2"},
 		Type:                   "self_hosted",
 		SessionDuration:        "24h",
 		AUD:                    "737646a56ab1df6ec9bddc7e5ca84eaf3b0768850f3ffb5d74f1534911fe3893",
@@ -275,6 +279,7 @@ func TestUpdateAccessApplication(t *testing.T) {
 				"aud": "737646a56ab1df6ec9bddc7e5ca84eaf3b0768850f3ffb5d74f1534911fe3893",
 				"name": "Admin Site",
 				"domain": "test.example.com/admin",
+				"self_hosted_domains": ["test.example.com/admin", "test.example.com/admin2"],
 				"type": "self_hosted",
 				"session_duration": "24h",
 				"allowed_idps": ["f174e90a-fafe-4643-bbbc-4a0ed4fc8415"],
@@ -297,6 +302,7 @@ func TestUpdateAccessApplication(t *testing.T) {
 		ID:                     "480f4f69-1a28-4fdd-9240-1ed29f0ac1db",
 		Name:                   "Admin Site",
 		Domain:                 "test.example.com/admin",
+		SelfHostedDomains:      []string{"test.example.com/admin", "test.example.com/admin2"},
 		Type:                   "self_hosted",
 		SessionDuration:        "24h",
 		AUD:                    "737646a56ab1df6ec9bddc7e5ca84eaf3b0768850f3ffb5d74f1534911fe3893",