mirror of
https://github.com/Elysola/WebHooker.git
synced 2026-11-21 01:23:40 +00:00
fix(auth): revoke stale sessions and tokens
Revoked or rotated credentials must stop working despite stale KV replicas. Track the live token and revocations in D1 and preserve immutable identity bindings rather than trusting a recycled login.
This commit is contained in:
1 parent
5ff2338b48
commit
2bdce90776
5 files changed
+285
-22
No files matched your search
@@ -99,7 +99,8 @@ export async function bearerUserId(event: H3Event): Promise<string> {
|
||||
const auth = getHeader(event, "authorization");
|
||||
if (!auth?.startsWith("Bearer "))
|
||||
throw createError({ statusCode: 401, statusMessage: "Missing authorization" });
|
||||
const userId = await findUserIdByToken(env.KV, auth.slice(7));
|
||||
// Resolves only the user's *current* token: a rotated or revoked one fails.
|
||||
const userId = await findUserIdByToken(env.KV, auth.slice(7), env.DB);
|
||||
if (!userId) throw createError({ statusCode: 401, statusMessage: "Invalid or expired token" });
|
||||
return userId;
|
||||
}
|
||||
Reference in new issue
Block a user