feat: RBAC Phase 2b - Betrieb auf @RequirePermission umgestellt
Varroa, SwarmControl, Treatments, Feedings (+ jeweilige Colony-Sub-Controller): @Roles(...) durch @RequirePermission(...) ersetzt, ungeschuetzte GET-Routen mit :read-Rechten geschlossen. Verifiziert: tsc, lint, e2e (varroa/swarm-control/treatments/feedings einzeln gruen; volle Suite 158/159 gruen, 1 getrackter Skip). Co-Authored-By: Claude Sonnet 5 <[email protected]>
This commit is contained in:
1 parent
f4b174ec56
commit
cdbdaedb8f
8 files changed
+29
-16
No files matched your search
@@ -1,5 +1,6 @@
|
|||||||
import { Controller, Get, Param } from '@nestjs/common';
|
import { Controller, Get, Param } from '@nestjs/common';
|
||||||
import { ApiBearerAuth, ApiTags } from '@nestjs/swagger';
|
import { ApiBearerAuth, ApiTags } from '@nestjs/swagger';
|
||||||
|
import { RequirePermission } from '../auth/decorators/require-permission.decorator';
|
||||||
import { FeedingsService } from './feedings.service';
|
import { FeedingsService } from './feedings.service';
|
||||||
|
|
||||||
@ApiTags('feedings')
|
@ApiTags('feedings')
|
||||||
@@ -8,11 +9,13 @@ import { FeedingsService } from './feedings.service';
|
|||||||
export class ColonyFeedingsController {
|
export class ColonyFeedingsController {
|
||||||
constructor(private readonly feedingsService: FeedingsService) {}
|
constructor(private readonly feedingsService: FeedingsService) {}
|
||||||
|
|
||||||
|
@RequirePermission('feedings:read')
|
||||||
@Get(':id/feedings')
|
@Get(':id/feedings')
|
||||||
findByColony(@Param('id') id: string) {
|
findByColony(@Param('id') id: string) {
|
||||||
return this.feedingsService.findByColony(id);
|
return this.feedingsService.findByColony(id);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@RequirePermission('feedings:read')
|
||||||
@Get(':id/feedings/summary')
|
@Get(':id/feedings/summary')
|
||||||
summaryByColony(@Param('id') id: string) {
|
summaryByColony(@Param('id') id: string) {
|
||||||
return this.feedingsService.summaryByColony(id);
|
return this.feedingsService.summaryByColony(id);
|
||||||
|
|||||||
@@ -1,7 +1,6 @@
|
|||||||
import { Body, Controller, Get, Param, Patch, Post } from '@nestjs/common';
|
import { Body, Controller, Get, Param, Patch, Post } from '@nestjs/common';
|
||||||
import { ApiBearerAuth, ApiTags } from '@nestjs/swagger';
|
import { ApiBearerAuth, ApiTags } from '@nestjs/swagger';
|
||||||
import { LegacyRole as Role } from '../../generated/prisma';
|
import { RequirePermission } from '../auth/decorators/require-permission.decorator';
|
||||||
import { Roles } from '../auth/decorators/roles.decorator';
|
|
||||||
import { CurrentUser } from '../auth/decorators/current-user.decorator';
|
import { CurrentUser } from '../auth/decorators/current-user.decorator';
|
||||||
import type { AuthenticatedUser } from '../auth/types/authenticated-user';
|
import type { AuthenticatedUser } from '../auth/types/authenticated-user';
|
||||||
import { CreateFeedingDto } from './dto/create-feeding.dto';
|
import { CreateFeedingDto } from './dto/create-feeding.dto';
|
||||||
@@ -14,17 +13,19 @@ import { FeedingsService } from './feedings.service';
|
|||||||
export class FeedingsController {
|
export class FeedingsController {
|
||||||
constructor(private readonly feedingsService: FeedingsService) {}
|
constructor(private readonly feedingsService: FeedingsService) {}
|
||||||
|
|
||||||
|
@RequirePermission('feedings:read')
|
||||||
@Get()
|
@Get()
|
||||||
findAll() {
|
findAll() {
|
||||||
return this.feedingsService.findAll();
|
return this.feedingsService.findAll();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@RequirePermission('feedings:read')
|
||||||
@Get(':id')
|
@Get(':id')
|
||||||
findOne(@Param('id') id: string) {
|
findOne(@Param('id') id: string) {
|
||||||
return this.feedingsService.findById(id);
|
return this.feedingsService.findById(id);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Roles(Role.ADMIN, Role.BEEKEEPER, Role.STAFF)
|
@RequirePermission('feedings:create')
|
||||||
@Post()
|
@Post()
|
||||||
create(
|
create(
|
||||||
@Body() dto: CreateFeedingDto,
|
@Body() dto: CreateFeedingDto,
|
||||||
@@ -33,7 +34,7 @@ export class FeedingsController {
|
|||||||
return this.feedingsService.create(dto, actor.id);
|
return this.feedingsService.create(dto, actor.id);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Roles(Role.ADMIN, Role.BEEKEEPER, Role.STAFF)
|
@RequirePermission('feedings:update')
|
||||||
@Patch(':id')
|
@Patch(':id')
|
||||||
update(
|
update(
|
||||||
@Param('id') id: string,
|
@Param('id') id: string,
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
import { Controller, Get, Param } from '@nestjs/common';
|
import { Controller, Get, Param } from '@nestjs/common';
|
||||||
import { ApiBearerAuth, ApiTags } from '@nestjs/swagger';
|
import { ApiBearerAuth, ApiTags } from '@nestjs/swagger';
|
||||||
|
import { RequirePermission } from '../auth/decorators/require-permission.decorator';
|
||||||
import { SwarmControlService } from './swarm-control.service';
|
import { SwarmControlService } from './swarm-control.service';
|
||||||
|
|
||||||
@ApiTags('swarm-control-checks')
|
@ApiTags('swarm-control-checks')
|
||||||
@@ -8,6 +9,7 @@ import { SwarmControlService } from './swarm-control.service';
|
|||||||
export class ColonySwarmControlChecksController {
|
export class ColonySwarmControlChecksController {
|
||||||
constructor(private readonly swarmControlService: SwarmControlService) {}
|
constructor(private readonly swarmControlService: SwarmControlService) {}
|
||||||
|
|
||||||
|
@RequirePermission('swarm-control:read')
|
||||||
@Get(':id/swarm-control-checks')
|
@Get(':id/swarm-control-checks')
|
||||||
findByColony(@Param('id') id: string) {
|
findByColony(@Param('id') id: string) {
|
||||||
return this.swarmControlService.findByColony(id);
|
return this.swarmControlService.findByColony(id);
|
||||||
|
|||||||
@@ -1,7 +1,6 @@
|
|||||||
import { Body, Controller, Get, Param, Patch, Post } from '@nestjs/common';
|
import { Body, Controller, Get, Param, Patch, Post } from '@nestjs/common';
|
||||||
import { ApiBearerAuth, ApiTags } from '@nestjs/swagger';
|
import { ApiBearerAuth, ApiTags } from '@nestjs/swagger';
|
||||||
import { LegacyRole as Role } from '../../generated/prisma';
|
import { RequirePermission } from '../auth/decorators/require-permission.decorator';
|
||||||
import { Roles } from '../auth/decorators/roles.decorator';
|
|
||||||
import { CurrentUser } from '../auth/decorators/current-user.decorator';
|
import { CurrentUser } from '../auth/decorators/current-user.decorator';
|
||||||
import type { AuthenticatedUser } from '../auth/types/authenticated-user';
|
import type { AuthenticatedUser } from '../auth/types/authenticated-user';
|
||||||
import { CreateSwarmControlCheckDto } from './dto/create-swarm-control-check.dto';
|
import { CreateSwarmControlCheckDto } from './dto/create-swarm-control-check.dto';
|
||||||
@@ -14,17 +13,19 @@ import { SwarmControlService } from './swarm-control.service';
|
|||||||
export class SwarmControlController {
|
export class SwarmControlController {
|
||||||
constructor(private readonly swarmControlService: SwarmControlService) {}
|
constructor(private readonly swarmControlService: SwarmControlService) {}
|
||||||
|
|
||||||
|
@RequirePermission('swarm-control:read')
|
||||||
@Get()
|
@Get()
|
||||||
findAll() {
|
findAll() {
|
||||||
return this.swarmControlService.findAll();
|
return this.swarmControlService.findAll();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@RequirePermission('swarm-control:read')
|
||||||
@Get(':id')
|
@Get(':id')
|
||||||
findOne(@Param('id') id: string) {
|
findOne(@Param('id') id: string) {
|
||||||
return this.swarmControlService.findById(id);
|
return this.swarmControlService.findById(id);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Roles(Role.ADMIN, Role.BEEKEEPER)
|
@RequirePermission('swarm-control:create')
|
||||||
@Post()
|
@Post()
|
||||||
create(
|
create(
|
||||||
@Body() dto: CreateSwarmControlCheckDto,
|
@Body() dto: CreateSwarmControlCheckDto,
|
||||||
@@ -33,7 +34,7 @@ export class SwarmControlController {
|
|||||||
return this.swarmControlService.create(dto, actor.id);
|
return this.swarmControlService.create(dto, actor.id);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Roles(Role.ADMIN, Role.BEEKEEPER)
|
@RequirePermission('swarm-control:update')
|
||||||
@Patch(':id')
|
@Patch(':id')
|
||||||
update(
|
update(
|
||||||
@Param('id') id: string,
|
@Param('id') id: string,
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
import { Controller, Get, Param } from '@nestjs/common';
|
import { Controller, Get, Param } from '@nestjs/common';
|
||||||
import { ApiBearerAuth, ApiTags } from '@nestjs/swagger';
|
import { ApiBearerAuth, ApiTags } from '@nestjs/swagger';
|
||||||
|
import { RequirePermission } from '../auth/decorators/require-permission.decorator';
|
||||||
import { TreatmentsService } from './treatments.service';
|
import { TreatmentsService } from './treatments.service';
|
||||||
|
|
||||||
@ApiTags('treatments')
|
@ApiTags('treatments')
|
||||||
@@ -8,6 +9,7 @@ import { TreatmentsService } from './treatments.service';
|
|||||||
export class ColonyTreatmentsController {
|
export class ColonyTreatmentsController {
|
||||||
constructor(private readonly treatmentsService: TreatmentsService) {}
|
constructor(private readonly treatmentsService: TreatmentsService) {}
|
||||||
|
|
||||||
|
@RequirePermission('treatments:read')
|
||||||
@Get(':id/treatments')
|
@Get(':id/treatments')
|
||||||
findByColony(@Param('id') id: string) {
|
findByColony(@Param('id') id: string) {
|
||||||
return this.treatmentsService.findByColony(id);
|
return this.treatmentsService.findByColony(id);
|
||||||
|
|||||||
@@ -1,7 +1,6 @@
|
|||||||
import { Body, Controller, Get, Param, Patch, Post } from '@nestjs/common';
|
import { Body, Controller, Get, Param, Patch, Post } from '@nestjs/common';
|
||||||
import { ApiBearerAuth, ApiTags } from '@nestjs/swagger';
|
import { ApiBearerAuth, ApiTags } from '@nestjs/swagger';
|
||||||
import { LegacyRole as Role } from '../../generated/prisma';
|
import { RequirePermission } from '../auth/decorators/require-permission.decorator';
|
||||||
import { Roles } from '../auth/decorators/roles.decorator';
|
|
||||||
import { CurrentUser } from '../auth/decorators/current-user.decorator';
|
import { CurrentUser } from '../auth/decorators/current-user.decorator';
|
||||||
import type { AuthenticatedUser } from '../auth/types/authenticated-user';
|
import type { AuthenticatedUser } from '../auth/types/authenticated-user';
|
||||||
import { CreateTreatmentDto } from './dto/create-treatment.dto';
|
import { CreateTreatmentDto } from './dto/create-treatment.dto';
|
||||||
@@ -14,17 +13,19 @@ import { TreatmentsService } from './treatments.service';
|
|||||||
export class TreatmentsController {
|
export class TreatmentsController {
|
||||||
constructor(private readonly treatmentsService: TreatmentsService) {}
|
constructor(private readonly treatmentsService: TreatmentsService) {}
|
||||||
|
|
||||||
|
@RequirePermission('treatments:read')
|
||||||
@Get()
|
@Get()
|
||||||
findAll() {
|
findAll() {
|
||||||
return this.treatmentsService.findAll();
|
return this.treatmentsService.findAll();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@RequirePermission('treatments:read')
|
||||||
@Get(':id')
|
@Get(':id')
|
||||||
findOne(@Param('id') id: string) {
|
findOne(@Param('id') id: string) {
|
||||||
return this.treatmentsService.findById(id);
|
return this.treatmentsService.findById(id);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Roles(Role.ADMIN, Role.BEEKEEPER)
|
@RequirePermission('treatments:create')
|
||||||
@Post()
|
@Post()
|
||||||
create(
|
create(
|
||||||
@Body() dto: CreateTreatmentDto,
|
@Body() dto: CreateTreatmentDto,
|
||||||
@@ -33,7 +34,7 @@ export class TreatmentsController {
|
|||||||
return this.treatmentsService.create(dto, actor.id);
|
return this.treatmentsService.create(dto, actor.id);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Roles(Role.ADMIN, Role.BEEKEEPER)
|
@RequirePermission('treatments:update')
|
||||||
@Patch(':id')
|
@Patch(':id')
|
||||||
update(
|
update(
|
||||||
@Param('id') id: string,
|
@Param('id') id: string,
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
import { Controller, Get, Param } from '@nestjs/common';
|
import { Controller, Get, Param } from '@nestjs/common';
|
||||||
import { ApiBearerAuth, ApiTags } from '@nestjs/swagger';
|
import { ApiBearerAuth, ApiTags } from '@nestjs/swagger';
|
||||||
|
import { RequirePermission } from '../auth/decorators/require-permission.decorator';
|
||||||
import { VarroaService } from './varroa.service';
|
import { VarroaService } from './varroa.service';
|
||||||
|
|
||||||
@ApiTags('varroa-measurements')
|
@ApiTags('varroa-measurements')
|
||||||
@@ -8,6 +9,7 @@ import { VarroaService } from './varroa.service';
|
|||||||
export class ColonyVarroaMeasurementsController {
|
export class ColonyVarroaMeasurementsController {
|
||||||
constructor(private readonly varroaService: VarroaService) {}
|
constructor(private readonly varroaService: VarroaService) {}
|
||||||
|
|
||||||
|
@RequirePermission('varroa:read')
|
||||||
@Get(':id/varroa-measurements')
|
@Get(':id/varroa-measurements')
|
||||||
findByColony(@Param('id') id: string) {
|
findByColony(@Param('id') id: string) {
|
||||||
return this.varroaService.findByColony(id);
|
return this.varroaService.findByColony(id);
|
||||||
|
|||||||
@@ -1,7 +1,6 @@
|
|||||||
import { Body, Controller, Get, Param, Patch, Post } from '@nestjs/common';
|
import { Body, Controller, Get, Param, Patch, Post } from '@nestjs/common';
|
||||||
import { ApiBearerAuth, ApiTags } from '@nestjs/swagger';
|
import { ApiBearerAuth, ApiTags } from '@nestjs/swagger';
|
||||||
import { LegacyRole as Role } from '../../generated/prisma';
|
import { RequirePermission } from '../auth/decorators/require-permission.decorator';
|
||||||
import { Roles } from '../auth/decorators/roles.decorator';
|
|
||||||
import { CurrentUser } from '../auth/decorators/current-user.decorator';
|
import { CurrentUser } from '../auth/decorators/current-user.decorator';
|
||||||
import type { AuthenticatedUser } from '../auth/types/authenticated-user';
|
import type { AuthenticatedUser } from '../auth/types/authenticated-user';
|
||||||
import { CreateVarroaMeasurementDto } from './dto/create-varroa-measurement.dto';
|
import { CreateVarroaMeasurementDto } from './dto/create-varroa-measurement.dto';
|
||||||
@@ -14,17 +13,19 @@ import { VarroaService } from './varroa.service';
|
|||||||
export class VarroaController {
|
export class VarroaController {
|
||||||
constructor(private readonly varroaService: VarroaService) {}
|
constructor(private readonly varroaService: VarroaService) {}
|
||||||
|
|
||||||
|
@RequirePermission('varroa:read')
|
||||||
@Get()
|
@Get()
|
||||||
findAll() {
|
findAll() {
|
||||||
return this.varroaService.findAll();
|
return this.varroaService.findAll();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@RequirePermission('varroa:read')
|
||||||
@Get(':id')
|
@Get(':id')
|
||||||
findOne(@Param('id') id: string) {
|
findOne(@Param('id') id: string) {
|
||||||
return this.varroaService.findById(id);
|
return this.varroaService.findById(id);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Roles(Role.ADMIN, Role.BEEKEEPER)
|
@RequirePermission('varroa:create')
|
||||||
@Post()
|
@Post()
|
||||||
create(
|
create(
|
||||||
@Body() dto: CreateVarroaMeasurementDto,
|
@Body() dto: CreateVarroaMeasurementDto,
|
||||||
@@ -33,7 +34,7 @@ export class VarroaController {
|
|||||||
return this.varroaService.create(dto, actor.id);
|
return this.varroaService.create(dto, actor.id);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Roles(Role.ADMIN, Role.BEEKEEPER)
|
@RequirePermission('varroa:update')
|
||||||
@Patch(':id')
|
@Patch(':id')
|
||||||
update(
|
update(
|
||||||
@Param('id') id: string,
|
@Param('id') id: string,
|
||||||
|
|||||||
Reference in new issue
Block a user