Skip to content

Commit

Permalink
fix(oidc): look at protocol to decide callback protocol
Browse files Browse the repository at this point in the history
  • Loading branch information
ankarhem committed Oct 12, 2022
1 parent 66fac20 commit 765c38b
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 2 deletions.
2 changes: 1 addition & 1 deletion server/routes/auth.ts
Original file line number Diff line number Diff line change
Expand Up @@ -434,7 +434,7 @@ authRoutes.get('/oidc-callback', async (req, res, next) => {
return res.status(500).json({ error: 'OIDC sign-in is disabled.' });
}
const cookieState = req.cookies['oidc-state'];
const url = new URL(req.url, `http://${req.hostname}`);
const url = new URL(req.url, `${req.protocol}://${req.hostname}`);
const state = url.searchParams.get('state');

try {
Expand Down
2 changes: 1 addition & 1 deletion server/utils/oidc.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ export async function getOIDCRedirectUrl(req: Request, state: string) {

const callbackUrl = new URL(
'/api/v1/auth/oidc-callback',
`http://${req.headers.host}`
`${req.protocol}://${req.headers.host}`
).toString();
url.searchParams.set('redirect_uri', callbackUrl);
url.searchParams.set('scope', 'openid profile email');
Expand Down

0 comments on commit 765c38b

Please sign in to comment.