-
Notifications
You must be signed in to change notification settings - Fork 46
feat(authorization): add role assignment methods #1474
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: ENT-4372-base-authorization-branch
Are you sure you want to change the base?
feat(authorization): add role assignment methods #1474
Conversation
- Add listRoleAssignments() for listing role assignments - Add assignRole() for assigning roles to resources - Add removeRole() for removing by role/resource criteria (via query params) - Add removeRoleAssignment() for removing by assignment ID Includes: - 5 new interface files for role assignments - 3 new serializer files - 2 fixture files for testing - 8 new tests (all passing) ENT-4372 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
|
@greptile do a first pass review plz |
Greptile OverviewGreptile SummaryThis PR implements four role assignment methods for the WorkOS Node SDK's authorization module: Key Changes:
Testing: Confidence Score: 5/5
Important Files Changed
Sequence DiagramsequenceDiagram
participant Client
participant SDK as Authorization SDK
participant Serializer
participant API as WorkOS API
Note over Client,API: List Role Assignments
Client->>SDK: listRoleAssignments(options)
SDK->>API: GET /authorization/organization_memberships/{id}/role_assignments
API-->>SDK: RoleAssignmentListResponse (snake_case)
SDK->>Serializer: deserializeRoleAssignment()
Serializer-->>SDK: RoleAssignment (camelCase)
SDK-->>Client: RoleAssignmentList
Note over Client,API: Assign Role
Client->>SDK: assignRole(options)
SDK->>Serializer: serializeAssignRoleOptions()
Serializer-->>SDK: SerializedOptions (snake_case)
SDK->>API: POST /authorization/organization_memberships/{id}/role_assignments
API-->>SDK: RoleAssignmentResponse (snake_case)
SDK->>Serializer: deserializeRoleAssignment()
Serializer-->>SDK: RoleAssignment (camelCase)
SDK-->>Client: RoleAssignment
Note over Client,API: Remove Role (by resource)
Client->>SDK: removeRole(options)
SDK->>Serializer: serializeRemoveRoleOptions()
Serializer-->>SDK: Query params (snake_case)
SDK->>API: DELETE /authorization/organization_memberships/{id}/role_assignments?params
API-->>SDK: 204 No Content
SDK-->>Client: void
Note over Client,API: Remove Role Assignment (by ID)
Client->>SDK: removeRoleAssignment(options)
SDK->>API: DELETE /authorization/organization_memberships/{id}/role_assignments/{ra_id}
API-->>SDK: 204 No Content
SDK-->>Client: void
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
14 files reviewed, no comments
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
14 files reviewed, no comments
| organizationMembershipId: string; | ||
| roleSlug: string; | ||
| resourceId?: string; | ||
| resourceExternalId?: string; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I wonder if we should actually make resource argument this for all endpoints
resource: {id: string} | {external_id: string, type_slug: string}
Because we also have it for remove/assign role options
It could be a union of types
type ResourceOptions = {id: string} | {external_id: string, type_slug: string}[3:17 PM]export interface RemoveRoleOptions {
organizationMembershipId: string;
roleSlug: string;
resource: ResourceOptions
}
| await this.workos.delete(`/authorization/resources/${resourceId}`); | ||
| } | ||
|
|
||
| // phase 3 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| // phase 3 |
linear: https://linear.app/workos/issue/ENT-4372/sdk-updates
I decided to break up the work for ENT-4372 into a smaller pr's that we can be easily reviewed and merge them into ENT-4372-base-authorization-branch. Then we can have one final merge that merges ENT-4372-base-authorization-branch into the main.
desc: the goal of this pr is to implement the following endpoints in the node sdk.
listRoleAssignments() ~ https://github.com/workos/workos/blob/1bf21e074e2cde476d83660ca41e05853fa081b8/packages/api/src/authorization/authorization-role-assignments.controller.ts#L83
assignRole() ~ https://github.com/workos/workos/blob/1bf21e074e2cde476d83660ca41e05853fa081b8/packages/api/src/authorization/authorization-role-assignments.controller.ts#L140
removeRole() ~ https://github.com/workos/workos/blob/1bf21e074e2cde476d83660ca41e05853fa081b8/packages/api/src/authorization/authorization-role-assignments.controller.ts#L205
removeRoleAssignment() ~ https://github.com/workos/workos/blob/1bf21e074e2cde476d83660ca41e05853fa081b8/packages/api/src/authorization/authorization-role-assignments.controller.ts#L264