Skip to content

Commit 826eef6

Browse files
author
Adam Ciarciński
committed
Extend external OpenID docs including Zitadel
1 parent e831755 commit 826eef6

File tree

5 files changed

+59
-45
lines changed

5 files changed

+59
-45
lines changed

.gitbook/assets/zitadel1.png

313 KB
Loading

.gitbook/assets/zitadel2.png

283 KB
Loading

.gitbook/assets/zitadel3.png

101 KB
Loading

.gitbook/assets/zitadel4.png

74.2 KB
Loading

enterprise/all-enteprise-features/external-openid-providers.md

Lines changed: 59 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -4,22 +4,22 @@ icon: up-right-from-square
44

55
# External OpenID providers
66

7-
Defguard, [apart from being an identity provider itself](../../admin-and-features/features-and-configuration/openid-connect/), supports logging in through external OpenID providers. Currently, there are two built in providers (Google and Microsoft) but there is also an option to specify a custom provider.
7+
Defguard, [apart from being an identity provider itself](../../admin-and-features/features-and-configuration/openid-connect/), supports logging in through external OpenID providers. Currently, there are two built-in providers (Google and Microsoft), but there is also an option to specify a custom one.
88

99
### Prerequisites
1010

11-
In order to configure this feature, you will need to obtain the following values from your provider of choice:
11+
In order to configure this feature, the following information is needed to be obtained from a provider of choice:
1212

13-
* `Client ID` 
14-
* `Client Secret`
15-
* (optional, only if you are using a custom provider) Your provider's base URL
16-
* (optional, only if you are using Microsoft as your provider) `Tenant ID`
13+
* Client ID
14+
* Client secret
15+
* (for custom provider) Your provider's base URL
16+
* (for Microsoft as provider) Tenant ID
1717

1818
If you don't know where to find those values, go to the [Examples](external-openid-providers.md#examples) section, where you will find an example setup for the built-in providers.
1919

2020
#### Base URL
2121

22-
The base URL is used to discover all the necessary provider's endpoints which will be used during the authorization flow. Usually, all required information resides at `<PROVIDER_BASE_URL>/.well-known/openid-configuration`. Hence, in order for defguard to discover the endpoints, you need to provide it with only the base URL value, as the rest (well-known part) is appended automatically. The base URL value should be provided without the trailing slash, some examples:
22+
The base URL is used to discover all the necessary provider's endpoints which will be used during the authorization flow. Usually, all required information resides at `<PROVIDER_BASE_URL>/.well-known/openid-configuration`. Hence, in order for Defguard to discover the endpoints, you need to provide it with only the base URL value, and the rest (the _well-known_ part) is appended automatically. The base URL should be provided without the trailing slash, some examples:
2323

2424
* `https://accounts.google.com`
2525
* `https:://login.microsoftonline.com/<TENANT_ID>/v2.0`
@@ -35,47 +35,44 @@ In order to configure the external OpenID provider login, go to the settings in
3535

3636
<figure><img src="../../.gitbook/assets/image (29).png" alt=""><figcaption></figcaption></figure>
3737

38-
Everything related to the external OpenID configuration can be found in the OpenID tab of the settings page. First thing to do here would be to pick your provider using the dropdown menu under the "Provider" label. Next, fill out the required information with values acquired from your provider. If you picked "Microsoft" or "Custom", make sure to also make corresponding changes in the "Base URL" field. After you are done, click "Save changes" to keep your changes.&#x20;
38+
Everything related to the external OpenID configuration can be found in the OpenID tab of the settings page. First thing to do here would be to pick your provider using the dropdown menu under the "Provider" label. Next, fill out the required information with values acquired from your provider. If you picked "Microsoft" or "Custom", make sure to also make corresponding changes in the "Base URL" field. After you are done, click "Save changes" to keep your changes.
3939

40-
You may have also noticed the checkbox option on the right. By default, when a new user (i.e. a user of whom DefGuard has no record) logs in for the first time using the external OpenID feature, their account in created automatically, based on the personal details (name, last name, email) received from the external provider. If you'd like to manually manage such users, uncheck the checkbox. Now users will need to be manually created in Defguard first in order to login.&#x20;
40+
You may have also noticed the checkbox option on the right. By default, when a new user (i.e. a user of whom Defguard has no record) logs in for the first time using the external OpenID feature, its account is created automatically, based on the personal details (first name, last name, email) received from the external provider. If you'd like to manually manage such users, uncheck the checkbox. Now users will need to be manually created in Defguard first in order to log in.
4141

4242
### Examples
4343

4444
#### Google
4545

4646
[Full Google documentation](https://developers.google.com/identity/openid-connect/openid-connect)
4747

48-
1. The Google OpenID connect can be configured in the [Google Cloud Console](https://console.cloud.google.com)
49-
2. If you don't have any project setup already (or you want to create a new one for this purpose), create it by clicking the dropdown menu here:
48+
1. The Google OpenID Connect can be configured in the [Google Cloud Console](https://console.cloud.google.com)
49+
2. If you don't have any project setup already (or you want to create a new one for this purpose), create it by clicking the dropdown menu here:
5050

5151
<figure><img src="../../.gitbook/assets/image (31).png" alt="" width="312"><figcaption></figcaption></figure>
5252

5353
If you already have project, make sure to select it in the above dropdown menu.
54-
3. Now, navigate to [`APIs & Services`](https://console.cloud.google.com/apis)&#x20;
54+
3. Now, navigate to [`APIs & Services`](https://console.cloud.google.com/apis)
5555
4. We will focus on the consent screen first, select `OAuth consent screen`
56-
5. &#x20;Pick the User Type according to your needs, this example will focus on the internal type
56+
5. Pick the User Type according to your needs, this example will focus on the internal type
5757

5858
<figure><img src="../../.gitbook/assets/image (32).png" alt=""><figcaption></figcaption></figure>
5959

60-
61-
6. Fill in all required details. Make sure to fill the correct domain. This should be the top domain under which your Defguard dashboard can be accessed, not the subdomain (e.g. `defguard.example.com` -> `example.com`).&#x20;
60+
6. Fill in all required details. Make sure to fill the correct domain. This should be the top domain under which your Defguard dashboard can be accessed, not the subdomain (e.g. `defguard.example.com` -> `example.com`).
6261
7. On the scopes config screen, click `ADD OR REMOVE SCOPES`, Defguard requires at least the following scopes:
6362

6463
<figure><img src="../../.gitbook/assets/image (34).png" alt=""><figcaption></figcaption></figure>
6564

66-
6765
8. Proceed until the end and return to the OAuth consent screen dashboard.
68-
9. Now, go to [`Credentials`](https://console.cloud.google.com/apis/credentials), click `CREATE CREDENTIALS` and choose `OAuth client ID`&#x20;
66+
9. Now, go to [`Credentials`](https://console.cloud.google.com/apis/credentials), click `CREATE CREDENTIALS` and choose `OAuth client ID`
6967

7068
<figure><img src="../../.gitbook/assets/image (35).png" alt=""><figcaption></figcaption></figure>
7169

72-
73-
10. On the next screen, fill out all required information:\
74-
70+
10. On the next screen, fill out all required information:
7571

7672
<figure><img src="../../.gitbook/assets/obraz (3).png" alt=""><figcaption></figcaption></figure>
7773

7874
Make sure to select "Web application" as the application type. The other thing to note here is the redirect URI. It is the URI to which the user will be redirected from the external provider's authorization. This URI is in the form of `<DEFGUARD_DASHBOARD_URL>/auth/callback`. Replace `<DEFGUARD_DASHBOARD_URL>` with the URL under which your dashboard is accessible, e.g. `https://defguard.example.com`.
75+
7976
11. After you proceed further, you will be presented with a popup containing your `Client ID` and `Client Secret`, copy them and paste on the Defguard OpenID configuration page.
8077

8178
<figure><img src="../../.gitbook/assets/settings.png" alt=""><figcaption></figcaption></figure>
@@ -84,69 +81,86 @@ You may have also noticed the checkbox option on the right. By default, when a n
8481

8582
1. Go to [https://portal.azure.com/](https://portal.azure.com)
8683
2. Navigate to Microsoft Entra ID
87-
3. In the Microsoft Entra ID, click Manage and select App registrations from the menu on the left.\
88-
\
89-
84+
3. In the Microsoft Entra ID, click Manage and select App registrations from the menu on the left.
9085

9186
<figure><img src="../../.gitbook/assets/obraz (4).png" alt=""><figcaption></figcaption></figure>
9287

93-
9488
4. Click "Make new registration"
95-
5. Fill out the form, like in the example:\
96-
89+
5. Fill out the form, like in the example:
9790

9891
<figure><img src="../../.gitbook/assets/obraz (5).png" alt=""><figcaption></figcaption></figure>
9992

100-
Make sure the Redirect URL you insert here is correct. Replace `defguard.example.com` with the domain you use for your Defguard dashboard.
101-
6. You should be now on the registered application's management screen. You can copy the client's ID and the tenant ID from here, as you need to provide them on the Defguard settings' page.\
93+
Make sure the Redirect URL you insert here is correct. Replace `defguard.example.com` with the domain you use for your Defguard dashboard.
10294

95+
6. You should be now on the registered application's management screen. You can copy the client's ID and the tenant ID from here, as you need to provide them on the Defguard settings' page.
10396

10497
<figure><img src="../../.gitbook/assets/Zrzut ekranu 2024-10-18 o 16.13.54.png" alt=""><figcaption></figcaption></figure>
105-
7. Go to Defguard settings, click the OpenID tab and paste the copied client ID. The tenant ID should be inserted instead of the `<TENANT_ID>` placeholder in the base URL field.
106-
8. &#x20;Now back in Microsoft Entra ID, still in your newly created application, go to Certificates and Secrets\
107-
\
10898

99+
7. Go to Defguard settings, click the OpenID tab and paste the copied client ID. The tenant ID should be inserted instead of the `<TENANT_ID>` placeholder in the base URL field.
100+
8. Now back in Microsoft Entra ID, still in your newly created application, go to **Certificates & Secrets**
109101

110102
<figure><img src="../../.gitbook/assets/obraz (8).png" alt=""><figcaption></figcaption></figure>
111103

112-
113104
9. Click Client secrets and create a new client secret. Copy its **value** and paste it in your Defguard OpenID settings.
114105
10. Go to Token configuration (in the menu on the left) and add a new optional token claim.
115-
11. Make sure to select the ID token type and the following claims:\
116-
106+
11. Make sure to select the ID token type and the following claims:
117107

118108
<figure><img src="../../.gitbook/assets/obraz (9).png" alt=""><figcaption></figcaption></figure>
119109

110+
12. Accept the popup or configure the API permissions manually.
120111

121-
12. Accept the popup or configure the API permissions manually.\
122-
123-
124-
<figure><img src="../../.gitbook/assets/obraz (10).png" alt=""><figcaption></figcaption></figure>
125-
112+
<figure><img src="../../.gitbook/assets/obraz (10).png" alt=""><figcaption></figcaption></figure>
126113

127114
13. Go to Authentication (again, it's in the menu on the left, still in the registered App settings) and enable the ID tokens field\
128115

129-
130116
<figure><img src="../../.gitbook/assets/obraz (11).png" alt=""><figcaption></figcaption></figure>
131117

132-
133118
14. Now you should be good to go. A new login button should appear on the login screen.
134119

135120
#### Custom OpenID provider
136121

137122
{% hint style="warning" %}
138-
We currently only support custom providers that allow a `id_token` response type. This may change in the future.
123+
Defguard supports custom providers that allow a **code** response type in the OpenID authorization flow.
139124
{% endhint %}
140125

141126
You can also configure a custom OpenID provider. The key thing here is setting up the **Base URL** correctly. This URL is used to discover all the endpoints required for the authorization flow.
142127

143128
The easiest way of obtaining the Base URL is finding out what is the OpenID `.well-known` URL of your provider. For example, for Google it's `https://accounts.google.com/.well-known/openid-configuration`, in this case, the Base URL would be `https://accounts.google.com` (note the lack of a trailing slash). The part starting with `/.well-known` is added automatically, so it should be omitted from the Base URL. This is explained in more detail in the [Base URL](external-openid-providers.md#base-url) section.
144129

145-
In order to get the `Client ID` and `Client Secret` values, refer to the documentation of your custom provider of choice.&#x20;
130+
In order to get the **Client ID** and **Client Secret** values, refer to the documentation of your custom provider of choice.
146131

147132
When configuring your external OpenID provider, at some point you will need to provide a callback URL, which will redirect the user back to Defguard. This URL is in form of `<DEFGUARD_DASHBOARD_URL>/auth/callback`. Replace `<DEFGUARD_DASHBOARD_URL>` with the URL under which your dashboard is accessible, e.g. `https://defguard.example.com`.
148133

149-
**Keycloak**
134+
### Examples
135+
136+
#### Zitadel
137+
138+
Refer to [Zitadel's documentation](https://zitadel.com/docs) on how to install it.
139+
140+
To use Zitadel with Defguard:
141+
142+
1. Log in to Zitadel's web interface.
143+
2. Create a project.
144+
3. Add a new application within the project.
145+
4. Select **Web** for applicatiom type.
146+
147+
<figure><img src="../../.gitbook/assets/zitadel1.png" alt=""><figcaption></figcaption></figure>
148+
149+
5. Choose **Code** for authorization method.
150+
151+
<figure><img src="../../.gitbook/assets/zitadel2.png" alt=""><figcaption></figcaption></figure>
152+
153+
6. Enter redirect URI for your Defguard instance. The URI is in the form `<DEFGUARD_DASHBOARD_URL>/auth/callback`, for example `https://defguard.example.com/auth/callback`. (If Defguard has been launched on the _localhost_, select **Development Mode** and enter `http://localhost:8000/auth/callback`.)
154+
155+
<figure><img src="../../.gitbook/assets/zitadel3.png" alt=""><figcaption></figcaption></figure>
156+
157+
7. **Create** the application.
158+
8. Copy the provided **Client ID** and **Client Secret** and enter these in the Defguard's OpenID settings.
159+
9. Finally, in the **Token Settings**, enable **User Infor inside ID Token**.
160+
161+
<figure><img src="../../.gitbook/assets/zitadel4.png" alt=""><figcaption></figcaption></figure>
162+
163+
#### Keycloak
150164

151-
A basic guide about securing applications using Keycloack can be found [here](https://www.keycloak.org/getting-started/getting-started-docker#\_secure\_the\_first\_application).&#x20;
165+
A basic guide about securing applications using Keycloack can be found [here](https://www.keycloak.org/getting-started/getting-started-docker#\_secure\_the\_first\_application).
152166

0 commit comments

Comments
 (0)