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
Copy file name to clipboardExpand all lines: README.md
+31-2
Original file line number
Diff line number
Diff line change
@@ -30,6 +30,21 @@ Subsequent requests to protected resources are authenticated by exchanging the s
30
30
31
31
For more information on OpenID Connect and JWT validation with NGINX Plus, see [Authenticating Users to Existing Applications with OpenID Connect and NGINX Plus](https://www.nginx.com/blog/authenticating-users-existing-applications-openid-connect-nginx-plus/).
32
32
33
+
### Access Tokens
34
+
The [access tokens](https://openid.net/specs/openid-connect-core-1_0.html#AccessTokenD) are credentials used to access protected resources. If an access token was received from the IdP then it is also stored in the key-value store. To access protected backend, bearer token can be used before calling `proxy_pass` directive as the following example:
35
+
36
+
```nginx
37
+
# Bearer token is uses to authorize NGINX to access protected backend
# Intercept and redirect "401 Unauthorized" proxied responses to nginx
41
+
# for processing with the error_page directive. Necessary if Access Token
42
+
# can expire before ID Token.
43
+
proxy_intercept_errors on;
44
+
45
+
proxy_pass http://my_backend; # The backend site/app
46
+
```
47
+
33
48
### Refresh Tokens
34
49
35
50
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.
@@ -114,6 +129,8 @@ Manual configuration involves reviewing the following files so that they match y
114
129
* Configure the preferred listen port and [enable SSL/TLS configuration](https://docs.nginx.com/nginx/admin-guide/security-controls/terminating-ssl-http/)
115
130
* Modify the severity level of the `error_log` directive to suit the deployment environment
116
131
* 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
132
+
* Uncomment the `proxy_set_header Authorization "Bearer $access_token"` directive if you want to pass access/bearer token in HTTP header to the protected backend/upstream
133
+
* Uncoment the `proxy_intercept_errors on` directive if the access token lifetime is less than the ID token lifetime
117
134
118
135
***openid_connect.server_conf** - this is the NGINX configuration for handling the various stages of OpenID Connect authorization code flow
119
136
* No changes are usually required here
@@ -128,8 +145,9 @@ Manual configuration involves reviewing the following files so that they match y
128
145
The key-value store is used to maintain persistent storage for ID tokens and refresh tokens. The default configuration should be reviewed so that it suits the environment. This is part of the advanced configuration in **openid_connect_configuration.conf**.
* The looping can now happen if the access token is not valid for some reason such that the setup of ID/access tokens expiration is different in the IdP.
248
+
* In case of this, the backend/upstream can respond with HTTP 401 "Invalid token", and the frontend can restart the flow of OpenID Connect to get new ID token or refresh tokens by calling the following directives.
249
+
```nginx
250
+
auth_jwt "" token=$session_jwt;
251
+
error_page 401 = @do_oidc_flow;
252
+
```
253
+
226
254
## Support
227
255
228
256
This reference implementation for OpenID Connect is supported for NGINX Plus subscribers.
@@ -236,3 +264,4 @@ This reference implementation for OpenID Connect is supported for NGINX Plus sub
236
264
***R19** Minor bug fixes
237
265
***R22** Separate configuration file, supports multiple IdPs. Configurable scopes and cookie flags. JavaScript is imported as an indepedent module with `js_import`. Container-friendly logging. Additional metrics for OIDC activity.
238
266
***R23** PKCE support. Added support for deployments behind another proxy or load balancer.
267
+
***R28** Access token support. Added support for access token to authorize NGINX to access protected backend.
0 commit comments