Skip to content
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

Added callback URLs for code exchange and logout #83

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 6 additions & 2 deletions openid_connect.js
Original file line number Diff line number Diff line change
Expand Up @@ -198,7 +198,8 @@ function codeExchange(r) {
r.variables.new_access_token = "";
}
r.headersOut["Set-Cookie"] = "auth_token=" + r.variables.request_id + "; " + r.variables.oidc_cookie_flags;
r.return(302, r.variables.redirect_base + r.variables.cookie_auth_redir);
const redirectLocation = r.variables.after_codexch_redir || r.variables.cookie_auth_redir
r.return(302, r.variables.redirect_base + redirectLocation);
}
);
} catch (e) {
Expand Down Expand Up @@ -268,7 +269,10 @@ function logout(r) {
r.variables.session_jwt = "-";
r.variables.access_token = "-";
r.variables.refresh_token = "-";
r.return(302, r.variables.oidc_logout_redirect);
const redirectLocation = r.variables.initial_logout_redir
? `${r.variables.redirect_base}${r.variables.initial_logout_redir}`
: r.variables.oidc_logout_redirect;
r.return(302, redirectLocation);
}

function getAuthZArgs(r) {
Expand Down
1 change: 0 additions & 1 deletion openid_connect.server_conf
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@
default_type text/plain; # In case we throw an error
}

set $redir_location "/_codexch";
location = /_codexch {
# This location is called by the IdP after successful authentication
status_zone "OIDC code exchange";
Expand Down
15 changes: 15 additions & 0 deletions openid_connect_configuration.conf
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,21 @@
# Each map block allows multiple values so that multiple IdPs can be supported,
# the $host variable is used as the default input parameter but can be changed.
#
map $host $redir_location {
# www.example.com "/signin-oidc"; # need to add the /signin-oidc location and code exchange process
default "/_codexch";
}

map $host $after_codexch_redir {
default "";
#www.example.com "/after_code_verified";
}

map $host $initial_logout_redir {
default "";
#www.example.com "/clear_proxy_session";
}

map $host $oidc_authz_endpoint {
default "http://127.0.0.1:8080/auth/realms/master/protocol/openid-connect/auth";
#www.example.com "https://my-idp/oauth2/v1/authorize";
Expand Down