mirror of
https://github.com/hedgedoc/hedgedoc.git
synced 2025-05-15 07:34:42 -04:00
openapi: adds auth to all public api routes
See: https://docs.nestjs.com/openapi/security Signed-off-by: Philip Molares <philip.molares@udo.edu>
This commit is contained in:
parent
2ab950c5c3
commit
33d9c455b8
5 changed files with 12 additions and 0 deletions
|
@ -25,7 +25,9 @@ import { NotesService } from '../../../notes/notes.service';
|
||||||
import { UserInfoDto } from '../../../users/user-info.dto';
|
import { UserInfoDto } from '../../../users/user-info.dto';
|
||||||
import { UsersService } from '../../../users/users.service';
|
import { UsersService } from '../../../users/users.service';
|
||||||
import { TokenAuthGuard } from '../../../auth/token-auth.guard';
|
import { TokenAuthGuard } from '../../../auth/token-auth.guard';
|
||||||
|
import { ApiSecurity } from '@nestjs/swagger';
|
||||||
|
|
||||||
|
@ApiSecurity('token')
|
||||||
@Controller('me')
|
@Controller('me')
|
||||||
export class MeController {
|
export class MeController {
|
||||||
constructor(
|
constructor(
|
||||||
|
|
|
@ -28,7 +28,9 @@ import { ConsoleLoggerService } from '../../../logger/console-logger.service';
|
||||||
import { MediaService } from '../../../media/media.service';
|
import { MediaService } from '../../../media/media.service';
|
||||||
import { MulterFile } from '../../../media/multer-file.interface';
|
import { MulterFile } from '../../../media/multer-file.interface';
|
||||||
import { TokenAuthGuard } from '../../../auth/token-auth.guard';
|
import { TokenAuthGuard } from '../../../auth/token-auth.guard';
|
||||||
|
import { ApiSecurity } from '@nestjs/swagger';
|
||||||
|
|
||||||
|
@ApiSecurity('token')
|
||||||
@Controller('media')
|
@Controller('media')
|
||||||
export class MediaController {
|
export class MediaController {
|
||||||
constructor(
|
constructor(
|
||||||
|
|
|
@ -7,7 +7,9 @@
|
||||||
import { Controller, Get, UseGuards } from '@nestjs/common';
|
import { Controller, Get, UseGuards } from '@nestjs/common';
|
||||||
import { MonitoringService } from '../../../monitoring/monitoring.service';
|
import { MonitoringService } from '../../../monitoring/monitoring.service';
|
||||||
import { TokenAuthGuard } from '../../../auth/token-auth.guard';
|
import { TokenAuthGuard } from '../../../auth/token-auth.guard';
|
||||||
|
import { ApiSecurity } from '@nestjs/swagger';
|
||||||
|
|
||||||
|
@ApiSecurity('token')
|
||||||
@Controller('monitoring')
|
@Controller('monitoring')
|
||||||
export class MonitoringController {
|
export class MonitoringController {
|
||||||
constructor(private monitoringService: MonitoringService) {}
|
constructor(private monitoringService: MonitoringService) {}
|
||||||
|
|
|
@ -24,7 +24,9 @@ import { NotesService } from '../../../notes/notes.service';
|
||||||
import { RevisionsService } from '../../../revisions/revisions.service';
|
import { RevisionsService } from '../../../revisions/revisions.service';
|
||||||
import { MarkdownBody } from '../../utils/markdownbody-decorator';
|
import { MarkdownBody } from '../../utils/markdownbody-decorator';
|
||||||
import { TokenAuthGuard } from '../../../auth/token-auth.guard';
|
import { TokenAuthGuard } from '../../../auth/token-auth.guard';
|
||||||
|
import { ApiSecurity } from '@nestjs/swagger';
|
||||||
|
|
||||||
|
@ApiSecurity('token')
|
||||||
@Controller('notes')
|
@Controller('notes')
|
||||||
export class NotesController {
|
export class NotesController {
|
||||||
constructor(
|
constructor(
|
||||||
|
|
|
@ -26,6 +26,10 @@ async function bootstrap() {
|
||||||
const swaggerOptions = new DocumentBuilder()
|
const swaggerOptions = new DocumentBuilder()
|
||||||
.setTitle('HedgeDoc')
|
.setTitle('HedgeDoc')
|
||||||
.setVersion('2.0-dev')
|
.setVersion('2.0-dev')
|
||||||
|
.addSecurity('token', {
|
||||||
|
type: 'http',
|
||||||
|
scheme: 'bearer',
|
||||||
|
})
|
||||||
.build();
|
.build();
|
||||||
const document = SwaggerModule.createDocument(app, swaggerOptions);
|
const document = SwaggerModule.createDocument(app, swaggerOptions);
|
||||||
SwaggerModule.setup('apidoc', app, document);
|
SwaggerModule.setup('apidoc', app, document);
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue