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 {
2222 include conf.d/openid_connect.server_conf; # Authorization code flow and Relying Party processing
2323
2424 # 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'
2629 set $oidc_authz_endpoint "http://127.0.0.1:8080/auth/realms/master/protocol/openid-connect/auth" ;
2730 set $oidc_token_endpoint "http://127.0.0.1:8080/auth/realms/master/protocol/openid-connect/token" ;
2831 set $oidc_client "my-client-id" ;
@@ -35,6 +38,7 @@ server {
3538 # This site is protected with OpenID Connect
3639 auth_jwt "" token=$session_jwt ; # Obtain JWT from key-value store
3740 auth_jwt_key_file $oidc_jwt_keyfile ;
41+ #auth_jwt_key_request /_jwks_uri; # Requires NGINX Plus R17+
3842
3943 # Absent/invalid OpenID Connect token will (re)start auth process
4044 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+
116 location @oidc_auth {
217 # TODO: if $auth_token then delete the expired/invalid entry from keyval
318
3954 # to construct the OpenID Connect token request, as per:
4055 # http://openid.net/specs/openid-connect-core-1_0.html#TokenRequest
4156 internal ;
42- resolver 127.0.0.1 ; # For DNS lookup of $oidc_token_endpoint ;
4357 gunzip on; # Decompress if necessary
4458
4559 proxy_set_header Content-Type "application/x-www-form-urlencoded" ;
Original file line number Diff line number Diff line change 11 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
33 internal ;
44 proxy_cache jwk;
55 proxy_pass $oidc_jwt_keyfile ;
1010 proxy_cache_valid 200 12h ;
1111 proxy_cache_lock on;
1212 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;
1614 }
1715
1816 location @oidc_auth {
3533 js_content oidcCodeExchange; # nginScript function to obtain JWT and issue cookie
3634 add_header Set-Cookie "auth_token=$auth_token; HttpOnly;" ;
3735
38- # Catch errors from oidc_codeExchange ()
36+ # Catch errors from oidcCodeExchange ()
3937 # 500 = token validation error, 502 = error from IdP, 504 = IdP timeout
4038 error_page 500 502 504 @oidc_error;
4139
You can’t perform that action at this time.
0 commit comments