feat(auth): split api-key boundary for frontend auth flow
This commit is contained in:
@@ -21,6 +21,18 @@ export class CenterApiKeyGuard implements CanActivate {
|
||||
const path = req.path ?? '';
|
||||
const method = (req.method ?? 'GET').toUpperCase();
|
||||
|
||||
const noApiKeyRequired =
|
||||
path === '/healthz' ||
|
||||
path.endsWith('/healthz') ||
|
||||
(method === 'POST' && (path === '/auth/login' || path.endsWith('/auth/login'))) ||
|
||||
(method === 'POST' && (path === '/auth/refresh' || path.endsWith('/auth/refresh'))) ||
|
||||
(method === 'POST' && (path === '/auth/logout' || path.endsWith('/auth/logout'))) ||
|
||||
(method === 'GET' && (path === '/auth/me/guilds' || path.endsWith('/auth/me/guilds')));
|
||||
|
||||
if (noApiKeyRequired) {
|
||||
return true;
|
||||
}
|
||||
|
||||
// only guild registration is exempt from API key; it is protected by HMAC secret
|
||||
if (method === 'POST' && (path === '/nodes/register' || path.endsWith('/nodes/register'))) {
|
||||
return true;
|
||||
@@ -40,4 +52,3 @@ export class CenterApiKeyGuard implements CanActivate {
|
||||
throw new UnauthorizedException('invalid api key');
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user