refactor(auth): address server review feedback
- Extract auth DTOs, cookie/JWT helpers and the generic duration parser. - Configure the session cookie and map domain auth failures to HTTP responses. - Add typed Swagger responses and focused regression coverage.
This commit is contained in:
1 parent
72e127888c
commit
1830feb71b
18 files changed
+399
-208
No files matched your search
@@ -1,8 +1,6 @@
|
||||
import "reflect-metadata";
|
||||
import {
|
||||
authDurationSeconds,
|
||||
validateAppConfig,
|
||||
} from "../src/config/app.config";
|
||||
import { validateAppConfig } from "../src/config/app.config";
|
||||
import { durationSeconds } from "../src/common/interval";
|
||||
|
||||
describe("Authentication configuration", () => {
|
||||
it("defaults authentication off with a 24-hour token lifetime and cleanup schedule", () => {
|
||||
@@ -10,6 +8,7 @@ describe("Authentication configuration", () => {
|
||||
|
||||
expect(config.AUTH_ENABLED).toBe(false);
|
||||
expect(config.AUTH_JWT_EXPIRES_IN).toBe("24h");
|
||||
expect(config.AUTH_COOKIE_NAME).toBe("liqa_auth");
|
||||
expect(config.AUTH_REVOKED_TOKEN_CLEANUP_CRON).toBe("0 3 * * *");
|
||||
});
|
||||
|
||||
@@ -46,9 +45,9 @@ describe("Authentication configuration", () => {
|
||||
expect(() => validateAppConfig({ AUTH_ENABLED: "yes" })).toThrow(
|
||||
"AUTH_ENABLED must be either true or false",
|
||||
);
|
||||
expect(authDurationSeconds("30m")).toBe(1800);
|
||||
expect(authDurationSeconds("24h")).toBe(86400);
|
||||
expect(authDurationSeconds("2d")).toBe(172800);
|
||||
expect(authDurationSeconds("0s")).toBeNull();
|
||||
expect(durationSeconds("30m")).toBe(1800);
|
||||
expect(durationSeconds("24h")).toBe(86400);
|
||||
expect(durationSeconds("2d")).toBe(172800);
|
||||
expect(durationSeconds("0s")).toBeNull();
|
||||
});
|
||||
});
|
||||
Reference in new issue
Block a user