Skip to content

Commit

Permalink
fix forward auth
Browse files Browse the repository at this point in the history
  • Loading branch information
NextFire committed Apr 10, 2024
1 parent c4beb61 commit b3daef9
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 6 deletions.
10 changes: 6 additions & 4 deletions server/routes/_oauth.get.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,12 @@ import assert from "node:assert/strict";
export default eventHandler(async (event) => {
const session = await useTypedSession(event);
const query = getQuery(event);
const { code, forwardAuthRedirect } = query;
if (forwardAuthRedirect) {
assert(typeof forwardAuthRedirect === "string");
await session.update({ redirect: ".", forwardAuthRedirect });
const { code, proto, host, uri } = query;
if (host) {
await session.update({
redirect: `http://${host}/_oauth`,
forwardAuthRedirect: `${proto}://${host}${uri}`,
});
return sendRedirect(event, `${userConfig.publicUrl}/api/discord/auth`);
} else if (code) {
assert(typeof code === "string");
Expand Down
3 changes: 1 addition & 2 deletions server/routes/traefik.get.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,7 @@ export default eventHandler(async (event) => {
throw createError({ status: 401, message: "Missing required group" });
}
} else {
const forwardAuthRedirect = `${proto}://${host}${uri}`;
const params = new URLSearchParams({ forwardAuthRedirect });
const params = new URLSearchParams({ proto, host, uri });
return sendRedirect(event, `http://${host}/_oauth?${params}`);
}
});

0 comments on commit b3daef9

Please sign in to comment.