Skip to content

Commit 0eb3ba5

Browse files
committed
Add OIDC landing page for NGINX to redirect after successful OIDC login
remove login endpoint
1 parent 74948ce commit 0eb3ba5

File tree

2 files changed

+17
-1
lines changed

2 files changed

+17
-1
lines changed

openid_connect.js

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -198,7 +198,7 @@ function codeExchange(r) {
198198
r.variables.new_access_token = "";
199199
}
200200
r.headersOut["Set-Cookie"] = "auth_token=" + r.variables.request_id + "; " + r.variables.oidc_cookie_flags;
201-
r.return(302, r.variables.redirect_base + r.variables.cookie_auth_redir);
201+
redirectPostLogin(r);
202202
}
203203
);
204204
} catch (e) {
@@ -263,6 +263,15 @@ function validateIdToken(r) {
263263
}
264264
}
265265

266+
// Redirect URI after successful login from the OP.
267+
function redirectPostLogin(r) {
268+
if (r.variables.oidc_landing_page) {
269+
r.return(302, r.variables.oidc_landing_page);
270+
} else {
271+
r.return(302, r.variables.redirect_base + r.variables.cookie_auth_redir);
272+
}
273+
}
274+
266275
function logout(r) {
267276
r.log("OIDC logout for " + r.variables.cookie_auth_token);
268277
r.variables.session_jwt = "-";

openid_connect_configuration.conf

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,13 @@ map $host $oidc_scopes {
4444
default "openid+profile+email+offline_access";
4545
}
4646

47+
map $host $oidc_landing_page {
48+
# Where to send browser after successful login. If empty, redirects User
49+
# Agent to $request_uri.
50+
default "";
51+
#www.example.com $redirect_base;
52+
}
53+
4754
map $host $oidc_logout_redirect {
4855
# Where to send browser after requesting /logout location. This can be
4956
# replaced with a custom logout page, or complete URL.

0 commit comments

Comments
 (0)