-
Notifications
You must be signed in to change notification settings - Fork 95
Evolve oidc logout #87
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -120,7 +120,7 @@ fi | |
# Build an intermediate configuration file | ||
# File format is: <NGINX variable name><space><IdP value> | ||
# | ||
jq -r '. | "$oidc_authz_endpoint \(.authorization_endpoint)\n$oidc_token_endpoint \(.token_endpoint)\n$oidc_jwks_uri \(.jwks_uri)"' < /tmp/${COMMAND}_$$_json > /tmp/${COMMAND}_$$_conf | ||
jq -r '. | "$oidc_authz_endpoint \(.authorization_endpoint)\n$oidc_token_endpoint \(.token_endpoint)\n$oidc_logout_endpoint \(.logout_endpoint)\n$oidc_jwks_uri \(.jwks_uri)"' < /tmp/${COMMAND}_$$_json > /tmp/${COMMAND}_$$_conf | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||
|
||
# Create a random value for HMAC key, adding to the intermediate configuration file | ||
echo "\$oidc_hmac_key `openssl rand -base64 18`" >> /tmp/${COMMAND}_$$_conf | ||
|
@@ -178,7 +178,7 @@ fi | |
|
||
# Loop through each configuration variable | ||
echo "$COMMAND: NOTICE: Configuring $CONFDIR/openid_connect_configuration.conf" | ||
for OIDC_VAR in \$oidc_authz_endpoint \$oidc_token_endpoint \$oidc_jwt_keyfile \$oidc_hmac_key $CLIENT_ID_VAR $CLIENT_SECRET_VAR $PKCE_ENABLE_VAR; do | ||
for OIDC_VAR in \$oidc_authz_endpoint \$oidc_token_endpoint \$oidc_logout_endpoint \$oidc_jwt_keyfile \$oidc_hmac_key $CLIENT_ID_VAR $CLIENT_SECRET_VAR $PKCE_ENABLE_VAR; do | ||
# Pull the configuration value from the intermediate file | ||
VALUE=`grep "^$OIDC_VAR " /tmp/${COMMAND}_$$_conf | cut -f2 -d' '` | ||
echo -n "$COMMAND: NOTICE: - $OIDC_VAR ..." | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -8,7 +8,7 @@ | |
|
||
location = /_jwks_uri { | ||
internal; | ||
proxy_cache jwk; # Cache the JWK Set recieved from IdP | ||
proxy_cache jwk; # Cache the JWK Set received from IdP | ||
proxy_cache_valid 200 12h; # How long to consider keys "fresh" | ||
proxy_cache_use_stale error timeout updating; # Use old JWK Set if cannot reach IdP | ||
proxy_ssl_server_name on; # For SNI to the IdP | ||
|
@@ -29,9 +29,9 @@ | |
# This location is called by the IdP after successful authentication | ||
status_zone "OIDC code exchange"; | ||
js_content oidc.codeExchange; | ||
error_page 500 502 504 @oidc_error; | ||
error_page 500 502 504 @oidc_error; | ||
} | ||
|
||
location = /_token { | ||
# This location is called by oidcCodeExchange(). We use the proxy_ directives | ||
# to construct the OpenID Connect token request, as per: | ||
|
@@ -67,16 +67,21 @@ | |
} | ||
|
||
location = /logout { | ||
# This location is called by UI to handle OIDC logout with IDP | ||
status_zone "OIDC logout"; | ||
add_header Set-Cookie "auth_token=; $oidc_cookie_flags"; # Send empty cookie | ||
add_header Set-Cookie "auth_redir=; $oidc_cookie_flags"; # Erase original cookie | ||
js_content oidc.logout; | ||
} | ||
|
||
location = /_logout { | ||
# This location is the default value of $oidc_logout_redirect (in case it wasn't configured) | ||
default_type text/plain; | ||
return 200 "Logged out\n"; | ||
# This location is a default value of $oidc_logout_redirect called by the | ||
# IDP after closing user session in the IDP. | ||
|
||
# Clean cookies | ||
add_header Set-Cookie "auth_nonce=; $oidc_cookie_flags"; # Send empty cookie | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. What is the practical meaning of your approach when you initiate security context destruction at the time of the |
||
add_header Set-Cookie "auth_token=; $oidc_cookie_flags"; # Erase original cookie | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. These comments make no sense, so I'd remove them. |
||
add_header Set-Cookie "auth_redir=; $oidc_cookie_flags"; | ||
|
||
js_content oidc.redirectPostLogout; | ||
} | ||
|
||
location @oidc_error { | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -28,6 +28,16 @@ map $host $oidc_jwt_keyfile { | |
default "http://127.0.0.1:8080/auth/realms/master/protocol/openid-connect/certs"; | ||
} | ||
|
||
map $host $oidc_logout_endpoint { | ||
default "http://127.0.0.1:8080/auth/realms/master/protocol/openid-connect/logout"; | ||
} | ||
|
||
map $host $redir_post_logout { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I have some doubts about the practical usefulness of this functionality for several reasons:
|
||
# Where to send browser after requesting /logout location. This can be | ||
# replaced with a custom logout page, or complete URL. | ||
default "http://127.0.0.1:8080"; | ||
} | ||
|
||
map $host $oidc_client { | ||
default "my-client-id"; | ||
} | ||
|
@@ -45,9 +55,7 @@ map $host $oidc_scopes { | |
} | ||
|
||
map $host $oidc_logout_redirect { | ||
# Where to send browser after requesting /logout location. This can be | ||
# replaced with a custom logout page, or complete URL. | ||
default "/_logout"; # Built-in, simple logout page | ||
default "/_logout"; # This is called by IdP after successful logout. | ||
} | ||
|
||
map $host $oidc_hmac_key { | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'd replace
logout endpoint
withend session endpoint
, since this is most likely how it will be reflected in the IdP documentation.