fix(security): fence corporate orchestration and human key administration
This commit is contained in:
1 parent
d80845af0d
commit
435a75a442
24 files changed
+1366
-54
No files matched your search
@@ -0,0 +1,17 @@
|
||||
import {
|
||||
CanActivate,
|
||||
ExecutionContext,
|
||||
ForbiddenException,
|
||||
Injectable,
|
||||
} from '@nestjs/common';
|
||||
|
||||
/** Key management is a human-only control plane, never delegated by API scope. */
|
||||
@Injectable()
|
||||
export class HumanAdminGuard implements CanActivate {
|
||||
canActivate(context: ExecutionContext): boolean {
|
||||
const user = context.switchToHttp().getRequest().user;
|
||||
if (!user || user.isApiKey || !['Admin', 'SUPER_ADMIN'].includes(user.role))
|
||||
throw new ForbiddenException('Human administrator required');
|
||||
return true;
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user