- ApiKeysController verlangt MANAGE_SETTINGS. Bisher konnte jeder
OIDC-Benutzer einen API-Key erzeugen, der im PermissionsGuard jede
Rechteprüfung umgeht (Rechteausweitung zum Admin).
- MailService setzt disableFileAccess/disableUrlAccess für jede Mail.
- send-email im Posteingang prüft den Body streng auf Strings/Zahlen.
Bisher liest nodemailer bei html: { path: '/proc/self/environ' }
beliebige Serverdateien ein und verschickt sie.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
40 lines
1.1 KiB
TypeScript
40 lines
1.1 KiB
TypeScript
import {
|
||
Controller,
|
||
Get,
|
||
Post,
|
||
Delete,
|
||
Body,
|
||
Param,
|
||
UseGuards,
|
||
} from '@nestjs/common';
|
||
import { ApiKeysService } from './api-keys.service';
|
||
import { JwtAuthGuard } from './jwt-auth.guard';
|
||
import { RequirePermissions } from './permissions.decorator';
|
||
import { Permission } from './permissions.enum';
|
||
|
||
@Controller('api/api-keys')
|
||
@UseGuards(JwtAuthGuard)
|
||
// Ein API-Key umgeht im PermissionsGuard jede Rechteprüfung – Anlegen und
|
||
// Verwalten darf daher nur, wer ohnehin alle Einstellungen verwalten darf.
|
||
@RequirePermissions(Permission.MANAGE_SETTINGS)
|
||
export class ApiKeysController {
|
||
constructor(private readonly apiKeysService: ApiKeysService) {}
|
||
|
||
@Post()
|
||
async create(@Body() body: { name: string; expiresDays?: number }) {
|
||
// Note: The plainKey is only returned here once.
|
||
return this.apiKeysService.createApiKey(body.name, body.expiresDays);
|
||
}
|
||
|
||
@Get()
|
||
async findAll() {
|
||
// Note: This returns hashed keys and prefixes, not the plain keys.
|
||
return this.apiKeysService.listKeys();
|
||
}
|
||
|
||
@Delete(':id')
|
||
async remove(@Param('id') id: string) {
|
||
return this.apiKeysService.deleteKey(id);
|
||
}
|
||
}
|