Compare commits
1 Commits
fix/csrf-b
...
chore/ms22
| Author | SHA1 | Date | |
|---|---|---|---|
| 5b692406ed |
@@ -1,5 +1,4 @@
|
|||||||
import { Module } from "@nestjs/common";
|
import { Module } from "@nestjs/common";
|
||||||
import { AuthModule } from "../auth/auth.module";
|
|
||||||
import { AgentConfigModule } from "../agent-config/agent-config.module";
|
import { AgentConfigModule } from "../agent-config/agent-config.module";
|
||||||
import { ContainerLifecycleModule } from "../container-lifecycle/container-lifecycle.module";
|
import { ContainerLifecycleModule } from "../container-lifecycle/container-lifecycle.module";
|
||||||
import { PrismaModule } from "../prisma/prisma.module";
|
import { PrismaModule } from "../prisma/prisma.module";
|
||||||
@@ -7,7 +6,7 @@ import { ChatProxyController } from "./chat-proxy.controller";
|
|||||||
import { ChatProxyService } from "./chat-proxy.service";
|
import { ChatProxyService } from "./chat-proxy.service";
|
||||||
|
|
||||||
@Module({
|
@Module({
|
||||||
imports: [AuthModule, PrismaModule, ContainerLifecycleModule, AgentConfigModule],
|
imports: [PrismaModule, ContainerLifecycleModule, AgentConfigModule],
|
||||||
controllers: [ChatProxyController],
|
controllers: [ChatProxyController],
|
||||||
providers: [ChatProxyService],
|
providers: [ChatProxyService],
|
||||||
exports: [ChatProxyService],
|
exports: [ChatProxyService],
|
||||||
|
|||||||
@@ -87,17 +87,6 @@ describe("CsrfGuard", () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
describe("State-changing methods requiring CSRF", () => {
|
describe("State-changing methods requiring CSRF", () => {
|
||||||
it("should allow POST with Bearer auth without CSRF token", () => {
|
|
||||||
const context = createContext(
|
|
||||||
"POST",
|
|
||||||
{},
|
|
||||||
{ authorization: "Bearer api-token" },
|
|
||||||
false,
|
|
||||||
"user-123"
|
|
||||||
);
|
|
||||||
expect(guard.canActivate(context)).toBe(true);
|
|
||||||
});
|
|
||||||
|
|
||||||
it("should reject POST without CSRF token", () => {
|
it("should reject POST without CSRF token", () => {
|
||||||
const context = createContext("POST", {}, {}, false, "user-123");
|
const context = createContext("POST", {}, {}, false, "user-123");
|
||||||
expect(() => guard.canActivate(context)).toThrow(ForbiddenException);
|
expect(() => guard.canActivate(context)).toThrow(ForbiddenException);
|
||||||
|
|||||||
@@ -57,11 +57,6 @@ export class CsrfGuard implements CanActivate {
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
const authHeader = request.headers.authorization;
|
|
||||||
if (typeof authHeader === "string" && authHeader.startsWith("Bearer ")) {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Get CSRF token from cookie and header
|
// Get CSRF token from cookie and header
|
||||||
const cookies = request.cookies as Record<string, string> | undefined;
|
const cookies = request.cookies as Record<string, string> | undefined;
|
||||||
const cookieToken = cookies?.["csrf-token"];
|
const cookieToken = cookies?.["csrf-token"];
|
||||||
|
|||||||
@@ -1,11 +1,10 @@
|
|||||||
import { Module } from "@nestjs/common";
|
import { Module } from "@nestjs/common";
|
||||||
import { ConfigModule } from "@nestjs/config";
|
|
||||||
import { PrismaModule } from "../prisma/prisma.module";
|
import { PrismaModule } from "../prisma/prisma.module";
|
||||||
import { CryptoModule } from "../crypto/crypto.module";
|
import { CryptoModule } from "../crypto/crypto.module";
|
||||||
import { ContainerLifecycleService } from "./container-lifecycle.service";
|
import { ContainerLifecycleService } from "./container-lifecycle.service";
|
||||||
|
|
||||||
@Module({
|
@Module({
|
||||||
imports: [ConfigModule, PrismaModule, CryptoModule],
|
imports: [PrismaModule, CryptoModule],
|
||||||
providers: [ContainerLifecycleService],
|
providers: [ContainerLifecycleService],
|
||||||
exports: [ContainerLifecycleService],
|
exports: [ContainerLifecycleService],
|
||||||
})
|
})
|
||||||
|
|||||||
@@ -1,12 +1,11 @@
|
|||||||
import { Module } from "@nestjs/common";
|
import { Module } from "@nestjs/common";
|
||||||
import { AuthModule } from "../auth/auth.module";
|
|
||||||
import { PrismaModule } from "../prisma/prisma.module";
|
import { PrismaModule } from "../prisma/prisma.module";
|
||||||
import { CryptoModule } from "../crypto/crypto.module";
|
import { CryptoModule } from "../crypto/crypto.module";
|
||||||
import { FleetSettingsController } from "./fleet-settings.controller";
|
import { FleetSettingsController } from "./fleet-settings.controller";
|
||||||
import { FleetSettingsService } from "./fleet-settings.service";
|
import { FleetSettingsService } from "./fleet-settings.service";
|
||||||
|
|
||||||
@Module({
|
@Module({
|
||||||
imports: [AuthModule, PrismaModule, CryptoModule],
|
imports: [PrismaModule, CryptoModule],
|
||||||
controllers: [FleetSettingsController],
|
controllers: [FleetSettingsController],
|
||||||
providers: [FleetSettingsService],
|
providers: [FleetSettingsService],
|
||||||
exports: [FleetSettingsService],
|
exports: [FleetSettingsService],
|
||||||
|
|||||||
@@ -121,10 +121,6 @@ services:
|
|||||||
OLLAMA_ENDPOINT: ${OLLAMA_ENDPOINT}
|
OLLAMA_ENDPOINT: ${OLLAMA_ENDPOINT}
|
||||||
OPENBAO_ADDR: ${OPENBAO_ADDR}
|
OPENBAO_ADDR: ${OPENBAO_ADDR}
|
||||||
ENCRYPTION_KEY: ${ENCRYPTION_KEY}
|
ENCRYPTION_KEY: ${ENCRYPTION_KEY}
|
||||||
# MS22: fleet encryption key (AES-256-GCM for provider API keys, agent tokens)
|
|
||||||
MOSAIC_SECRET_KEY: ${MOSAIC_SECRET_KEY}
|
|
||||||
# MS22: Docker socket for per-user container lifecycle (optional: set DOCKER_HOST for TCP)
|
|
||||||
DOCKER_HOST: ${DOCKER_HOST:-}
|
|
||||||
# Matrix bridge (optional — configure after Synapse is running)
|
# Matrix bridge (optional — configure after Synapse is running)
|
||||||
MATRIX_HOMESERVER_URL: ${MATRIX_HOMESERVER_URL:-http://synapse:8008}
|
MATRIX_HOMESERVER_URL: ${MATRIX_HOMESERVER_URL:-http://synapse:8008}
|
||||||
MATRIX_ACCESS_TOKEN: ${MATRIX_ACCESS_TOKEN:-}
|
MATRIX_ACCESS_TOKEN: ${MATRIX_ACCESS_TOKEN:-}
|
||||||
@@ -146,8 +142,6 @@ services:
|
|||||||
NEXT_PUBLIC_APP_URL: ${NEXT_PUBLIC_APP_URL}
|
NEXT_PUBLIC_APP_URL: ${NEXT_PUBLIC_APP_URL}
|
||||||
NEXT_PUBLIC_API_URL: ${NEXT_PUBLIC_API_URL}
|
NEXT_PUBLIC_API_URL: ${NEXT_PUBLIC_API_URL}
|
||||||
TRUSTED_ORIGINS: ${TRUSTED_ORIGINS:-}
|
TRUSTED_ORIGINS: ${TRUSTED_ORIGINS:-}
|
||||||
volumes:
|
|
||||||
- /var/run/docker.sock:/var/run/docker.sock:ro
|
|
||||||
healthcheck:
|
healthcheck:
|
||||||
test:
|
test:
|
||||||
[
|
[
|
||||||
|
|||||||
Reference in New Issue
Block a user