Repository: cloudflare/cloudflare-go
Pull request #1260 (2023-04-05 11:05:22)

Add auto_redirect_to_identity to access organizations
Adds auto_redirect_to_identity  to access organizations. This field has been supported for a while now, but undocumented.

## Description

Describe your changes in detail through motivation and context. Why is
this change required? What problem does it solve? If it fixes an open
issue, link to the issue using GitHub's closing issues keywords[1].

## Has your change been tested?

automated test should be enough

## 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.
- [ X  ] My change requires a change to the documentation.
- [  X ] 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]: changelog detected :white_check_mark:
codecov-commenter: ## [Codecov](https://codecov.io/gh/cloudflare/cloudflare-go/pull/1260?src=pr&el=h1&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=cloudflare) Report
> Merging [#1260](https://codecov.io/gh/cloudflare/cloudflare-go/pull/1260?src=pr&el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=cloudflare) (b60b857) into [master](https://codecov.io/gh/cloudflare/cloudflare-go/commit/0c3db86282352878154a63c9bc67764dfded0780?el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=cloudflare) (0c3db86) will **increase** coverage by `0.07%`.
> The diff coverage is `48.27%`.

> :exclamation: Current head b60b857 differs from pull request most recent head ae7ec32. Consider uploading reports for the commit ae7ec32 to get more accurate results

```diff
@@            Coverage Diff             @@
##           master    #1260      +/-   ##
==========================================
+ Coverage   49.23%   49.31%   +0.07%     
==========================================
  Files         131      131              
  Lines       12665    12686      +21     
==========================================
+ Hits         6236     6256      +20     
+ Misses       4988     4981       -7     
- Partials     1441     1449       +8     
```


| [Impacted Files](https://codecov.io/gh/cloudflare/cloudflare-go/pull/1260?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=cloudflare) | Coverage Δ | |
|---|---|---|
| [access\_organization.go](https://codecov.io/gh/cloudflare/cloudflare-go/pull/1260?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=cloudflare#diff-YWNjZXNzX29yZ2FuaXphdGlvbi5nbw==) | `64.70% <ø> (ø)` | |
| [access\_policy.go](https://codecov.io/gh/cloudflare/cloudflare-go/pull/1260?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=cloudflare#diff-YWNjZXNzX3BvbGljeS5nbw==) | `76.31% <ø> (ø)` | |
| [errors.go](https://codecov.io/gh/cloudflare/cloudflare-go/pull/1260?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=cloudflare#diff-ZXJyb3JzLmdv) | `40.78% <ø> (ø)` | |
| [rulesets.go](https://codecov.io/gh/cloudflare/cloudflare-go/pull/1260?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=cloudflare#diff-cnVsZXNldHMuZ28=) | `34.86% <0.00%> (-0.12%)` | :arrow_down: |
| [ssl.go](https://codecov.io/gh/cloudflare/cloudflare-go/pull/1260?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=cloudflare#diff-c3NsLmdv) | `72.72% <ø> (ø)` | |
| [zone.go](https://codecov.io/gh/cloudflare/cloudflare-go/pull/1260?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=cloudflare#diff-em9uZS5nbw==) | `41.70% <50.00%> (+2.59%)` | :arrow_up: |

Help us with your feedback. Take ten seconds to tell us [how you rate us](https://about.codecov.io/nps?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=cloudflare). Have a feature suggestion? [Share it here.](https://app.codecov.io/gh/feedback/?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=cloudflare)


Patch:
diff --git a/.changelog/1260.txt b/.changelog/1260.txt
new file mode 100644
index 000000000..806345d46
--- /dev/null
+++ b/.changelog/1260.txt
@@ -0,0 +1,3 @@
+```release-note:enhancement
+access: Add `auto_redirect_to_identity` flag to Access organizations
+```
diff --git a/access_organization.go b/access_organization.go
index f4de4a7b6..ff2fef9de 100644
--- a/access_organization.go
+++ b/access_organization.go
@@ -18,6 +18,7 @@ type AccessOrganization struct {
 	IsUIReadOnly                   *bool                         `json:"is_ui_read_only,omitempty"`
 	UIReadOnlyToggleReason         string                        `json:"ui_read_only_toggle_reason,omitempty"`
 	UserSeatExpirationInactiveTime string                        `json:"user_seat_expiration_inactive_time,omitempty"`
+	AutoRedirectToIdentity         *bool                         `json:"auto_redirect_to_identity,omitempty"`
 }
 
 // AccessOrganizationLoginDesign represents the login design options.


Test patch:
diff --git a/access_organization_test.go b/access_organization_test.go
index 7d6cfa60e..3ea79970a 100644
--- a/access_organization_test.go
+++ b/access_organization_test.go
@@ -28,6 +28,7 @@ func TestAccessOrganization(t *testing.T) {
 				"auth_domain": "test.cloudflareaccess.com",
 				"is_ui_read_only": false,
 				"user_seat_expiration_inactive_time": "720h",
+				"auto_redirect_to_identity": true,
 				"login_design": {
 					"background_color": "#c5ed1b",
 					"logo_path": "https://example.com/logo.png",
@@ -57,6 +58,7 @@ func TestAccessOrganization(t *testing.T) {
 		},
 		IsUIReadOnly:                   BoolPtr(false),
 		UserSeatExpirationInactiveTime: "720h",
+		AutoRedirectToIdentity:         BoolPtr(true),
 	}
 
 	mux.HandleFunc("/accounts/"+testAccountID+"/access/organizations", handler)