fix(auth): invalidate session server-side on logout, not just the cookie
/auth/logout previously only cleared the client's cookie, leaving the session token valid in the sessions table — a stolen cookie captured before logout would still work afterwards. Add BackendDbInterface#deleteSession (implemented in SqliteInterface) and call it from the logout route using the session token from the cookie. Caught by the new auth-http.test.ts integration test, updated to assert the session is actually invalidated. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
This commit was merged in pull request #2.
This commit is contained in:
@@ -74,7 +74,7 @@ describe("api backend: auth over HTTP", async () => {
|
||||
assert.equal(res.status, 401);
|
||||
});
|
||||
|
||||
it("POST /auth/logout clears the session cookie", async () => {
|
||||
it("POST /auth/logout clears the cookie and invalidates the session server-side", async () => {
|
||||
const login = await fetch(`${server.url}/auth/login`, {
|
||||
method: "POST",
|
||||
headers: { "Content-Type": "application/json" },
|
||||
@@ -88,6 +88,11 @@ describe("api backend: auth over HTTP", async () => {
|
||||
});
|
||||
assert.equal(logout.status, 204);
|
||||
assert.equal(getCookie(logout, "abode_session"), "");
|
||||
|
||||
const self = await fetch(`${server.url}/auth/self`, {
|
||||
headers: { Cookie: `abode_session=${cookie}` },
|
||||
});
|
||||
assert.equal(self.status, 401, "session was invalidated server-side, not just the cookie cleared");
|
||||
});
|
||||
|
||||
it("POST /auth/clear-sessions invalidates outstanding session cookies", async () => {
|
||||
|
||||
Reference in New Issue
Block a user