-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
12 changed files
with
64 additions
and
23 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
14 changes: 14 additions & 0 deletions
14
apps/authz/src/app/http/rest/dto/policy-rules/criteria/action-criterion.dto.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
import { Action, Criterion } from '@narval/authz-shared' | ||
import { ApiProperty } from '@nestjs/swagger' | ||
import { IsDefined, IsEnum } from 'class-validator' | ||
|
||
export class ActionCriterionDto { | ||
@IsDefined() | ||
@ApiProperty() | ||
criterion: typeof Criterion.CHECK_ACTION | ||
|
||
@IsDefined() | ||
@IsEnum(Action, { each: true }) | ||
@ApiProperty({ isArray: true, enum: Action }) | ||
args: Action[] | ||
} |
12 changes: 12 additions & 0 deletions
12
apps/authz/src/app/http/rest/dto/policy-rules/criteria/resource-integrity-criterion.dto.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
import { Criterion } from '@narval/authz-shared' | ||
import { ApiProperty } from '@nestjs/swagger' | ||
import { IsDefined } from 'class-validator' | ||
|
||
export class ResourceIntegrityCriterionDto { | ||
@IsDefined() | ||
@ApiProperty() | ||
criterion: typeof Criterion.CHECK_RESOURCE_INTEGRITY | ||
|
||
@ApiProperty() | ||
args: null | ||
} |
26 changes: 20 additions & 6 deletions
26
apps/authz/src/app/http/rest/dto/policy-rules/policy-criterion.dto.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,14 +1,28 @@ | ||
import { Criterion } from '@narval/authz-shared' | ||
import { ApiProperty } from '@nestjs/swagger' | ||
import { IsDefined, IsIn } from 'class-validator' | ||
import { ApiProperty, getSchemaPath } from '@nestjs/swagger' | ||
import { Type } from 'class-transformer' | ||
import { IsDefined, IsIn, ValidateNested } from 'class-validator' | ||
import { ActionCriterionDto } from './criteria/action-criterion.dto' | ||
import { ResourceIntegrityCriterionDto } from './criteria/resource-integrity-criterion.dto' | ||
|
||
export class PolicyCriterionDto { | ||
@IsIn(Object.values(Criterion)) | ||
@IsDefined() | ||
@ApiProperty({ | ||
enum: Object.values(Criterion) | ||
}) | ||
@ApiProperty({ enum: Object.values(Criterion) }) | ||
criterion: Criterion | ||
|
||
args: any | ||
@ValidateNested() | ||
@Type((opts) => { | ||
Check failure on line 15 in apps/authz/src/app/http/rest/dto/policy-rules/policy-criterion.dto.ts GitHub Actions / Build and test
Check failure on line 15 in apps/authz/src/app/http/rest/dto/policy-rules/policy-criterion.dto.ts GitHub Actions / Build and test
|
||
if (opts?.object.criterion === Criterion.CHECK_ACTION) { | ||
return ActionCriterionDto | ||
} | ||
if (opts?.object.criterion === Criterion.CHECK_RESOURCE_INTEGRITY) { | ||
return ResourceIntegrityCriterionDto | ||
} | ||
}) | ||
@IsDefined() | ||
@ApiProperty({ | ||
oneOf: [{ $ref: getSchemaPath(ActionCriterionDto) }, { $ref: getSchemaPath(ResourceIntegrityCriterionDto) }] | ||
}) | ||
args: ActionCriterionDto | ResourceIntegrityCriterionDto | ||
} |
4 changes: 2 additions & 2 deletions
4
apps/authz/src/app/http/rest/dto/policy-rules/set-policy-rules-request.dto.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters