You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
feat: new endpoints and bundle OIDC simulation environment
chore: agenda and getting started for README.md
fix: typo
fix: link for README.md
fix: signout and sample API for README.md
fix: comment for post logout and gitignore
fix: space to horizontally aligh variables of key/value
fix: README.md
fix: image of make watch
chore: add a node when Keycloak container isn't working
feat: advanced example of proxy server
chore: fix typo and add a note for two examples for reverse proxy configuration
This repository describes how to enable OpenID Connect integration for [NGINX Plus](https://www.nginx.com/products/nginx/). The solution depends on NGINX Plus components ([auth_jwt module](http://nginx.org/en/docs/http/ngx_http_auth_jwt_module.html) and [key-value store](http://nginx.org/en/docs/http/ngx_http_keyval_module.html)) and as such is not suitable for [open source NGINX](http://www.nginx.org/en).
@@ -32,18 +49,45 @@ For more information on OpenID Connect and JWT validation with NGINX Plus, see [
32
49
33
50
### Refresh Tokens
34
51
35
-
If a [refresh token](https://openid.net/specs/openid-connect-core-1_0.html#RefreshTokens) was received from the IdP then it is also stored in the key-value store. When validation of the ID Token fails (typically upon expiry) then NGINX Plus sends the refresh token to the IdP. If the user's session is still valid at the IdP then a new ID token is received, validated, and updated in the key-value store. The refresh process is seamless to the client.
52
+
If a [refresh token](https://openid.net/specs/openid-connect-core-1_0.html#RefreshTokens) was received from the IdP then it is also stored in the key-value store. When validation of the ID Token fails (typically upon expiry) then NGINX Plus sends the refresh token to the IdP. If the user's session is still valid at the IdP then new ID token and access token are received, validated, and updated in the key-value store. The refresh process is seamless to the client. The ID token is used for user authentication with login and logout, and the access is used for API authorization before proxing to IdP endpoint such as `/userinfo` or custom backend APIs.
53
+
54
+
### User Information & Login
55
+
56
+
The `/userinfo` endpoint is used for the following purposes by validating access token via your IdP(s):
57
+
58
+
- When connecting a frontend app for the first time, the landing page can be shown with `Login` button without user information.
59
+
- The frontend app periodically calls the `/userinfo` endpoint, and it returns the status code of `401` as the access token is invalid before clicking `Login` button.
60
+
- When an End-User clicks `Login` button, the frontend app calls `/login` endpoint, and the ID token, access token, and refresh token are issued by the IdP and stored in the key-value store of NGINX Plus.
61
+
- NGINX Plus successfully redirects to the frontend landing page with session cookie after successful login.
62
+
- In the meantime, the user information is shown in the frontend app as the `userinfo` endpoint returns the user data with the status code of `200` by validating access token with the IdP.
36
63
37
64
### Logout
38
65
39
66
Requests made to the `/logout` location invalidate both the ID token and refresh token by erasing them from the key-value store. Therefore, subsequent requests to protected resources will be treated as a first-time request and send the client to the IdP for authentication. Note that the IdP may issue cookies such that an authenticated session still exists at the IdP.
40
67
68
+
To avoid breaking changes of API endpoints to customers, the `/v2/logout` location is added to interact with the IdP's `end_session_endpoint` which is to handle [OIDC RP-Initiated Logout](https://openid.net/specs/openid-connect-rpinitiated-1_0.html#RPLogout) as the spec of OpenID Connect. The `$post_logout_return_uri` is the URI to which the RP is requesting that the End-User's User Agent be redirected after a logout has been performed. When setting up an IdP, `/v1/_logout` is used in this example, and you can change it per your preference.
69
+
41
70
### Multiple IdPs
42
71
43
72
Where NGINX Plus is configured to proxy requests for multiple websites or applications, or user groups, these may require authentication by different IdPs. Separate IdPs can be configured, with each one matching on an attribute of the HTTP request, e.g. hostname or part of the URI path.
44
73
45
74
> **Note:** When validating OpenID Connect tokens, NGINX Plus can be configured to read the signing key (JWKS) from disk, or a URL. When using multiple IdPs, each one must be configured to use the same method. It is not possible to use a mix of both disk and URLs for the `map…$oidc_jwt_keyfile` variable.
46
75
76
+
## 🏠 Getting Started
77
+
78
+
Start by following [step 1](#step-1-quick-starting-guide) if you want to quickly learn and test NGINX Plus OIDC locally. Otherwise skip step 1, and follow the [step 2](#step-2-detailed-starting-guide).
79
+
80
+
### Step 1. Quick Starting Guide
81
+
82
+
- 📚 [**How To Set Up and Locally Test NGINX Plus OIDC**](./docs/01-oidc-local-test.md)
Start by [installing NGINX Plus](https://docs.nginx.com/nginx/admin-guide/installing-nginx/installing-nginx-plus/). In addition, the [NGINX JavaScript module](https://www.nginx.com/blog/introduction-nginscript/) (njs) is required for handling the interaction between NGINX Plus and the OpenID Connect provider (IdP). Install the njs module after installing NGINX Plus by running one of the following:
@@ -100,6 +144,8 @@ When NGINX Plus is deployed behind another proxy, the original protocol and port
100
144
- Obtain the URL for `jwks_uri` or download the JWK file to your NGINX Plus instance
101
145
- Obtain the URL for the **authorization endpoint**
102
146
- Obtain the URL for the **token endpoint**
147
+
- Obtain the URL for the **end session endpoint**
148
+
- Obtain the URL for the **user info endpoint**
103
149
104
150
## Configuring NGINX Plus
105
151
@@ -110,7 +156,8 @@ Manual configuration involves reviewing the following files so that they match y
110
156
-**openid_connect_configuration.conf** - this contains the primary configuration for one or more IdPs in `map{}` blocks
111
157
112
158
- Modify all of the `map…$oidc_` blocks to match your IdP configuration
113
-
- Modify the URI defined in `map…$oidc_logout_redirect` to specify an unprotected resource to be displayed after requesting the `/logout` location
159
+
- Modify the URI defined in `map…$oidc_logout_redirect` to specify an unprotected resource to be displayed after requesting the `/logout` location for customers who has been using R28.
160
+
- Modify the URI defined in `map…$oidc_logout_redirect_uri` to specify an unprotected resource to be displayed after requesting the `/v2/_logout` location for customers who start using R29 and wants to change from `map…$oidc_logout_redirect` to `map…$oidc_logout_redirect_uri` to use the feature of `OIDC RP-Initiated Logout` which is interact with IdP's `end_session_endpoint`.
114
161
- Set a unique value for `$oidc_hmac_key` to ensure nonce values are unpredictable
115
162
- If NGINX Plus is deployed behind another proxy or load balancer, modify the `map…$redirect_base` and `map…$proto` blocks to define how to obtain the original protocol and port number.
116
163
@@ -121,6 +168,19 @@ Manual configuration involves reviewing the following files so that they match y
121
168
- Modify the severity level of the `error_log` directive to suit the deployment environment
122
169
- Comment/uncomment the `auth_jwt_key_file` or `auth_jwt_key_request` directives based on whether `$oidc_jwt_keyfile` is a file or URI, respectively
123
170
171
+
> Note: Two configuration examples are provided as follows.
172
+
>
173
+
> -1. Basic Example. Landing page starts OIDC flow without a login button
# Uncomment the line below if you want to specify JDBC parameters. The parameter below is just an example, and it shouldn't be used in production without knowledge. It is highly recommended that you read the PostgreSQL JDBC driver documentation in order to use it.
0 commit comments