Skip to content

Commit 545ba4e

Browse files
authored
fix: remove duplicate query parameters on HTTPS redirect (#6460)
HTTPS redirection rebuilds the full URL using req.originalUrl, which includes query parameters (see https://expressjs.com/en/api.html#req.originalUrl). Prior to this patch, appending the stringified query params to req.originalUrl resulted in duplicate parameters, e.g. wiki.js/callback?session=123&code=abc?session=123&code=abc which caused errors when being redirected from an insecure (http://) callback URL to a secure version when using OIDC (e.g. with keycloak). This issue is probably rare, but in cases where HTTPS redirection is enabled and a user tries to hit an insecure URL with query parameters, it could cause problems.
1 parent 3bf1d9c commit 545ba4e

File tree

1 file changed

+1
-2
lines changed

1 file changed

+1
-2
lines changed

server/controllers/ssl.js

+1-2
Original file line numberDiff line numberDiff line change
@@ -28,8 +28,7 @@ router.get('/.well-known/acme-challenge/:token', (req, res, next) => {
2828
*/
2929
router.all('/*', (req, res, next) => {
3030
if (WIKI.config.server.sslRedir && !req.secure && WIKI.servers.servers.https) {
31-
let query = (!_.isEmpty(req.query)) ? `?${qs.stringify(req.query)}` : ``
32-
return res.redirect(`https://${req.hostname}${req.originalUrl}${query}`)
31+
return res.redirect(`https://${req.hostname}${req.originalUrl}`)
3332
} else {
3433
next()
3534
}

0 commit comments

Comments
 (0)