Compare commits

..

No commits in common. "97101cfcc3a5d29c5dd15e47f3c878d16fade060" and "067594e669dfffd66ab09d54dd8d434ccb699a02" have entirely different histories.

View file

@ -28,15 +28,6 @@ const oidcClaimsHook = async (orig: OidcAuth | undefined, claims: IDToken | unde
};
};
app.get("/auth/logout", async (c) => {
const auth = await getAuth(c);
if (!auth) {
return c.json({ status: 401, message: "Unauthorized" }, 401);
}
await revokeSession(c);
return c.json({ status: 200, message: "OK" });
});
app.get("/auth/callback", async (c: Context) => {
c.set("oidcClaimsHook", oidcClaimsHook);
return processOAuthCallback(c);
@ -45,6 +36,22 @@ app.get("/auth/callback", async (c: Context) => {
app.use(logger(), compress());
app.use("/", serveStatic({ root: "./public" }));
app.use("/auth/*", oidcAuthMiddleware());
app.use("/auth/*", async (c, next) => {
const auth = await getAuth(c);
if (!auth) {
return c.json({ status: 401, message: "Unauthorized" }, 401);
}
await next();
});
app.get("/auth/logout", async (c) => {
const auth = await getAuth(c);
if (!auth) {
return c.json({ status: 401, message: "Unauthorized" }, 401);
}
await revokeSession(c);
return c.json({ status: 200, message: "OK" });
});
app.get("/auth/login", async (c) => {
const auth = await getAuth(c);
@ -93,12 +100,6 @@ app.get("/stats", async (c) => {
});
app.onError((err, c) => {
const isDev = Deno.env.get("NODE_ENV") === "development";
if (isDev) {
console.error(err);
console.log(Deno.env.toObject());
return c.json({ status: 500, message: "Server Error", error: err.message }, 500);
}
return c.json({ status: 500, message: "Server Error" }, 500);
});