Skip to content

Commit

Permalink
use absolute redirect URLs
Browse files Browse the repository at this point in the history
  • Loading branch information
nk-coding committed Aug 6, 2024
1 parent 393375a commit c14cd34
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 5 deletions.
5 changes: 2 additions & 3 deletions backend/src/api-internal/auth-error-redirect.middleware.ts
Original file line number Diff line number Diff line change
Expand Up @@ -38,9 +38,8 @@ export class AuthErrorRedirectMiddleware extends StateMiddleware<OAuthAuthorizeS
? "register-additional"
: "login";
const encodedState = encodeURIComponent(this.stateJwtService.sign({ request: state.request }));
res.redirect(
`/auth/flow/${target}?error=${encodeURIComponent(error.authErrorMessage)}&strategy_instance=${encodeURIComponent(error.strategyInstanceId)}&state=${encodedState}`,
);
const url = `/auth/flow/${target}?error=${encodeURIComponent(error.authErrorMessage)}&strategy_instance=${encodeURIComponent(error.strategyInstanceId)}&state=${encodedState}`;
res.redirect(new URL(url, process.env.GROPIUS_ENDPOINT).toString());
} else {
next();
}
Expand Down
2 changes: 1 addition & 1 deletion backend/src/api-internal/auth-redirect.middleware.ts
Original file line number Diff line number Diff line change
Expand Up @@ -166,7 +166,7 @@ export class AuthRedirectMiddleware extends StateMiddleware<
suggestions.displayName ?? "",
)}&forceSuggestedUsername=${state.strategy.forceSuggestedUsername}`;
const url = `/auth/flow/register?code=${token}&state=${encodedState}` + suggestionQuery;
res.redirect(url);
res.redirect(new URL(url, process.env.GROPIUS_ENDPOINT).toString());
} else {
await this.redirectWithCode(state, res);
}
Expand Down
3 changes: 2 additions & 1 deletion backend/src/api-oauth/oauth-authorize-redirect.middleware.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ export class OAuthAuthorizeRedirectMiddleware extends StateMiddleware<
? "register-additional"
: "login";
const encodedState = encodeURIComponent(this.stateJwtService.sign({ request: state.request }));
res.redirect(`/auth/flow/${target}?state=${encodedState}`);
const url = `/auth/flow/${target}?state=${encodedState}`;
res.redirect(new URL(url, process.env.GROPIUS_ENDPOINT).toString());
}
}

0 comments on commit c14cd34

Please sign in to comment.