Skip to content

Commit 31856d2

Browse files
authored
feat: Add PKCE specific Keycloak setup (#585)
1 parent 5da80f2 commit 31856d2

File tree

1 file changed

+63
-13
lines changed
  • content/nginx/deployment-guides/single-sign-on

1 file changed

+63
-13
lines changed

content/nginx/deployment-guides/single-sign-on/keycloak.md

Lines changed: 63 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -24,29 +24,77 @@ This guide explains how to enable single sign-on (SSO) for applications being pr
2424

2525
## Configure Keycloak {#keycloak-setup}
2626

27-
1. Log in to your Keycloak admin console, for example, `https://<keycloak-server>/auth/admin/`.
27+
{{<tabs name="configure-keycloak">}}
2828

29-
2. In the left navigation, go to **Clients**.then
29+
{{%tab name="Standard OIDC"%}}
3030

31-
3. Select **Create** and provide the following details:
31+
1. Log in to your Keycloak admin console, for example, `https://<keycloak-server>/admin/master/console/`.
3232

33-
- Enter a **Client ID**, for example, `nginx-demo-app`. You will need it later when configuring NGINX Plus.
33+
2. In the left navigation, go to **Clients**, then
3434

35-
- Set **Client Protocol** to **openid-connect**.
35+
3. Select **Create client** and provide the following details:
3636

37-
- Select **Save**.
37+
- Set **Client type** to **OpenID Connect**.
38+
39+
- Enter a **Client ID**, for example, `nginx-demo-app`. You will need it later when configuring NGINX Plus.
40+
41+
- Select **Next**.
3842

39-
4. In the **Settings** tab of your new client:
43+
4. In the **Capability Config** section:
4044

41-
- Set **Access Type** to `confidential`.
45+
- Set **Client Authentication** to **On**. This sets the client type to **confidential**.
46+
47+
- Select **Next**.
4248

43-
- Add a **Redirect URI**, for example:
49+
5. In the **Login Settings** section:
50+
51+
- Add a **Redirect URI**, for example:
4452
```
4553
https://demo.example.com/oidc_callback
4654
```
4755
- Select **Save**.
4856
49-
5. In the **Credentials** tab, make note of the **Client Secret**. You will need it later when configuring NGINX Plus.
57+
6. In the **Credentials** tab, make note of the **Client Secret**. You will need it later when configuring NGINX Plus.
58+
59+
{{%/tab%}}
60+
61+
{{%tab name="Using PKCE"%}}
62+
63+
1. Log in to your Keycloak admin console, for example, `https://<keycloak-server>/auth/admin/`.
64+
65+
2. In the left navigation, go to **Clients**, then
66+
67+
3. Select **Create client** and provide the following details:
68+
69+
- Set **Client type** to **OpenID Connect**.
70+
71+
- Enter a **Client ID**, for example, `nginx-demo-app`. You will need it later when configuring NGINX Plus.
72+
73+
- Select **Next**.
74+
75+
4. In the **Capability Config** section:
76+
77+
- Set **Client Authentication** to **Off**. This sets the client type to **public**.
78+
79+
- Unselect the **Direct access grants** in the **Authentication Flow** section.
80+
81+
- Select **Next**
82+
83+
5. In the **Login Settings** section:
84+
85+
- Add a **Redirect URI**, for example:
86+
```
87+
https://demo.example.com/oidc_callback
88+
```
89+
- Select **Save**.
90+
91+
6. In the **Advanced** tab, under the **Advanced Settings** section set the **Proof Key for Code Exchange Code Challenge Method** to **S256**.
92+
93+
7. Note that as opposed to standard OIDC flow, PKCE does not use Client Secrets, so there is no Credentials tab. This is expected.
94+
95+
{{%/tab%}}
96+
97+
{{</tabs>}}
5098
5199
### Assign Users or Groups
52100
@@ -63,7 +111,7 @@ This step is optional, and is necessary if you need to restrict or organize user
63111
64112
## Set up NGINX Plus {#nginx-plus-setup}
65113
66-
With Keycloak configured, you can enable OIDC on NGINX Plus. NGINX Plus serves as the Rely Party (RP) application &mdash; a client service that verifies user identity.
114+
With Keycloak configured, you can enable OIDC on NGINX Plus. NGINX Plus serves as the Relying Party (RP) application &mdash; a client service that verifies user identity.
67115
68116
1. Ensure that you are using the latest version of NGINX Plus by running the `nginx -v` command in a terminal:
69117
@@ -76,7 +124,8 @@ With Keycloak configured, you can enable OIDC on NGINX Plus. NGINX Plus serves a
76124
nginx version: nginx/1.27.4 (nginx-plus-r34)
77125
```
78126
79-
2. Ensure that you have the values of the **Client ID**, **Client Secret**, and **Issuer** obtained during [Keycloak Configuration](#keycloak-setup).
127+
2. Ensure that you have the values of the **Client ID**, **Client Secret**, and **Issuer** obtained during
128+
[Keycloak Configuration](#keycloak-setup) if applicable. PKCE will not have a **Client Secret**.
80129
81130
3. In your preferred text editor, open the NGINX configuration file (`/etc/nginx/nginx.conf` for Linux or `/usr/local/etc/nginx/nginx.conf` for FreeBSD).
82131
@@ -110,7 +159,8 @@ With Keycloak configured, you can enable OIDC on NGINX Plus. NGINX Plus serves a
110159
111160
- your actual Keycloak **Client ID** obtained in [Keycloak Configuration](#keycloak-setup) with the [`client_id`](https://nginx.org/en/docs/http/ngx_http_oidc_module.html#client_id) directive
112161
113-
- your **Client Secret** obtained in [Keycloak Configuration](#keycloak-setup) with the [`client_secret`](https://nginx.org/en/docs/http/ngx_http_oidc_module.html#client_secret) directive
162+
- (if not using PKCE) your **Client Secret** obtained in [Keycloak Configuration](#keycloak-setup) with the
163+
[`client_secret`](https://nginx.org/en/docs/http/ngx_http_oidc_module.html#client_secret) directive
114164
115165
- the **Issuer** URL obtained in [Keycloak Configuration](#keycloak-setup) with the [`issuer`](https://nginx.org/en/docs/http/ngx_http_oidc_module.html#client_secret) directive
116166

0 commit comments

Comments
 (0)