feat(center): issue per-guild tokens and add introspection API

This commit is contained in:
root
2026-05-13 07:59:27 +00:00
parent 03a3342d2a
commit a924bf656d
5 changed files with 162 additions and 3 deletions

View File

@@ -1,4 +1,4 @@
import { Body, Controller, Post } from '@nestjs/common';
import { Body, Controller, Get, Headers, Post, UnauthorizedException } from '@nestjs/common';
import { AuthService } from './auth.service';
import { RegisterDto } from './dto.register.dto';
import { LoginDto } from './dto.login.dto';
@@ -28,4 +28,19 @@ export class AuthController {
logout(@Body() body: LogoutDto) {
return this.authService.logout(body.refreshToken);
}
@Get('me/guilds')
meGuilds(@Headers('authorization') authorization?: string) {
const token = authorization?.startsWith('Bearer ') ? authorization.slice(7) : '';
if (!token) throw new UnauthorizedException('missing bearer token');
return this.authService.listMyGuilds(token);
}
@Post('introspect')
introspect(
@Body() body: { token?: string; guildNodeId?: string },
@Headers('x-center-shared-secret') sharedSecret?: string,
) {
return this.authService.introspectGuildToken(body?.token ?? '', body?.guildNodeId ?? '', sharedSecret);
}
}