Skip to content

Commit

Permalink
fix: if appBaseUrl includes a base path
Browse files Browse the repository at this point in the history
OKTA-464266
<<<Jenkins Check-In of Tested SHA: c6d7dd6 for eng_productivity_ci_bot_okta@okta.com>>>
Artifact: okta-oidc-middleware
Files changed count: 3
PR Link: "#43"
  • Loading branch information
jaredperreault-okta authored and eng-prod-CI-bot-okta committed Jan 27, 2022
1 parent 4e1414e commit 8b0691c
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 2 deletions.
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
# 4.5.1

### Bug Fixes

- [#43](https://github.com/okta/okta-oidc-middleware/pull/43) fix: correctly preprends `appBaseUrl` to redirect url when `appBaseUrl` contains a base path

# 4.5.0

### Features
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"private": true,
"name": "@okta/oidc-middleware",
"version": "4.5.0",
"version": "4.5.1",
"description": "OpenId Connect middleware for authorization code flows",
"repository": "https://github.com/okta/okta-oidc-middleware",
"homepage": "https://github.com/okta/okta-oidc-middleware#readme",
Expand Down
6 changes: 5 additions & 1 deletion src/oidcUtil.js
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,11 @@ oidcUtil.ensureAuthenticated = (context, options = {}) => {
if (req.session) {
req.session.returnTo = req.originalUrl || req.url;
}
const url = options.redirectTo || (new URL(context.options.routes.login.path, context.options.appBaseUrl)).href;
let url = options.redirectTo;
if (!url) {
const loginPath = context.options.routes.login.path;
url = (new URL(loginPath[0] === '/' ? `.${loginPath}` : `/${loginPath}`, context.options.appBaseUrl + '/')).href;
}
return res.redirect(appendOptionsToQuery(url, options));
}

Expand Down

0 comments on commit 8b0691c

Please sign in to comment.