Take the following steps to create a new application of Keycloak for integrating with NGINX Plus.
Note:
The following procedure reflects the Keycloak GUI at the time of publication, but the GUI is subject to change. Use this guide as a reference and adapt to the current Keycloak GUI as necessary.
Create a Keycloak client for NGINX Plus in the Keycloak GUI:
-
Access the Keycloak Admin Console at
http://keycloak-server-address:8080/auth/admin/
and log in.Note:
In the example of this repository, use the following information after running a docker containter for the purpose of testing.
- URL:
http://localhost:8080/auth/admin
- Basic Auth:
admin / password
(Where to change)
- URL:
-
In the left navigation column, click Clients. On the Clients page that opens, click the Create button in the upper right corner.
-
On the Add Client page that opens, enter or select these values, then click the
Save
button.- Client ID – The name of the application for which you’re enabling SSO (Keycloak refers to it as the “client”). Here we’re using
my-client-id
. - Client Protocol – openid-connect.
- Client ID – The name of the application for which you’re enabling SSO (Keycloak refers to it as the “client”). Here we’re using
-
On the my-client-id page that opens, enter or select these values on the Settings tab:
-
Access Type:
- Option 1. Check
confidential
if you don't enable PKCE. - Option 2. Check
public
if you enable PKCE.
- Option 1. Check
-
Valid Redirect URIs – The URI of the NGINX Plus instance, including the port number, and ending in the following URIs:
/_codexch
: in this guide it ishttp://nginx.keycloak.test:11000/_codexch
/_logout
: in this guide it ishttp://nginx.keycloak.test:11000/_logout
Notes:
- For production, we strongly recommend that you use SSL/TLS (port 443).
- The port number is mandatory even when you’re using the default port for HTTP (80) or HTTPS (443). But it it isn't needed if you use NGINX ACM.
-
-
Click the
Credentials
tab and make a note of the value in the Secret field. You will copy it into the NGINX Plus configuration file in Step 3 of Configuring NGINX Plus.Notes: This is only used for the step if you choose
Access Type: confidential
when you don't enable PKCE.
-
Click the
Roles
tab, then click the Add Role button in the upper right corner of the page that opens. -
On the Add Role page that opens, type a value in the Role Name field (here it is
nginx-keycloak-role
) and click the Save button.
-
In the left navigation column, click Users. On the Users page that opens, either click the name of an existing user, or click the Add user button in the upper right corner to create a new user. For complete instructions, see the Keycloak documentation.
-
Optional. Reset password if you want to set a password for your testing:
-
On the management page for the user (here, user-01), click the
Role Mappings
tab. On the page that opens, select my-client-01 on the Client Roles drop‑down menu. Clicknginx-keycloak-role
in the Available Roles box, then click the Add selected button below the box. The role then appears in the Assigned Roles and Effective Roles boxes, as shown in the screenshot.