feat(auth): add optional authentication boundary
- Add account, JWT session, revocation, cookie and bearer handling. - Protect server surfaces while preserving public health, manifest and disabled mode. - Add SQLite migration and focused server regression coverage.
This commit is contained in:
1 parent
d4bb274982
commit
de41571b5c
33 files changed
+1083
-20
No files matched your search
@@ -16,7 +16,12 @@ import {
|
||||
UploadedFile,
|
||||
} from "@nestjs/common";
|
||||
import { FileInterceptor } from "@nestjs/platform-express";
|
||||
import { ApiOperation, ApiResponse, ApiTags } from "@nestjs/swagger";
|
||||
import {
|
||||
ApiBearerAuth,
|
||||
ApiOperation,
|
||||
ApiResponse,
|
||||
ApiTags,
|
||||
} from "@nestjs/swagger";
|
||||
import { Response } from "express";
|
||||
import { interval, map, merge, type Observable } from "rxjs";
|
||||
import type { File as MulterFile } from "multer";
|
||||
@@ -40,6 +45,7 @@ interface SseMessage {
|
||||
}
|
||||
|
||||
@ApiTags("scenarios")
|
||||
@ApiBearerAuth()
|
||||
@Controller("scenarios")
|
||||
export class ScenarioController {
|
||||
private static readonly HEARTBEAT_MS = 25_000;
|
||||
@@ -60,7 +66,10 @@ export class ScenarioController {
|
||||
}
|
||||
|
||||
@Post("import")
|
||||
@ApiOperation({ summary: "Import a scenario from an export payload (single object or array)" })
|
||||
@ApiOperation({
|
||||
summary:
|
||||
"Import a scenario from an export payload (single object or array)",
|
||||
})
|
||||
@ApiResponse({ status: 201, description: "Scenario imported" })
|
||||
importScenario(@Body() payload: unknown) {
|
||||
return this.scenarioService.importScenario(
|
||||
@@ -200,7 +209,8 @@ export class ScenarioController {
|
||||
|
||||
@Get(":id/export-e2e")
|
||||
@ApiOperation({
|
||||
summary: "Export a scenario as a standalone, plug-and-play Playwright e2e test (zip)",
|
||||
summary:
|
||||
"Export a scenario as a standalone, plug-and-play Playwright e2e test (zip)",
|
||||
})
|
||||
@ApiResponse({ status: 200, description: "Zip archive" })
|
||||
@ApiResponse({ status: 404, description: "Scenario or version not found" })
|
||||
@@ -210,10 +220,8 @@ export class ScenarioController {
|
||||
version: number | undefined,
|
||||
@Res() res: Response,
|
||||
) {
|
||||
const { filename, buffer } = await this.e2eExportService.buildE2eTestPackage(
|
||||
id,
|
||||
version,
|
||||
);
|
||||
const { filename, buffer } =
|
||||
await this.e2eExportService.buildE2eTestPackage(id, version);
|
||||
res.setHeader("Content-Type", "application/zip");
|
||||
res.setHeader("Content-Disposition", `attachment; filename="${filename}"`);
|
||||
res.setHeader("Content-Length", buffer.length);
|
||||
@@ -270,7 +278,8 @@ export class ScenarioController {
|
||||
|
||||
@Get(":id/used-snippets")
|
||||
@ApiOperation({
|
||||
summary: "List snippets referenced (directly or transitively) by this scenario's steps",
|
||||
summary:
|
||||
"List snippets referenced (directly or transitively) by this scenario's steps",
|
||||
})
|
||||
@ApiResponse({ status: 200 })
|
||||
@ApiResponse({ status: 404, description: "Scenario not found" })
|
||||
@@ -375,7 +384,9 @@ export class ScenarioController {
|
||||
const fmt = format === "csv" ? "csv" : "md";
|
||||
const content = await this.scenarioService.exportRunLogs(id, runId, fmt);
|
||||
const contentType =
|
||||
fmt === "csv" ? "text/csv; charset=utf-8" : "text/markdown; charset=utf-8";
|
||||
fmt === "csv"
|
||||
? "text/csv; charset=utf-8"
|
||||
: "text/markdown; charset=utf-8";
|
||||
const ext = fmt === "csv" ? "csv" : "md";
|
||||
res.setHeader("Content-Type", contentType);
|
||||
res.setHeader(
|
||||
|
||||
Reference in new issue
Block a user