Skip to content

Commit 8ca431f

Browse files
committed
[server/auth] ensure safe returnTo param
1 parent aced836 commit 8ca431f

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

components/server/src/user/user-controller.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -81,13 +81,15 @@ export class UserController {
8181
}
8282

8383
// Proceed with login
84+
this.ensureSafeReturnToParam(req);
8485
await this.authenticator.authenticate(req, res, next);
8586
});
8687
router.get("/authorize", (req: express.Request, res: express.Response, next: express.NextFunction) => {
8788
if (!User.is(req.user)) {
8889
res.sendStatus(401);
8990
return;
9091
}
92+
this.ensureSafeReturnToParam(req);
9193
this.authenticator.authorize(req, res, next);
9294
});
9395
const branding = this.env.brandingConfig;
@@ -483,6 +485,10 @@ export class UserController {
483485
}
484486
}
485487

488+
protected ensureSafeReturnToParam(req: express.Request) {
489+
req.query.returnTo = this.getSafeReturnToParam(req);
490+
}
491+
486492
protected getSafeReturnToParam(req: express.Request) {
487493
const returnToURL: string | undefined = req.query.redirect || req.query.returnTo;
488494
if (returnToURL) {

0 commit comments

Comments
 (0)