Skip to content

Add cedarPolicy field to group creation and update APIs#1668

Open
gugu wants to merge 3 commits intomainfrom
cedar-policy-backend
Open

Add cedarPolicy field to group creation and update APIs#1668
gugu wants to merge 3 commits intomainfrom
cedar-policy-backend

Conversation

@gugu
Copy link
Contributor

@gugu gugu commented Mar 14, 2026

Expose cedarPolicy through backend DTOs, responses, and use cases for creating and updating user groups.

Expose cedarPolicy through backend DTOs, responses, and use cases
for creating and updating user groups.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Copilot AI review requested due to automatic review settings March 14, 2026 10:35
@gugu gugu requested a review from Artuomka March 14, 2026 10:36
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Expose cedarPolicy through group-related DTOs/responses and allow clients to provide/update it during group creation and group title update flows.

Changes:

  • Add cedarPolicy to group response/data structures (FoundGroupResponseDto, FoundGroupDataInfoDs, connection/group DTO builders).
  • Allow cedarPolicy to be provided on group creation (CreateGroupInConnectionDTO/DS + use case).
  • Allow cedarPolicy to be provided on group title update (UpdateGroupTitleDto + use case) and invalidate Cedar policy cache.

Reviewed changes

Copilot reviewed 11 out of 11 changed files in this pull request and generated 6 comments.

Show a summary per file
File Description
backend/src/entities/group/utils/biuld-found-group-response.dto.ts Include cedarPolicy in found-group response builder.
backend/src/entities/group/use-cases/update-group-title.use.case.ts Accept/update cedarPolicy, adjust uniqueness check, invalidate Cedar cache, return cedarPolicy.
backend/src/entities/group/dto/update-group-title.dto.ts Add optional/nullable cedarPolicy to update-title DTO.
backend/src/entities/group/dto/found-group-response.dto.ts Add optional/nullable cedarPolicy to group response DTO.
backend/src/entities/group/application/data-sctructures/found-user-groups.ds.ts Add optional/nullable cedarPolicy to group data structure.
backend/src/entities/connection/utils/build-found-user-group-in-connection-dto.util.ts Include cedarPolicy in group-in-connection DTO builder.
backend/src/entities/connection/use-cases/create-group-in-connection.use.case.ts Accept optional cedarPolicy and default-generate when missing; invalidate Cedar cache.
backend/src/entities/connection/connection.controller.ts Pass cedarPolicy from request body into group creation input.
backend/src/entities/connection/application/dto/found-user-groups-in-connection.dto.ts Add optional/nullable cedarPolicy to connection groups DTO.
backend/src/entities/connection/application/dto/create-group-in-connection.dto.ts Add optional/nullable cedarPolicy to create-group DTO.
backend/src/entities/connection/application/data-structures/create-group-in-connection.ds.ts Add optional/nullable cedarPolicy to create-group DS.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines +16 to +19
@IsOptional()
@IsString()
@ApiProperty({ required: false, nullable: true })
cedarPolicy?: string | null;
Comment on lines +39 to +45
savedGroup.cedarPolicy =
cedarPolicy ??
generateCedarPolicyForGroup(connectionId, false, {
connection: { connectionId, accessLevel: AccessLevelEnum.none },
group: { groupId: savedGroup.id, accessLevel: AccessLevelEnum.none },
tables: [],
},
);
});
Comment on lines +39 to +45
savedGroup.cedarPolicy =
cedarPolicy ??
generateCedarPolicyForGroup(connectionId, false, {
connection: { connectionId, accessLevel: AccessLevelEnum.none },
group: { groupId: savedGroup.id, accessLevel: AccessLevelEnum.none },
tables: [],
},
);
});
Comment on lines +9 to +13

@IsOptional()
@IsString()
@ApiProperty({ required: false, nullable: true })
cedarPolicy?: string | null;
Comment on lines 42 to +46
groupToUpdate.title = title;
if (cedarPolicy !== undefined) {
groupToUpdate.cedarPolicy = cedarPolicy;
Cacher.invalidateCedarPolicyCache(groupToUpdate.connection.id);
}
Comment on lines 42 to 47
groupToUpdate.title = title;
if (cedarPolicy !== undefined) {
groupToUpdate.cedarPolicy = cedarPolicy;
Cacher.invalidateCedarPolicyCache(groupToUpdate.connection.id);
}
const updatedGroup = await this._dbContext.groupRepository.saveNewOrUpdatedGroup(groupToUpdate);
@gugu gugu mentioned this pull request Mar 16, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants