-
Notifications
You must be signed in to change notification settings - Fork 4
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
1 parent
ed11311
commit 8cb4862
Showing
16 changed files
with
300 additions
and
115 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
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
16 changes: 7 additions & 9 deletions
16
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 |
---|---|---|
@@ -1,14 +1,12 @@ | ||
import { Action, Criterion } from '@narval/authz-shared' | ||
import { ApiProperty } from '@nestjs/swagger' | ||
import { IsDefined, IsEnum } from 'class-validator' | ||
import { Action } from '@narval/authz-shared' | ||
|
||
export class ActionCriterionDto { | ||
@IsDefined() | ||
@ApiProperty() | ||
criterion: typeof Criterion.CHECK_ACTION | ||
// @IsDefined() | ||
// @ApiProperty() | ||
// criterion: typeof Criterion.CHECK_ACTION | ||
|
||
@IsDefined() | ||
@IsEnum(Action, { each: true }) | ||
@ApiProperty({ isArray: true, enum: Action }) | ||
// @IsDefined() | ||
// @IsEnum(Action, { each: true }) | ||
// @ApiProperty({ isArray: true, enum: Action }) | ||
args: Action[] | ||
} |
8 changes: 3 additions & 5 deletions
8
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
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
41 changes: 19 additions & 22 deletions
41
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,28 +1,25 @@ | ||
import { Criterion } from '@narval/authz-shared' | ||
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) }) | ||
// @IsIn(Object.values(Criterion)) | ||
// @IsDefined() | ||
// @ApiProperty({ enum: Object.values(Criterion) }) | ||
criterion: Criterion | ||
|
||
@ValidateNested() | ||
@Type((opts) => { | ||
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 | ||
// @ValidateNested() | ||
// @Type((opts) => { | ||
// switch (opts?.object.criterion) { | ||
// case Criterion.CHECK_ACTION: | ||
// return ActionCriterionDto | ||
// case Criterion.CHECK_RESOURCE_INTEGRITY: | ||
// return ResourceIntegrityCriterionDto | ||
// default: | ||
// throw Error('boom, sam change in the future') | ||
// } | ||
// }) | ||
// @IsDefined() | ||
// @ApiProperty({ | ||
// oneOf: [{ $ref: getSchemaPath(ActionCriterionDto) }, { $ref: getSchemaPath(ResourceIntegrityCriterionDto) }] | ||
// }) | ||
// args: ActionCriterionDto | ResourceIntegrityCriterionDto | ||
} |
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
20 changes: 12 additions & 8 deletions
20
apps/authz/src/app/http/rest/dto/policy-rules/set-policy-rules-response.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,15 +1,19 @@ | ||
import { PolicyCriterionBuilder } from '@narval/authz-shared' | ||
import { Policy } from '@narval/authz-shared' | ||
import { ApiProperty } from '@nestjs/swagger' | ||
import { Type } from 'class-transformer' | ||
import { IsDefined, ValidateNested } from 'class-validator' | ||
import { PolicyCriterionBuilderDto } from './policy-criterion-builder.dto' | ||
|
||
export class SetPolicyRulesResponseDto { | ||
constructor(policyRules: PolicyCriterionBuilder[]) { | ||
this.policyRules = policyRules.map((rule) => new PolicyCriterionBuilderDto(rule)) | ||
} | ||
|
||
@IsDefined() | ||
@Type(() => Policy) | ||
@ValidateNested() | ||
@ApiProperty() | ||
policyRules: PolicyCriterionBuilderDto[] | ||
@ApiProperty({ | ||
type: () => Policy, | ||
isArray: true | ||
}) | ||
policyRules: Policy[] | ||
|
||
constructor(partial: Partial<SetPolicyRulesResponseDto>) { | ||
Object.assign(this, partial) | ||
} | ||
} |
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
Oops, something went wrong.