aboutsummaryrefslogtreecommitdiffstats
path: root/packages/api/middlewares/prometheusAuth.ts
diff options
context:
space:
mode:
Diffstat (limited to 'packages/api/middlewares/prometheusAuth.ts')
-rw-r--r--packages/api/middlewares/prometheusAuth.ts33
1 files changed, 0 insertions, 33 deletions
diff --git a/packages/api/middlewares/prometheusAuth.ts b/packages/api/middlewares/prometheusAuth.ts
deleted file mode 100644
index bf35608f..00000000
--- a/packages/api/middlewares/prometheusAuth.ts
+++ /dev/null
@@ -1,33 +0,0 @@
-import { createMiddleware } from "hono/factory";
-import { HTTPException } from "hono/http-exception";
-
-import serverConfig from "@karakeep/shared/config";
-
-export const prometheusAuthMiddleware = createMiddleware(async (c, next) => {
- const { metricsToken } = serverConfig.prometheus;
-
- // If no token is configured, deny access (safe default)
- if (!metricsToken) {
- throw new HTTPException(404, {
- message: "Not Found",
- });
- }
-
- const auth = c.req.header("Authorization");
-
- if (!auth || !auth.startsWith("Bearer ")) {
- throw new HTTPException(401, {
- message: "Unauthorized",
- });
- }
-
- const token = auth.slice(7); // Remove "Bearer " prefix
-
- if (token !== metricsToken) {
- throw new HTTPException(401, {
- message: "Unauthorized",
- });
- }
-
- await next();
-});