feat(center): issue per-guild tokens and add introspection API
This commit is contained in:
@@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user