Skip to content

Commit 5de2c11

Browse files
authored
[ZT] Terraform IdP examples (#20183)
* one-time-pin * move import command * generic oidc examples * saml example * fix numbering
1 parent fc7542e commit 5de2c11

File tree

4 files changed

+138
-39
lines changed

4 files changed

+138
-39
lines changed

src/content/docs/cloudflare-one/identity/idp-integration/generic-oidc.mdx

Lines changed: 76 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,11 @@ sidebar:
55
order: 1
66
---
77

8-
import { Render } from "~/components";
8+
import { Tabs, TabItem, Render } from '~/components';
99

1010
Cloudflare Access has a generic OpenID Connect (OIDC) connector to help you integrate IdPs not already set in Access.
1111

12-
## Set up a generic OIDC
12+
## 1. Create an application in your identity provider
1313

1414
1. Visit your identity provider and create a client/app.
1515

@@ -31,21 +31,87 @@ Cloudflare Access has a generic OpenID Connect (OIDC) connector to help you inte
3131

3232
You can find these values on your identity provider's **OIDC discovery endpoint**. Some providers call this the "well-known URL".
3333

34-
4. In [Zero Trust](https://one.dash.cloudflare.com), go to **Settings** > **Authentication**.
34+
## 2. Add an OIDC provider to Zero Trust
3535

36-
5. Under **Login methods**, select **Add new**.
36+
<Tabs syncKey="dashPlusAPI"> <TabItem label="Dashboard">
3737

38-
6. Choose **OpenID Connect**..
38+
1. In [Zero Trust](https://one.dash.cloudflare.com), go to **Settings** > **Authentication**.
3939

40-
7. Name your identity provider and fill in the required fields with the information obtained in Step 3.
40+
2. Under **Login methods**, select **Add new**.
4141

42-
8. (Optional) Enable [Proof of Key Exchange (PKCE)](https://www.oauth.com/oauth2-servers/pkce/) if the protocol is supported by your IdP. PKCE will be performed on all login attempts.
42+
3. Choose **OpenID Connect**.
4343

44-
9. (Optional) To enable SCIM, refer to [Synchronize users and groups](#synchronize-users-and-groups).
44+
4. Name your identity provider and fill in the required fields with the information obtained in Step 3.
4545

46-
10. (Optional) Under **Optional configurations**, enter [custom OIDC claims](#oidc-claims) that you wish to add to users' identity. This information will be available in the [user identity endpoint](/cloudflare-one/identity/authorization-cookie/application-token/#user-identity).
46+
5. (Optional) Enable [Proof of Key Exchange (PKCE)](https://www.oauth.com/oauth2-servers/pkce/) if the protocol is supported by your IdP. PKCE will be performed on all login attempts.
4747

48-
11. Select **Save**.
48+
6. (Optional) To enable SCIM, refer to [Synchronize users and groups](#synchronize-users-and-groups).
49+
50+
7. (Optional) Under **Optional configurations**, enter [custom OIDC claims](#oidc-claims) that you wish to add to users' identity. This information will be available in the [user identity endpoint](/cloudflare-one/identity/authorization-cookie/application-token/#user-identity).
51+
52+
8. Select **Save**.
53+
54+
</TabItem> <TabItem label="API">
55+
56+
1. [Create an API token](/fundamentals/api/get-started/create-token/) with the following permissions:
57+
| Type | Item | Permission |
58+
| ------- | ---------------- | ---------- |
59+
| Account | Access: Organizations, Identity Providers, and Groups | Edit |
60+
61+
2. Make a `POST` request to the [Identity Providers](/api/resources/zero_trust/subresources/identity_providers/methods/create/) endpoint:
62+
63+
```sh
64+
curl https://api.cloudflare.com/client/v4/accounts/$ACCOUNT_ID/access/identity_providers \
65+
--header "Authorization: Bearer $CLOUDFLARE_API_TOKEN" \
66+
--data '{
67+
"name": "Generic OIDC example",
68+
"type": "oidc",
69+
"config": {
70+
"client_id": "<your client id>",
71+
"client_secret": "<your client secret>",
72+
"auth_url": "https://accounts.google.com/o/oauth2/auth",
73+
"token_url": "https://accounts.google.com/o/oauth2/token",
74+
"certs_url": "https://www.googleapis.com/oauth2/v3/certs",
75+
"pkce_enabled": false,
76+
"email_claim_name": "email",
77+
"claims": ["employeeID", "groups"],
78+
"scopes": ["openid", "email", "profile"]
79+
}
80+
}'
81+
```
82+
83+
</TabItem> <TabItem label="Terraform (v4)">
84+
85+
:::note[Provider versions]
86+
The following example requires Cloudflare provider version `>=4.40.0`.
87+
:::
88+
89+
1. Add the following permission to your [`cloudflare_api_token`](https://registry.terraform.io/providers/cloudflare/cloudflare/4.40.0/docs/resources/api_token):
90+
- `Access: Organizations, Identity Providers, and Groups Write`
91+
92+
2. Configure the [`cloudflare_zero_trust_access_identity_provider`](https://registry.terraform.io/providers/cloudflare/cloudflare/4.40.0/docs/resources/zero_trust_access_identity_provider) resource:
93+
94+
```tf
95+
resource "cloudflare_zero_trust_access_identity_provider" "generic_oidc_example" {
96+
account_id = var.cloudflare_account_id
97+
name = "Generic OIDC example"
98+
type = "oidc"
99+
config {
100+
client_id = "<your client id>"
101+
client_secret = "<your client secret>"
102+
auth_url = "https://accounts.google.com/o/oauth2/auth"
103+
token_url = "https://accounts.google.com/o/oauth2/token"
104+
certs_url = "https://www.googleapis.com/oauth2/v3/certs"
105+
pkce_enabled = false
106+
email_claim_name = "email"
107+
claims = ["employeeID", "groups"]
108+
scopes = ["openid", "email", "profile"]
109+
}
110+
}
111+
```
112+
</TabItem> </Tabs>
113+
114+
## 3. Test the connection
49115

50116
To test that your connection is working, go to **Authentication** > **Login methods** and select **Test** next to the login method you want to test. On success, a confirmation screen displays.
51117

@@ -92,23 +158,6 @@ Cloudflare Access extends support for multi-record OIDC claims. These claims are
92158

93159
Cloudflare Access does not support partial OIDC claim value references or OIDC scopes.
94160

95-
## Example API Configuration
96-
97-
```json
98-
{
99-
"config": {
100-
"client_id": "<your client id>",
101-
"client_secret": "<your client secret>",
102-
"auth_url": "https://accounts.google.com/o/oauth2/auth",
103-
"token_url": "https://accounts.google.com/o/oauth2/token",
104-
"certs_url": "https://www.googleapis.com/oauth2/v3/certs",
105-
"scopes": ["openid", "email", "profile"]
106-
},
107-
"type": "oidc",
108-
"name": "Generic Google"
109-
}
110-
```
111-
112161
## Supported algorithms for generic OIDC tokens
113162

114163
Cloudflare supports the following algorithms for verifying generic OIDC tokens:

src/content/docs/cloudflare-one/identity/idp-integration/generic-saml.mdx

Lines changed: 32 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ sidebar:
55
order: 2
66
---
77

8-
import { Render } from "~/components";
8+
import { Tabs, TabItem, Render } from '~/components';
99

1010
Cloudflare Zero Trust integrates with any identity provider that supports SAML 2.0. If your identity provider is not listed in the integration list of login methods in Zero Trust, it can be configured using SAML 2.0 (or OpenID if OIDC based). Generic SAML can also be used if you would like to pass additional SAML headers or claims for an IdP in the integration list.
1111

@@ -43,6 +43,9 @@ To download the SAML metadata file, copy-paste the metadata endpoint into a web
4343

4444
## 2. Add a SAML identity provider to Zero Trust
4545

46+
47+
<Tabs syncKey="dashPlusAPI"> <TabItem label="Dashboard">
48+
4649
1. In [Zero Trust](https://one.dash.cloudflare.com), go to **Settings** > **Authentication** > **Login methods**.
4750
2. Select **Add new** and select **SAML**.
4851
3. Choose a descriptive name for your identity provider.
@@ -51,6 +54,34 @@ To download the SAML metadata file, copy-paste the metadata endpoint into a web
5154
6. (Optional) Under **Optional configurations**, configure [additional SAML options](#optional-configurations).
5255
7. Select **Save**.
5356

57+
</TabItem> <TabItem label="Terraform (v4)">
58+
59+
:::note[Provider versions]
60+
The following example requires Cloudflare provider version `>=4.40.0`.
61+
:::
62+
63+
1. Add the following permission to your [`cloudflare_api_token`](https://registry.terraform.io/providers/cloudflare/cloudflare/4.40.0/docs/resources/api_token):
64+
- `Access: Organizations, Identity Providers, and Groups Write`
65+
66+
2. Configure the [`cloudflare_zero_trust_access_identity_provider`](https://registry.terraform.io/providers/cloudflare/cloudflare/4.40.0/docs/resources/zero_trust_access_identity_provider) resource:
67+
68+
```tf
69+
resource "cloudflare_zero_trust_access_identity_provider" "generic_saml_example" {
70+
account_id = var.cloudflare_account_id
71+
name = "Generic SAML example"
72+
type = "saml"
73+
config {
74+
sso_target_url = "https://example.com/1234/sso/saml"
75+
issuer_url = "https://example.com/1234"
76+
idp_public_cert = "-----BEGIN CERTIFICATE-----\nXXXXX\n-----END CERTIFICATE-----"
77+
sign_request = false
78+
email_attribute_name = "email"
79+
attributes = ["employeeID", "groups"]
80+
}
81+
}
82+
```
83+
</TabItem> </Tabs>
84+
5485
## 3. Test the connection
5586

5687
You can now [test the IdP integration](/cloudflare-one/identity/idp-integration/#test-idps-in-zero-trust). A success response should return the configured SAML attributes.

src/content/docs/cloudflare-one/identity/one-time-pin.mdx

Lines changed: 30 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ sidebar:
55
order: 2
66
---
77

8-
import { Render } from "~/components";
8+
import { Tabs, TabItem, Render } from '~/components';
99

1010
Cloudflare Access can send a one-time PIN (OTP) to approved email addresses as an alternative to integrating an identity provider. You can simultaneously configure OTP login and the identity provider of your choice to allow users to select their own authentication method.
1111

@@ -15,7 +15,35 @@ For example, if your team uses Okta but you are collaborating with someone outsi
1515

1616
## Set up OTP
1717

18-
<Render file="access/one-time-pin" />
18+
<Tabs syncKey="dashPlusAPI"> <TabItem label="Dashboard">
19+
20+
1. In [Zero Trust](https://one.dash.cloudflare.com), go to **Settings** > **Authentication**.
21+
2. Under **Login methods**, select **Add new**.
22+
3. Select **One-time PIN**.
23+
24+
</TabItem> <TabItem label="Terraform (v4)">
25+
26+
:::note[Provider versions]
27+
The following example requires Cloudflare provider version `>=4.40.0`.
28+
:::
29+
30+
1. Add the following permission to your [`cloudflare_api_token`](https://registry.terraform.io/providers/cloudflare/cloudflare/4.40.0/docs/resources/api_token):
31+
- `Access: Organizations, Identity Providers, and Groups Write`
32+
33+
2. Configure the [`cloudflare_zero_trust_access_identity_provider`](https://registry.terraform.io/providers/cloudflare/cloudflare/4.40.0/docs/resources/zero_trust_access_identity_provider) resource:
34+
35+
```tf
36+
resource "cloudflare_zero_trust_access_identity_provider" "onetimepin_login" {
37+
account_id = var.cloudflare_account_id
38+
name = "One-time PIN login"
39+
type = "onetimepin"
40+
}
41+
```
42+
</TabItem> </Tabs>
43+
44+
:::tip
45+
If your organization uses a third-party email scanning service (for example, Mimecast or Barracuda), add `[email protected]` to the email scanning allowlist.
46+
:::
1947

2048
To grant a user access to an application, simply add their email address to an [Access policy](/cloudflare-one/policies/access/policy-management/#create-a-policy).
2149

src/content/partials/cloudflare-one/access/one-time-pin.mdx

Lines changed: 0 additions & 9 deletions
This file was deleted.

0 commit comments

Comments
 (0)