feat(auth): add bootstrap token flow for initial admin creation

- Introduced `BootstrapService` to handle admin creation when no admins exist.
- Added `/auth/bootstrap-admin` endpoint to consume bootstrap tokens.
- Updated `RbacRepository` to support counting admins and assigning roles.
- Included unit tests for `BootstrapService` to ensure token behavior and admin assignment.
This commit is contained in:
Mathis HERRIOT
2026-01-21 11:07:02 +01:00
parent aff8acebf8
commit 3f0b1e5119
6 changed files with 215 additions and 1 deletions

View File

@@ -51,4 +51,12 @@ export class RbacService implements OnApplicationBootstrap {
async getUserPermissions(userId: string) {
return this.rbacRepository.findPermissionsByUserId(userId);
}
async countAdmins() {
return this.rbacRepository.countAdmins();
}
async assignRoleToUser(userId: string, roleSlug: string) {
return this.rbacRepository.assignRole(userId, roleSlug);
}
}