fix: remove AuthGuard('jwt') from all service controllers
Kong handles JWT validation at the gateway level. Service-level
AuthGuard('jwt') fails because services don't register a Passport
JWT strategy (only auth-service does). Removed from 17 controllers
across ops, inventory, monitor, comm, audit, and agent services.
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
parent
c710303b60
commit
806113554b
|
|
@ -1,5 +1,4 @@
|
||||||
import { Controller, Post, Body, Param, Delete, Get, UseGuards, NotFoundException, BadRequestException } from '@nestjs/common';
|
import { Controller, Post, Body, Param, Delete, Get, NotFoundException, BadRequestException } from '@nestjs/common';
|
||||||
import { AuthGuard } from '@nestjs/passport';
|
|
||||||
import { TenantId } from '@it0/common';
|
import { TenantId } from '@it0/common';
|
||||||
import { EngineRegistry } from '../../../infrastructure/engines/engine-registry';
|
import { EngineRegistry } from '../../../infrastructure/engines/engine-registry';
|
||||||
import { AgentStreamGateway } from '../../ws/agent-stream.gateway';
|
import { AgentStreamGateway } from '../../ws/agent-stream.gateway';
|
||||||
|
|
@ -22,7 +21,6 @@ export class AgentController {
|
||||||
|
|
||||||
// TODO 10: Execute task
|
// TODO 10: Execute task
|
||||||
@Post('tasks')
|
@Post('tasks')
|
||||||
@UseGuards(AuthGuard('jwt'))
|
|
||||||
async executeTask(
|
async executeTask(
|
||||||
@TenantId() tenantId: string,
|
@TenantId() tenantId: string,
|
||||||
@Body() body: { prompt: string; systemPrompt?: string; maxTurns?: number; allowedTools?: string[] },
|
@Body() body: { prompt: string; systemPrompt?: string; maxTurns?: number; allowedTools?: string[] },
|
||||||
|
|
@ -115,7 +113,6 @@ export class AgentController {
|
||||||
|
|
||||||
// TODO 11: Cancel task
|
// TODO 11: Cancel task
|
||||||
@Delete('tasks/:taskId')
|
@Delete('tasks/:taskId')
|
||||||
@UseGuards(AuthGuard('jwt'))
|
|
||||||
async cancelTask(@Param('taskId') taskId: string) {
|
async cancelTask(@Param('taskId') taskId: string) {
|
||||||
const task = await this.taskRepository.findById(taskId);
|
const task = await this.taskRepository.findById(taskId);
|
||||||
if (!task) {
|
if (!task) {
|
||||||
|
|
@ -143,7 +140,6 @@ export class AgentController {
|
||||||
|
|
||||||
// TODO 12: Approve command
|
// TODO 12: Approve command
|
||||||
@Post('tasks/:taskId/approve')
|
@Post('tasks/:taskId/approve')
|
||||||
@UseGuards(AuthGuard('jwt'))
|
|
||||||
async approveCommand(@Param('taskId') taskId: string, @Body() body: { approved: boolean }) {
|
async approveCommand(@Param('taskId') taskId: string, @Body() body: { approved: boolean }) {
|
||||||
const task = await this.taskRepository.findById(taskId);
|
const task = await this.taskRepository.findById(taskId);
|
||||||
if (!task) {
|
if (!task) {
|
||||||
|
|
@ -230,7 +226,6 @@ export class AgentController {
|
||||||
|
|
||||||
// TODO 13: List engines
|
// TODO 13: List engines
|
||||||
@Get('engines')
|
@Get('engines')
|
||||||
@UseGuards(AuthGuard('jwt'))
|
|
||||||
async listEngines() {
|
async listEngines() {
|
||||||
const engines = this.engineRegistry.listAvailable();
|
const engines = this.engineRegistry.listAvailable();
|
||||||
return { engines };
|
return { engines };
|
||||||
|
|
@ -238,7 +233,6 @@ export class AgentController {
|
||||||
|
|
||||||
// TODO 14: Switch engine
|
// TODO 14: Switch engine
|
||||||
@Post('engines/switch')
|
@Post('engines/switch')
|
||||||
@UseGuards(AuthGuard('jwt'))
|
|
||||||
async switchEngine(@Body() body: { engineType: string }) {
|
async switchEngine(@Body() body: { engineType: string }) {
|
||||||
const engine = this.engineRegistry.switchEngine(body.engineType as AgentEngineType);
|
const engine = this.engineRegistry.switchEngine(body.engineType as AgentEngineType);
|
||||||
return { message: 'Engine switched', engineType: engine.engineType };
|
return { message: 'Engine switched', engineType: engine.engineType };
|
||||||
|
|
|
||||||
|
|
@ -6,10 +6,8 @@ import {
|
||||||
Delete,
|
Delete,
|
||||||
Param,
|
Param,
|
||||||
Body,
|
Body,
|
||||||
UseGuards,
|
|
||||||
NotFoundException,
|
NotFoundException,
|
||||||
} from '@nestjs/common';
|
} from '@nestjs/common';
|
||||||
import { AuthGuard } from '@nestjs/passport';
|
|
||||||
import * as crypto from 'crypto';
|
import * as crypto from 'crypto';
|
||||||
|
|
||||||
interface RiskRule {
|
interface RiskRule {
|
||||||
|
|
@ -47,13 +45,11 @@ export class RiskRulesController {
|
||||||
/* ---------- Risk Rules CRUD ---------- */
|
/* ---------- Risk Rules CRUD ---------- */
|
||||||
|
|
||||||
@Get('risk-rules')
|
@Get('risk-rules')
|
||||||
@UseGuards(AuthGuard('jwt'))
|
|
||||||
listRules() {
|
listRules() {
|
||||||
return { data: this.rules, total: this.rules.length };
|
return { data: this.rules, total: this.rules.length };
|
||||||
}
|
}
|
||||||
|
|
||||||
@Post('risk-rules')
|
@Post('risk-rules')
|
||||||
@UseGuards(AuthGuard('jwt'))
|
|
||||||
createRule(@Body() body: any) {
|
createRule(@Body() body: any) {
|
||||||
const now = new Date().toISOString();
|
const now = new Date().toISOString();
|
||||||
const rule: RiskRule = {
|
const rule: RiskRule = {
|
||||||
|
|
@ -71,7 +67,6 @@ export class RiskRulesController {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Put('risk-rules/:id')
|
@Put('risk-rules/:id')
|
||||||
@UseGuards(AuthGuard('jwt'))
|
|
||||||
updateRule(@Param('id') id: string, @Body() body: any) {
|
updateRule(@Param('id') id: string, @Body() body: any) {
|
||||||
const rule = this.rules.find((r) => r.id === id);
|
const rule = this.rules.find((r) => r.id === id);
|
||||||
if (!rule) {
|
if (!rule) {
|
||||||
|
|
@ -87,7 +82,6 @@ export class RiskRulesController {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Delete('risk-rules/:id')
|
@Delete('risk-rules/:id')
|
||||||
@UseGuards(AuthGuard('jwt'))
|
|
||||||
deleteRule(@Param('id') id: string) {
|
deleteRule(@Param('id') id: string) {
|
||||||
const idx = this.rules.findIndex((r) => r.id === id);
|
const idx = this.rules.findIndex((r) => r.id === id);
|
||||||
if (idx === -1) {
|
if (idx === -1) {
|
||||||
|
|
@ -100,13 +94,11 @@ export class RiskRulesController {
|
||||||
/* ---------- Permissions ---------- */
|
/* ---------- Permissions ---------- */
|
||||||
|
|
||||||
@Get('permissions')
|
@Get('permissions')
|
||||||
@UseGuards(AuthGuard('jwt'))
|
|
||||||
getPermissions() {
|
getPermissions() {
|
||||||
return this.permissionMatrix;
|
return this.permissionMatrix;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Put('permissions')
|
@Put('permissions')
|
||||||
@UseGuards(AuthGuard('jwt'))
|
|
||||||
updatePermissions(@Body() body: PermissionMatrix) {
|
updatePermissions(@Body() body: PermissionMatrix) {
|
||||||
this.permissionMatrix = { ...this.permissionMatrix, ...body };
|
this.permissionMatrix = { ...this.permissionMatrix, ...body };
|
||||||
return this.permissionMatrix;
|
return this.permissionMatrix;
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,4 @@
|
||||||
import { Controller, Get, Param, UseGuards, NotFoundException } from '@nestjs/common';
|
import { Controller, Get, Param, NotFoundException } from '@nestjs/common';
|
||||||
import { AuthGuard } from '@nestjs/passport';
|
|
||||||
import { TenantId } from '@it0/common';
|
import { TenantId } from '@it0/common';
|
||||||
import { SessionRepository } from '../../../infrastructure/repositories/session.repository';
|
import { SessionRepository } from '../../../infrastructure/repositories/session.repository';
|
||||||
import { TaskRepository } from '../../../infrastructure/repositories/task.repository';
|
import { TaskRepository } from '../../../infrastructure/repositories/task.repository';
|
||||||
|
|
@ -13,14 +12,12 @@ export class SessionController {
|
||||||
|
|
||||||
// TODO 15: List sessions
|
// TODO 15: List sessions
|
||||||
@Get()
|
@Get()
|
||||||
@UseGuards(AuthGuard('jwt'))
|
|
||||||
async listSessions(@TenantId() tenantId: string) {
|
async listSessions(@TenantId() tenantId: string) {
|
||||||
return this.sessionRepository.findByTenant(tenantId);
|
return this.sessionRepository.findByTenant(tenantId);
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO 16: Get session details
|
// TODO 16: Get session details
|
||||||
@Get(':sessionId')
|
@Get(':sessionId')
|
||||||
@UseGuards(AuthGuard('jwt'))
|
|
||||||
async getSession(@Param('sessionId') sessionId: string) {
|
async getSession(@Param('sessionId') sessionId: string) {
|
||||||
const session = await this.sessionRepository.findById(sessionId);
|
const session = await this.sessionRepository.findById(sessionId);
|
||||||
if (!session) {
|
if (!session) {
|
||||||
|
|
@ -31,7 +28,6 @@ export class SessionController {
|
||||||
|
|
||||||
// TODO 17: Get session history
|
// TODO 17: Get session history
|
||||||
@Get(':sessionId/history')
|
@Get(':sessionId/history')
|
||||||
@UseGuards(AuthGuard('jwt'))
|
|
||||||
async getSessionHistory(@Param('sessionId') sessionId: string) {
|
async getSessionHistory(@Param('sessionId') sessionId: string) {
|
||||||
return this.taskRepository.findBySessionId(sessionId);
|
return this.taskRepository.findBySessionId(sessionId);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,4 @@
|
||||||
import { Controller, Get, Query, UseGuards } from '@nestjs/common';
|
import { Controller, Get, Query, UseGuards } from '@nestjs/common';
|
||||||
import { AuthGuard } from '@nestjs/passport';
|
|
||||||
import { Roles, RolesGuard } from '@it0/common';
|
import { Roles, RolesGuard } from '@it0/common';
|
||||||
import { AuditLogRepository } from '../../../infrastructure/repositories/audit-log.repository';
|
import { AuditLogRepository } from '../../../infrastructure/repositories/audit-log.repository';
|
||||||
|
|
||||||
|
|
@ -8,7 +7,7 @@ export class AuditController {
|
||||||
constructor(private readonly auditLogRepository: AuditLogRepository) {}
|
constructor(private readonly auditLogRepository: AuditLogRepository) {}
|
||||||
|
|
||||||
@Get('logs')
|
@Get('logs')
|
||||||
@UseGuards(AuthGuard('jwt'), RolesGuard)
|
@UseGuards(RolesGuard)
|
||||||
@Roles('admin')
|
@Roles('admin')
|
||||||
async queryLogs(
|
async queryLogs(
|
||||||
@Query('actionType') actionType?: string,
|
@Query('actionType') actionType?: string,
|
||||||
|
|
@ -36,7 +35,7 @@ export class AuditController {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Get('logs/export')
|
@Get('logs/export')
|
||||||
@UseGuards(AuthGuard('jwt'), RolesGuard)
|
@UseGuards(RolesGuard)
|
||||||
@Roles('admin')
|
@Roles('admin')
|
||||||
async exportLogs(@Query('format') format: 'json' | 'csv' = 'json') {
|
async exportLogs(@Query('format') format: 'json' | 'csv' = 'json') {
|
||||||
return this.auditLogRepository.exportLogs(format);
|
return this.auditLogRepository.exportLogs(format);
|
||||||
|
|
|
||||||
|
|
@ -4,14 +4,11 @@ import {
|
||||||
Patch,
|
Patch,
|
||||||
Param,
|
Param,
|
||||||
Body,
|
Body,
|
||||||
UseGuards,
|
|
||||||
NotFoundException,
|
NotFoundException,
|
||||||
} from '@nestjs/common';
|
} from '@nestjs/common';
|
||||||
import { AuthGuard } from '@nestjs/passport';
|
|
||||||
import { AdapterRegistry } from '../../../infrastructure/adapters/adapter-registry';
|
import { AdapterRegistry } from '../../../infrastructure/adapters/adapter-registry';
|
||||||
|
|
||||||
@Controller('api/v1/comm/channels')
|
@Controller('api/v1/comm/channels')
|
||||||
@UseGuards(AuthGuard('jwt'))
|
|
||||||
export class ChannelController {
|
export class ChannelController {
|
||||||
constructor(private readonly adapterRegistry: AdapterRegistry) {}
|
constructor(private readonly adapterRegistry: AdapterRegistry) {}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,4 @@
|
||||||
import { Controller, Get, Post, Put, Delete, Body, Param, UseGuards, NotFoundException } from '@nestjs/common';
|
import { Controller, Get, Post, Put, Delete, Body, Param, NotFoundException } from '@nestjs/common';
|
||||||
import { AuthGuard } from '@nestjs/passport';
|
|
||||||
import { ContactRepository } from '../../../infrastructure/repositories/contact.repository';
|
import { ContactRepository } from '../../../infrastructure/repositories/contact.repository';
|
||||||
import { Contact } from '../../../domain/entities/contact.entity';
|
import { Contact } from '../../../domain/entities/contact.entity';
|
||||||
import * as crypto from 'crypto';
|
import * as crypto from 'crypto';
|
||||||
|
|
@ -9,13 +8,11 @@ export class ContactController {
|
||||||
constructor(private readonly contactRepository: ContactRepository) {}
|
constructor(private readonly contactRepository: ContactRepository) {}
|
||||||
|
|
||||||
@Get()
|
@Get()
|
||||||
@UseGuards(AuthGuard('jwt'))
|
|
||||||
async listContacts() {
|
async listContacts() {
|
||||||
return this.contactRepository.findAll();
|
return this.contactRepository.findAll();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Post()
|
@Post()
|
||||||
@UseGuards(AuthGuard('jwt'))
|
|
||||||
async createContact(@Body() body: any) {
|
async createContact(@Body() body: any) {
|
||||||
const contact = new Contact();
|
const contact = new Contact();
|
||||||
contact.id = crypto.randomUUID();
|
contact.id = crypto.randomUUID();
|
||||||
|
|
@ -32,7 +29,6 @@ export class ContactController {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Put(':id')
|
@Put(':id')
|
||||||
@UseGuards(AuthGuard('jwt'))
|
|
||||||
async updateContact(@Param('id') id: string, @Body() body: any) {
|
async updateContact(@Param('id') id: string, @Body() body: any) {
|
||||||
const contact = await this.contactRepository.findById(id);
|
const contact = await this.contactRepository.findById(id);
|
||||||
if (!contact) {
|
if (!contact) {
|
||||||
|
|
@ -43,7 +39,6 @@ export class ContactController {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Delete(':id')
|
@Delete(':id')
|
||||||
@UseGuards(AuthGuard('jwt'))
|
|
||||||
async deleteContact(@Param('id') id: string) {
|
async deleteContact(@Param('id') id: string) {
|
||||||
const contact = await this.contactRepository.findById(id);
|
const contact = await this.contactRepository.findById(id);
|
||||||
if (!contact) {
|
if (!contact) {
|
||||||
|
|
|
||||||
|
|
@ -6,10 +6,8 @@ import {
|
||||||
Delete,
|
Delete,
|
||||||
Param,
|
Param,
|
||||||
Body,
|
Body,
|
||||||
UseGuards,
|
|
||||||
NotFoundException,
|
NotFoundException,
|
||||||
} from '@nestjs/common';
|
} from '@nestjs/common';
|
||||||
import { AuthGuard } from '@nestjs/passport';
|
|
||||||
import { EscalationPolicyRepository } from '../../../infrastructure/repositories/escalation-policy.repository';
|
import { EscalationPolicyRepository } from '../../../infrastructure/repositories/escalation-policy.repository';
|
||||||
import { EscalationPolicy } from '../../../domain/entities/escalation-policy.entity';
|
import { EscalationPolicy } from '../../../domain/entities/escalation-policy.entity';
|
||||||
import * as crypto from 'crypto';
|
import * as crypto from 'crypto';
|
||||||
|
|
@ -21,14 +19,12 @@ export class EscalationPolicyController {
|
||||||
) {}
|
) {}
|
||||||
|
|
||||||
@Get()
|
@Get()
|
||||||
@UseGuards(AuthGuard('jwt'))
|
|
||||||
async listPolicies() {
|
async listPolicies() {
|
||||||
const policies = await this.policyRepository.findAll();
|
const policies = await this.policyRepository.findAll();
|
||||||
return policies.map((p) => this.serialize(p));
|
return policies.map((p) => this.serialize(p));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Get(':id')
|
@Get(':id')
|
||||||
@UseGuards(AuthGuard('jwt'))
|
|
||||||
async getPolicy(@Param('id') id: string) {
|
async getPolicy(@Param('id') id: string) {
|
||||||
const policy = await this.policyRepository.findById(id);
|
const policy = await this.policyRepository.findById(id);
|
||||||
if (!policy) {
|
if (!policy) {
|
||||||
|
|
@ -38,7 +34,6 @@ export class EscalationPolicyController {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Post()
|
@Post()
|
||||||
@UseGuards(AuthGuard('jwt'))
|
|
||||||
async createPolicy(@Body() body: any) {
|
async createPolicy(@Body() body: any) {
|
||||||
const policy = new EscalationPolicy();
|
const policy = new EscalationPolicy();
|
||||||
policy.id = crypto.randomUUID();
|
policy.id = crypto.randomUUID();
|
||||||
|
|
@ -52,7 +47,6 @@ export class EscalationPolicyController {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Put(':id')
|
@Put(':id')
|
||||||
@UseGuards(AuthGuard('jwt'))
|
|
||||||
async updatePolicy(@Param('id') id: string, @Body() body: any) {
|
async updatePolicy(@Param('id') id: string, @Body() body: any) {
|
||||||
const policy = await this.policyRepository.findById(id);
|
const policy = await this.policyRepository.findById(id);
|
||||||
if (!policy) {
|
if (!policy) {
|
||||||
|
|
@ -67,7 +61,6 @@ export class EscalationPolicyController {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Delete(':id')
|
@Delete(':id')
|
||||||
@UseGuards(AuthGuard('jwt'))
|
|
||||||
async deletePolicy(@Param('id') id: string) {
|
async deletePolicy(@Param('id') id: string) {
|
||||||
const policy = await this.policyRepository.findById(id);
|
const policy = await this.policyRepository.findById(id);
|
||||||
if (!policy) {
|
if (!policy) {
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,4 @@
|
||||||
import { Controller, Get, Post, Body, Query, UseGuards } from '@nestjs/common';
|
import { Controller, Get, Post, Body, Query } from '@nestjs/common';
|
||||||
import { AuthGuard } from '@nestjs/passport';
|
|
||||||
import { MessageRepository } from '../../../infrastructure/repositories/message.repository';
|
import { MessageRepository } from '../../../infrastructure/repositories/message.repository';
|
||||||
import { Message } from '../../../domain/entities/message.entity';
|
import { Message } from '../../../domain/entities/message.entity';
|
||||||
import * as crypto from 'crypto';
|
import * as crypto from 'crypto';
|
||||||
|
|
@ -9,7 +8,6 @@ export class MessageController {
|
||||||
constructor(private readonly messageRepository: MessageRepository) {}
|
constructor(private readonly messageRepository: MessageRepository) {}
|
||||||
|
|
||||||
@Get()
|
@Get()
|
||||||
@UseGuards(AuthGuard('jwt'))
|
|
||||||
async listMessages(@Query('direction') direction?: string) {
|
async listMessages(@Query('direction') direction?: string) {
|
||||||
if (direction) {
|
if (direction) {
|
||||||
return this.messageRepository.findByDirection(direction);
|
return this.messageRepository.findByDirection(direction);
|
||||||
|
|
@ -18,7 +16,6 @@ export class MessageController {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Post()
|
@Post()
|
||||||
@UseGuards(AuthGuard('jwt'))
|
|
||||||
async sendMessage(@Body() body: any) {
|
async sendMessage(@Body() body: any) {
|
||||||
const message = new Message();
|
const message = new Message();
|
||||||
message.id = crypto.randomUUID();
|
message.id = crypto.randomUUID();
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,4 @@
|
||||||
import { Controller, Get, Post, Body, Param, UseGuards, NotFoundException } from '@nestjs/common';
|
import { Controller, Get, Post, Body, Param, NotFoundException } from '@nestjs/common';
|
||||||
import { AuthGuard } from '@nestjs/passport';
|
|
||||||
import { ClusterRepository } from '../../../infrastructure/repositories/cluster.repository';
|
import { ClusterRepository } from '../../../infrastructure/repositories/cluster.repository';
|
||||||
import { Cluster } from '../../../domain/entities/cluster.entity';
|
import { Cluster } from '../../../domain/entities/cluster.entity';
|
||||||
import * as crypto from 'crypto';
|
import * as crypto from 'crypto';
|
||||||
|
|
@ -9,13 +8,11 @@ export class ClusterController {
|
||||||
constructor(private readonly clusterRepository: ClusterRepository) {}
|
constructor(private readonly clusterRepository: ClusterRepository) {}
|
||||||
|
|
||||||
@Get()
|
@Get()
|
||||||
@UseGuards(AuthGuard('jwt'))
|
|
||||||
async listClusters() {
|
async listClusters() {
|
||||||
return this.clusterRepository.findAll();
|
return this.clusterRepository.findAll();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Post()
|
@Post()
|
||||||
@UseGuards(AuthGuard('jwt'))
|
|
||||||
async createCluster(@Body() body: any) {
|
async createCluster(@Body() body: any) {
|
||||||
const cluster = new Cluster();
|
const cluster = new Cluster();
|
||||||
cluster.id = crypto.randomUUID();
|
cluster.id = crypto.randomUUID();
|
||||||
|
|
@ -29,7 +26,6 @@ export class ClusterController {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Get(':id')
|
@Get(':id')
|
||||||
@UseGuards(AuthGuard('jwt'))
|
|
||||||
async getCluster(@Param('id') id: string) {
|
async getCluster(@Param('id') id: string) {
|
||||||
const cluster = await this.clusterRepository.findById(id);
|
const cluster = await this.clusterRepository.findById(id);
|
||||||
if (!cluster) {
|
if (!cluster) {
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,4 @@
|
||||||
import { Controller, Get, Post, Delete, Body, Param, UseGuards, NotFoundException } from '@nestjs/common';
|
import { Controller, Get, Post, Delete, Body, Param, UseGuards, NotFoundException } from '@nestjs/common';
|
||||||
import { AuthGuard } from '@nestjs/passport';
|
|
||||||
import { Roles, RolesGuard } from '@it0/common';
|
import { Roles, RolesGuard } from '@it0/common';
|
||||||
import { CredentialRepository } from '../../../infrastructure/repositories/credential.repository';
|
import { CredentialRepository } from '../../../infrastructure/repositories/credential.repository';
|
||||||
import { CredentialVaultService } from '../../../infrastructure/crypto/credential-vault.service';
|
import { CredentialVaultService } from '../../../infrastructure/crypto/credential-vault.service';
|
||||||
|
|
@ -14,14 +13,12 @@ export class CredentialController {
|
||||||
) {}
|
) {}
|
||||||
|
|
||||||
@Get()
|
@Get()
|
||||||
@UseGuards(AuthGuard('jwt'))
|
|
||||||
async listCredentials() {
|
async listCredentials() {
|
||||||
const credentials = await this.credentialRepository.findAll();
|
const credentials = await this.credentialRepository.findAll();
|
||||||
return credentials.map(c => this.toSafeOutput(c));
|
return credentials.map(c => this.toSafeOutput(c));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Post()
|
@Post()
|
||||||
@UseGuards(AuthGuard('jwt'))
|
|
||||||
async createCredential(
|
async createCredential(
|
||||||
@Body() body: { name: string; type: string; plainValue: string; keyType?: string; expiresAt?: string },
|
@Body() body: { name: string; type: string; plainValue: string; keyType?: string; expiresAt?: string },
|
||||||
) {
|
) {
|
||||||
|
|
@ -42,7 +39,6 @@ export class CredentialController {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Get(':id')
|
@Get(':id')
|
||||||
@UseGuards(AuthGuard('jwt'))
|
|
||||||
async getCredential(@Param('id') id: string) {
|
async getCredential(@Param('id') id: string) {
|
||||||
const credential = await this.credentialRepository.findById(id);
|
const credential = await this.credentialRepository.findById(id);
|
||||||
if (!credential) {
|
if (!credential) {
|
||||||
|
|
@ -52,7 +48,6 @@ export class CredentialController {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Delete(':id')
|
@Delete(':id')
|
||||||
@UseGuards(AuthGuard('jwt'))
|
|
||||||
async deleteCredential(@Param('id') id: string) {
|
async deleteCredential(@Param('id') id: string) {
|
||||||
const credential = await this.credentialRepository.findById(id);
|
const credential = await this.credentialRepository.findById(id);
|
||||||
if (!credential) {
|
if (!credential) {
|
||||||
|
|
@ -63,7 +58,7 @@ export class CredentialController {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Post(':id/decrypt')
|
@Post(':id/decrypt')
|
||||||
@UseGuards(AuthGuard('jwt'), RolesGuard)
|
@UseGuards(RolesGuard)
|
||||||
@Roles('admin')
|
@Roles('admin')
|
||||||
async decryptCredential(@Param('id') id: string) {
|
async decryptCredential(@Param('id') id: string) {
|
||||||
const credential = await this.credentialRepository.findById(id);
|
const credential = await this.credentialRepository.findById(id);
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,4 @@
|
||||||
import { Controller, Get, Post, Put, Delete, Body, Param, Query, UseGuards, NotFoundException } from '@nestjs/common';
|
import { Controller, Get, Post, Put, Delete, Body, Param, Query, NotFoundException } from '@nestjs/common';
|
||||||
import { AuthGuard } from '@nestjs/passport';
|
|
||||||
import { ServerRepository } from '../../../infrastructure/repositories/server.repository';
|
import { ServerRepository } from '../../../infrastructure/repositories/server.repository';
|
||||||
import { Server } from '../../../domain/entities/server.entity';
|
import { Server } from '../../../domain/entities/server.entity';
|
||||||
import * as crypto from 'crypto';
|
import * as crypto from 'crypto';
|
||||||
|
|
@ -17,7 +16,6 @@ export class ServerController {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Get()
|
@Get()
|
||||||
@UseGuards(AuthGuard('jwt'))
|
|
||||||
async listServers(@Query('environment') env?: string) {
|
async listServers(@Query('environment') env?: string) {
|
||||||
const servers = env
|
const servers = env
|
||||||
? await this.serverRepository.findByEnvironment(env)
|
? await this.serverRepository.findByEnvironment(env)
|
||||||
|
|
@ -26,7 +24,6 @@ export class ServerController {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Post()
|
@Post()
|
||||||
@UseGuards(AuthGuard('jwt'))
|
|
||||||
async createServer(@Body() body: any) {
|
async createServer(@Body() body: any) {
|
||||||
const server = new Server();
|
const server = new Server();
|
||||||
server.id = crypto.randomUUID();
|
server.id = crypto.randomUUID();
|
||||||
|
|
@ -51,7 +48,6 @@ export class ServerController {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Get(':id')
|
@Get(':id')
|
||||||
@UseGuards(AuthGuard('jwt'))
|
|
||||||
async getServer(@Param('id') id: string) {
|
async getServer(@Param('id') id: string) {
|
||||||
const server = await this.serverRepository.findById(id);
|
const server = await this.serverRepository.findById(id);
|
||||||
if (!server) {
|
if (!server) {
|
||||||
|
|
@ -61,7 +57,6 @@ export class ServerController {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Put(':id')
|
@Put(':id')
|
||||||
@UseGuards(AuthGuard('jwt'))
|
|
||||||
async updateServer(@Param('id') id: string, @Body() body: any) {
|
async updateServer(@Param('id') id: string, @Body() body: any) {
|
||||||
const server = await this.serverRepository.findById(id);
|
const server = await this.serverRepository.findById(id);
|
||||||
if (!server) {
|
if (!server) {
|
||||||
|
|
@ -76,7 +71,6 @@ export class ServerController {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Delete(':id')
|
@Delete(':id')
|
||||||
@UseGuards(AuthGuard('jwt'))
|
|
||||||
async deleteServer(@Param('id') id: string) {
|
async deleteServer(@Param('id') id: string) {
|
||||||
const server = await this.serverRepository.findById(id);
|
const server = await this.serverRepository.findById(id);
|
||||||
if (!server) {
|
if (!server) {
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,4 @@
|
||||||
import { Controller, Get, Post, Put, Body, Param, Query, UseGuards, NotFoundException } from '@nestjs/common';
|
import { Controller, Get, Post, Put, Body, Param, Query, NotFoundException } from '@nestjs/common';
|
||||||
import { AuthGuard } from '@nestjs/passport';
|
|
||||||
import { AlertRuleRepository } from '../../../infrastructure/repositories/alert-rule.repository';
|
import { AlertRuleRepository } from '../../../infrastructure/repositories/alert-rule.repository';
|
||||||
import { AlertEventRepository } from '../../../infrastructure/repositories/alert-event.repository';
|
import { AlertEventRepository } from '../../../infrastructure/repositories/alert-event.repository';
|
||||||
import { AlertRule } from '../../../domain/entities/alert-rule.entity';
|
import { AlertRule } from '../../../domain/entities/alert-rule.entity';
|
||||||
|
|
@ -13,13 +12,11 @@ export class AlertController {
|
||||||
) {}
|
) {}
|
||||||
|
|
||||||
@Get('rules')
|
@Get('rules')
|
||||||
@UseGuards(AuthGuard('jwt'))
|
|
||||||
async listRules() {
|
async listRules() {
|
||||||
return this.alertRuleRepository.findAll();
|
return this.alertRuleRepository.findAll();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Post('rules')
|
@Post('rules')
|
||||||
@UseGuards(AuthGuard('jwt'))
|
|
||||||
async createRule(@Body() body: any) {
|
async createRule(@Body() body: any) {
|
||||||
const rule = new AlertRule();
|
const rule = new AlertRule();
|
||||||
rule.id = crypto.randomUUID();
|
rule.id = crypto.randomUUID();
|
||||||
|
|
@ -36,7 +33,6 @@ export class AlertController {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Get('events')
|
@Get('events')
|
||||||
@UseGuards(AuthGuard('jwt'))
|
|
||||||
async listEvents(@Query('status') status?: string) {
|
async listEvents(@Query('status') status?: string) {
|
||||||
if (status) {
|
if (status) {
|
||||||
return this.alertEventRepository.findByStatus(status);
|
return this.alertEventRepository.findByStatus(status);
|
||||||
|
|
@ -45,7 +41,6 @@ export class AlertController {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Put('events/:id/acknowledge')
|
@Put('events/:id/acknowledge')
|
||||||
@UseGuards(AuthGuard('jwt'))
|
|
||||||
async acknowledgeEvent(@Param('id') id: string) {
|
async acknowledgeEvent(@Param('id') id: string) {
|
||||||
const event = await this.alertEventRepository.findById(id);
|
const event = await this.alertEventRepository.findById(id);
|
||||||
if (!event) {
|
if (!event) {
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,4 @@
|
||||||
import { Controller, Get, Post, Body, Query, UseGuards } from '@nestjs/common';
|
import { Controller, Get, Post, Body, Query } from '@nestjs/common';
|
||||||
import { AuthGuard } from '@nestjs/passport';
|
|
||||||
import { HealthCheckResultRepository } from '../../../infrastructure/repositories/health-check-result.repository';
|
import { HealthCheckResultRepository } from '../../../infrastructure/repositories/health-check-result.repository';
|
||||||
import { HealthCheckResult } from '../../../domain/entities/health-check-result.entity';
|
import { HealthCheckResult } from '../../../domain/entities/health-check-result.entity';
|
||||||
import * as crypto from 'crypto';
|
import * as crypto from 'crypto';
|
||||||
|
|
@ -9,7 +8,6 @@ export class HealthCheckController {
|
||||||
constructor(private readonly healthCheckResultRepo: HealthCheckResultRepository) {}
|
constructor(private readonly healthCheckResultRepo: HealthCheckResultRepository) {}
|
||||||
|
|
||||||
@Get()
|
@Get()
|
||||||
@UseGuards(AuthGuard('jwt'))
|
|
||||||
async listHealthChecks(@Query('serverId') serverId?: string) {
|
async listHealthChecks(@Query('serverId') serverId?: string) {
|
||||||
if (serverId) {
|
if (serverId) {
|
||||||
return this.healthCheckResultRepo.findByServerId(serverId);
|
return this.healthCheckResultRepo.findByServerId(serverId);
|
||||||
|
|
@ -18,7 +16,6 @@ export class HealthCheckController {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Post('run')
|
@Post('run')
|
||||||
@UseGuards(AuthGuard('jwt'))
|
|
||||||
async runHealthCheck(@Body() body: { serverIds?: string[]; checkType?: string }) {
|
async runHealthCheck(@Body() body: { serverIds?: string[]; checkType?: string }) {
|
||||||
const results: HealthCheckResult[] = [];
|
const results: HealthCheckResult[] = [];
|
||||||
const serverIds = body.serverIds || [];
|
const serverIds = body.serverIds || [];
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,4 @@
|
||||||
import { Controller, Get, Post, Body, Param, Query, UseGuards, NotFoundException } from '@nestjs/common';
|
import { Controller, Get, Post, Body, Param, Query, NotFoundException } from '@nestjs/common';
|
||||||
import { AuthGuard } from '@nestjs/passport';
|
|
||||||
import { ApprovalRepository } from '../../../infrastructure/repositories/approval.repository';
|
import { ApprovalRepository } from '../../../infrastructure/repositories/approval.repository';
|
||||||
import { ApproveTaskUseCase } from '../../../application/use-cases/approve-task.use-case';
|
import { ApproveTaskUseCase } from '../../../application/use-cases/approve-task.use-case';
|
||||||
|
|
||||||
|
|
@ -11,13 +10,11 @@ export class ApprovalController {
|
||||||
) {}
|
) {}
|
||||||
|
|
||||||
@Get()
|
@Get()
|
||||||
@UseGuards(AuthGuard('jwt'))
|
|
||||||
async listApprovals(@Query('status') status?: string) {
|
async listApprovals(@Query('status') status?: string) {
|
||||||
return this.approveTaskUseCase.getApprovalRequests(status);
|
return this.approveTaskUseCase.getApprovalRequests(status);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Get(':id')
|
@Get(':id')
|
||||||
@UseGuards(AuthGuard('jwt'))
|
|
||||||
async getApproval(@Param('id') id: string) {
|
async getApproval(@Param('id') id: string) {
|
||||||
const approval = await this.approvalRepository.findById(id);
|
const approval = await this.approvalRepository.findById(id);
|
||||||
if (!approval) {
|
if (!approval) {
|
||||||
|
|
@ -27,7 +24,6 @@ export class ApprovalController {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Post(':id/approve')
|
@Post(':id/approve')
|
||||||
@UseGuards(AuthGuard('jwt'))
|
|
||||||
async approve(
|
async approve(
|
||||||
@Param('id') id: string,
|
@Param('id') id: string,
|
||||||
@Body() body: { approvedBy: string },
|
@Body() body: { approvedBy: string },
|
||||||
|
|
@ -37,7 +33,6 @@ export class ApprovalController {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Post(':id/reject')
|
@Post(':id/reject')
|
||||||
@UseGuards(AuthGuard('jwt'))
|
|
||||||
async reject(
|
async reject(
|
||||||
@Param('id') id: string,
|
@Param('id') id: string,
|
||||||
@Body() body: { rejectedBy: string; reason?: string },
|
@Body() body: { rejectedBy: string; reason?: string },
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,4 @@
|
||||||
import { Controller, Get, Post, Put, Delete, Body, Param, UseGuards, NotFoundException } from '@nestjs/common';
|
import { Controller, Get, Post, Put, Delete, Body, Param, NotFoundException } from '@nestjs/common';
|
||||||
import { AuthGuard } from '@nestjs/passport';
|
|
||||||
import { RunbookRepository } from '../../../infrastructure/repositories/runbook.repository';
|
import { RunbookRepository } from '../../../infrastructure/repositories/runbook.repository';
|
||||||
import { Runbook } from '../../../domain/entities/runbook.entity';
|
import { Runbook } from '../../../domain/entities/runbook.entity';
|
||||||
import * as crypto from 'crypto';
|
import * as crypto from 'crypto';
|
||||||
|
|
@ -9,13 +8,11 @@ export class RunbookController {
|
||||||
constructor(private readonly runbookRepository: RunbookRepository) {}
|
constructor(private readonly runbookRepository: RunbookRepository) {}
|
||||||
|
|
||||||
@Get()
|
@Get()
|
||||||
@UseGuards(AuthGuard('jwt'))
|
|
||||||
async listRunbooks() {
|
async listRunbooks() {
|
||||||
return this.runbookRepository.findAll();
|
return this.runbookRepository.findAll();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Post()
|
@Post()
|
||||||
@UseGuards(AuthGuard('jwt'))
|
|
||||||
async createRunbook(@Body() body: any) {
|
async createRunbook(@Body() body: any) {
|
||||||
const runbook = new Runbook();
|
const runbook = new Runbook();
|
||||||
runbook.id = crypto.randomUUID();
|
runbook.id = crypto.randomUUID();
|
||||||
|
|
@ -33,7 +30,6 @@ export class RunbookController {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Put(':id')
|
@Put(':id')
|
||||||
@UseGuards(AuthGuard('jwt'))
|
|
||||||
async updateRunbook(@Param('id') id: string, @Body() body: any) {
|
async updateRunbook(@Param('id') id: string, @Body() body: any) {
|
||||||
const runbook = await this.runbookRepository.findById(id);
|
const runbook = await this.runbookRepository.findById(id);
|
||||||
if (!runbook) {
|
if (!runbook) {
|
||||||
|
|
@ -44,7 +40,6 @@ export class RunbookController {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Delete(':id')
|
@Delete(':id')
|
||||||
@UseGuards(AuthGuard('jwt'))
|
|
||||||
async deleteRunbook(@Param('id') id: string) {
|
async deleteRunbook(@Param('id') id: string) {
|
||||||
const runbook = await this.runbookRepository.findById(id);
|
const runbook = await this.runbookRepository.findById(id);
|
||||||
if (!runbook) {
|
if (!runbook) {
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,4 @@
|
||||||
import { Controller, Get, Post, Put, Patch, Param, Body, UseGuards, NotFoundException } from '@nestjs/common';
|
import { Controller, Get, Post, Put, Patch, Param, Body, NotFoundException } from '@nestjs/common';
|
||||||
import { AuthGuard } from '@nestjs/passport';
|
|
||||||
import { StandingOrderRepository } from '../../../infrastructure/repositories/standing-order.repository';
|
import { StandingOrderRepository } from '../../../infrastructure/repositories/standing-order.repository';
|
||||||
import { StandingOrderExecutionRepository } from '../../../infrastructure/repositories/standing-order-execution.repository';
|
import { StandingOrderExecutionRepository } from '../../../infrastructure/repositories/standing-order-execution.repository';
|
||||||
import { StandingOrder } from '../../../domain/entities/standing-order.entity';
|
import { StandingOrder } from '../../../domain/entities/standing-order.entity';
|
||||||
|
|
@ -13,7 +12,6 @@ export class StandingOrderController {
|
||||||
) {}
|
) {}
|
||||||
|
|
||||||
@Get()
|
@Get()
|
||||||
@UseGuards(AuthGuard('jwt'))
|
|
||||||
async listOrders() {
|
async listOrders() {
|
||||||
const orders = await this.standingOrderRepository.findAll();
|
const orders = await this.standingOrderRepository.findAll();
|
||||||
return orders.map((o) => this.serializeOrder(o));
|
return orders.map((o) => this.serializeOrder(o));
|
||||||
|
|
@ -93,7 +91,6 @@ export class StandingOrderController {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Post()
|
@Post()
|
||||||
@UseGuards(AuthGuard('jwt'))
|
|
||||||
async createOrder(@Body() body: any) {
|
async createOrder(@Body() body: any) {
|
||||||
const order = new StandingOrder();
|
const order = new StandingOrder();
|
||||||
order.id = crypto.randomUUID();
|
order.id = crypto.randomUUID();
|
||||||
|
|
@ -110,7 +107,6 @@ export class StandingOrderController {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Get(':id')
|
@Get(':id')
|
||||||
@UseGuards(AuthGuard('jwt'))
|
|
||||||
async getOrder(@Param('id') id: string) {
|
async getOrder(@Param('id') id: string) {
|
||||||
const order = await this.standingOrderRepository.findById(id);
|
const order = await this.standingOrderRepository.findById(id);
|
||||||
if (!order) {
|
if (!order) {
|
||||||
|
|
@ -120,7 +116,6 @@ export class StandingOrderController {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Put(':id')
|
@Put(':id')
|
||||||
@UseGuards(AuthGuard('jwt'))
|
|
||||||
async updateOrder(@Param('id') id: string, @Body() body: any) {
|
async updateOrder(@Param('id') id: string, @Body() body: any) {
|
||||||
const order = await this.standingOrderRepository.findById(id);
|
const order = await this.standingOrderRepository.findById(id);
|
||||||
if (!order) {
|
if (!order) {
|
||||||
|
|
@ -133,7 +128,6 @@ export class StandingOrderController {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Patch(':id/status')
|
@Patch(':id/status')
|
||||||
@UseGuards(AuthGuard('jwt'))
|
|
||||||
async updateStatus(@Param('id') id: string, @Body() body: { status: string }) {
|
async updateStatus(@Param('id') id: string, @Body() body: { status: string }) {
|
||||||
const order = await this.standingOrderRepository.findById(id);
|
const order = await this.standingOrderRepository.findById(id);
|
||||||
if (!order) {
|
if (!order) {
|
||||||
|
|
@ -145,7 +139,6 @@ export class StandingOrderController {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Get(':id/executions')
|
@Get(':id/executions')
|
||||||
@UseGuards(AuthGuard('jwt'))
|
|
||||||
async getExecutions(@Param('id') id: string) {
|
async getExecutions(@Param('id') id: string) {
|
||||||
const order = await this.standingOrderRepository.findById(id);
|
const order = await this.standingOrderRepository.findById(id);
|
||||||
if (!order) {
|
if (!order) {
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,4 @@
|
||||||
import { Controller, Get, Post, Body, Param, UseGuards, NotFoundException } from '@nestjs/common';
|
import { Controller, Get, Post, Body, Param, NotFoundException } from '@nestjs/common';
|
||||||
import { AuthGuard } from '@nestjs/passport';
|
|
||||||
import { TaskRepository } from '../../../infrastructure/repositories/task.repository';
|
import { TaskRepository } from '../../../infrastructure/repositories/task.repository';
|
||||||
import { OpsTask } from '../../../domain/entities/ops-task.entity';
|
import { OpsTask } from '../../../domain/entities/ops-task.entity';
|
||||||
import * as crypto from 'crypto';
|
import * as crypto from 'crypto';
|
||||||
|
|
@ -9,13 +8,11 @@ export class TaskController {
|
||||||
constructor(private readonly taskRepository: TaskRepository) {}
|
constructor(private readonly taskRepository: TaskRepository) {}
|
||||||
|
|
||||||
@Get()
|
@Get()
|
||||||
@UseGuards(AuthGuard('jwt'))
|
|
||||||
async listTasks() {
|
async listTasks() {
|
||||||
return this.taskRepository.findAll();
|
return this.taskRepository.findAll();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Post()
|
@Post()
|
||||||
@UseGuards(AuthGuard('jwt'))
|
|
||||||
async createTask(@Body() body: any) {
|
async createTask(@Body() body: any) {
|
||||||
const task = new OpsTask();
|
const task = new OpsTask();
|
||||||
task.id = crypto.randomUUID();
|
task.id = crypto.randomUUID();
|
||||||
|
|
@ -34,7 +31,6 @@ export class TaskController {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Get(':id')
|
@Get(':id')
|
||||||
@UseGuards(AuthGuard('jwt'))
|
|
||||||
async getTask(@Param('id') id: string) {
|
async getTask(@Param('id') id: string) {
|
||||||
const task = await this.taskRepository.findById(id);
|
const task = await this.taskRepository.findById(id);
|
||||||
if (!task) {
|
if (!task) {
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue