Skip to content

Commit 22c4858

Browse files
committed
feat: add SchemaChangeBatchOwnershipGuard and SchemaChangeOwnershipGuard for enhanced access control
1 parent 870a47b commit 22c4858

5 files changed

Lines changed: 20 additions & 17 deletions

File tree

backend/src/entities/table-schema/table-schema.controller.ts

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,11 @@ import { UseCaseType } from '../../common/data-injection.tokens.js';
1616
import { MasterPassword } from '../../decorators/master-password.decorator.js';
1717
import { SlugUuid } from '../../decorators/slug-uuid.decorator.js';
1818
import { UserId } from '../../decorators/user-id.decorator.js';
19-
import { ConnectionEditGuard } from '../../guards/index.js';
19+
import {
20+
ConnectionEditGuard,
21+
SchemaChangeBatchOwnershipGuard,
22+
SchemaChangeOwnershipGuard,
23+
} from '../../guards/index.js';
2024
import { SentryInterceptor } from '../../interceptors/sentry.interceptor.js';
2125
import { ApproveBatchSchemaChangeDto } from './application/data-transfer-objects/approve-batch-schema-change.dto.js';
2226
import { ApproveSchemaChangeDto } from './application/data-transfer-objects/approve-schema-change.dto.js';
@@ -36,8 +40,6 @@ import {
3640
IRollbackBatchSchemaChange,
3741
IRollbackSchemaChange,
3842
} from './use-cases/table-schema-use-cases.interface.js';
39-
import { SchemaChangeBatchOwnershipGuard } from './utils/schema-change-batch-ownership.guard.js';
40-
import { SchemaChangeOwnershipGuard } from './utils/schema-change-ownership.guard.js';
4143

4244
@UseInterceptors(SentryInterceptor)
4345
@Controller()

backend/src/entities/table-schema/table-schema.module.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ import { TypeOrmModule } from '@nestjs/typeorm';
33
import { AuthMiddleware } from '../../authorization/auth.middleware.js';
44
import { GlobalDatabaseContext } from '../../common/application/global-database-context.js';
55
import { BaseType, UseCaseType } from '../../common/data-injection.tokens.js';
6+
import { SchemaChangeBatchOwnershipGuard, SchemaChangeOwnershipGuard } from '../../guards/index.js';
67
import { ConnectionEntity } from '../connection/connection.entity.js';
78
import { LogOutEntity } from '../log-out/log-out.entity.js';
89
import { UserEntity } from '../user/user.entity.js';
@@ -18,8 +19,6 @@ import { RejectBatchSchemaChangesUseCase } from './use-cases/reject-batch-schema
1819
import { RejectSchemaChangeUseCase } from './use-cases/reject-schema-change.use-case.js';
1920
import { RollbackBatchSchemaChangesUseCase } from './use-cases/rollback-batch-schema-changes.use-case.js';
2021
import { RollbackSchemaChangeUseCase } from './use-cases/rollback-schema-change.use-case.js';
21-
import { SchemaChangeBatchOwnershipGuard } from './utils/schema-change-batch-ownership.guard.js';
22-
import { SchemaChangeOwnershipGuard } from './utils/schema-change-ownership.guard.js';
2322

2423
@Module({
2524
imports: [TypeOrmModule.forFeature([TableSchemaChangeEntity, ConnectionEntity, UserEntity, LogOutEntity])],

backend/src/guards/index.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@ export { DashboardEditGuard } from './dashboard-edit.guard.js';
55
export { DashboardReadGuard } from './dashboard-read.guard.js';
66
export { GroupEditGuard } from './group-edit.guard.js';
77
export { GroupReadGuard } from './group-read.guard.js';
8+
export { SchemaChangeBatchOwnershipGuard } from './schema-change-batch-ownership.guard.js';
9+
export { SchemaChangeOwnershipGuard } from './schema-change-ownership.guard.js';
810
export { TableAddGuard } from './table-add.guard.js';
911
export { TableDeleteGuard } from './table-delete.guard.js';
1012
export { TableEditGuard } from './table-edit.guard.js';

backend/src/entities/table-schema/utils/schema-change-batch-ownership.guard.ts renamed to backend/src/guards/schema-change-batch-ownership.guard.ts

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -8,12 +8,12 @@ import {
88
} from '@nestjs/common';
99
import { InjectRepository } from '@nestjs/typeorm';
1010
import { Repository } from 'typeorm';
11-
import { IRequestWithCognitoInfo } from '../../../authorization/index.js';
12-
import { Messages } from '../../../exceptions/text/messages.js';
13-
import { ValidationHelper } from '../../../helpers/validators/validation-helper.js';
14-
import { CedarAction } from '../../cedar-authorization/cedar-action-map.js';
15-
import { CedarAuthorizationService } from '../../cedar-authorization/cedar-authorization.service.js';
16-
import { TableSchemaChangeEntity } from '../table-schema-change.entity.js';
11+
import { IRequestWithCognitoInfo } from '../authorization/index.js';
12+
import { CedarAction } from '../entities/cedar-authorization/cedar-action-map.js';
13+
import { CedarAuthorizationService } from '../entities/cedar-authorization/cedar-authorization.service.js';
14+
import { TableSchemaChangeEntity } from '../entities/table-schema/table-schema-change.entity.js';
15+
import { Messages } from '../exceptions/text/messages.js';
16+
import { ValidationHelper } from '../helpers/validators/validation-helper.js';
1717

1818
@Injectable()
1919
export class SchemaChangeBatchOwnershipGuard implements CanActivate {

backend/src/entities/table-schema/utils/schema-change-ownership.guard.ts renamed to backend/src/guards/schema-change-ownership.guard.ts

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -8,12 +8,12 @@ import {
88
} from '@nestjs/common';
99
import { InjectRepository } from '@nestjs/typeorm';
1010
import { Repository } from 'typeorm';
11-
import { IRequestWithCognitoInfo } from '../../../authorization/index.js';
12-
import { Messages } from '../../../exceptions/text/messages.js';
13-
import { ValidationHelper } from '../../../helpers/validators/validation-helper.js';
14-
import { CedarAction } from '../../cedar-authorization/cedar-action-map.js';
15-
import { CedarAuthorizationService } from '../../cedar-authorization/cedar-authorization.service.js';
16-
import { TableSchemaChangeEntity } from '../table-schema-change.entity.js';
11+
import { IRequestWithCognitoInfo } from '../authorization/index.js';
12+
import { CedarAction } from '../entities/cedar-authorization/cedar-action-map.js';
13+
import { CedarAuthorizationService } from '../entities/cedar-authorization/cedar-authorization.service.js';
14+
import { TableSchemaChangeEntity } from '../entities/table-schema/table-schema-change.entity.js';
15+
import { Messages } from '../exceptions/text/messages.js';
16+
import { ValidationHelper } from '../helpers/validators/validation-helper.js';
1717

1818
@Injectable()
1919
export class SchemaChangeOwnershipGuard implements CanActivate {

0 commit comments

Comments
 (0)