File tree Expand file tree Collapse file tree 3 files changed +23
-7
lines changed Expand file tree Collapse file tree 3 files changed +23
-7
lines changed Original file line number Diff line number Diff line change @@ -22,7 +22,10 @@ server {
22
22
include conf.d/openid_connect.server_conf; # Authorization code flow and Relying Party processing
23
23
24
24
# OpenID Connect Provider (IdP) configuration
25
- set $oidc_jwt_keyfile /etc/nginx/my_idp_jwk.json;
25
+ resolver 8.8.8.8 ; # For DNS lookup of IdP endpoints;
26
+ subrequest_output_buffer_size 32k; # To fit a complete tokenset response
27
+
28
+ set $oidc_jwt_keyfile /etc/nginx/my_idp_jwk.json; # URL when using 'auth_jwt_key_request'
26
29
set $oidc_authz_endpoint "http://127.0.0.1:8080/auth/realms/master/protocol/openid-connect/auth" ;
27
30
set $oidc_token_endpoint "http://127.0.0.1:8080/auth/realms/master/protocol/openid-connect/token" ;
28
31
set $oidc_client "my-client-id" ;
@@ -35,6 +38,7 @@ server {
35
38
# This site is protected with OpenID Connect
36
39
auth_jwt "" token=$session_jwt ; # Obtain JWT from key-value store
37
40
auth_jwt_key_file $oidc_jwt_keyfile ;
41
+ #auth_jwt_key_request /_jwks_uri; # Requires NGINX Plus R17+
38
42
39
43
# Absent/invalid OpenID Connect token will (re)start auth process
40
44
error_page 401 @oidc_auth;
Original file line number Diff line number Diff line change
1
+ location = /_jwks_uri {
2
+ # This is where the JSON Web Key Set is fetched from the IdP and cached
3
+ internal ;
4
+ proxy_cache jwk;
5
+ proxy_pass $oidc_jwt_keyfile ;
6
+
7
+ # This configuration ignores all response headers that influence caching,
8
+ # and instead sets a fixed validity period before the JWK is re-fetched.
9
+ # See http://nginx.org/r/proxy_cache for all configuration options
10
+ proxy_cache_valid 200 12h ;
11
+ proxy_cache_lock on;
12
+ proxy_cache_use_stale error timeout updating;
13
+ proxy_ignore_headers Cache-Control Expires Set-Cookie;
14
+ }
15
+
1
16
location @oidc_auth {
2
17
# TODO: if $auth_token then delete the expired/invalid entry from keyval
3
18
39
54
# to construct the OpenID Connect token request, as per:
40
55
# http://openid.net/specs/openid-connect-core-1_0.html#TokenRequest
41
56
internal ;
42
- resolver 127.0.0.1 ; # For DNS lookup of $oidc_token_endpoint;
43
57
gunzip on; # Decompress if necessary
44
58
45
59
proxy_set_header Content-Type "application/x-www-form-urlencoded" ;
Original file line number Diff line number Diff line change 1
1
location = /_jwks_uri {
2
- # This is where the JSON Web Key Set is fetched from the IdP and cached
2
+ # This is where the JSON Web Key Set is fetched from the IdP and cached
3
3
internal ;
4
4
proxy_cache jwk;
5
5
proxy_pass $oidc_jwt_keyfile ;
10
10
proxy_cache_valid 200 12h ;
11
11
proxy_cache_lock on;
12
12
proxy_cache_use_stale error timeout updating;
13
- proxy_ignore_headers Cache-Control;
14
- proxy_ignore_headers Expires;
15
- proxy_ignore_headers Set-Cookie;
13
+ proxy_ignore_headers Cache-Control Expires Set-Cookie;
16
14
}
17
15
18
16
location @oidc_auth {
35
33
js_content oidcCodeExchange; # nginScript function to obtain JWT and issue cookie
36
34
add_header Set-Cookie "auth_token=$auth_token ; HttpOnly;" ;
37
35
38
- # Catch errors from oidc_codeExchange ()
36
+ # Catch errors from oidcCodeExchange ()
39
37
# 500 = token validation error, 502 = error from IdP, 504 = IdP timeout
40
38
error_page 500 502 504 @oidc_error;
41
39
You can’t perform that action at this time.
0 commit comments