Authorization Resources endpoints for Internal ID#1471
Authorization Resources endpoints for Internal ID#1471swaroopAkkineniWorkos merged 21 commits intoENT-4372-base-authorization-branchfrom
Conversation
a1466df to
60dff4c
Compare
04b9596 to
685643c
Compare
|
@greptile plz review this pr |
|
@claude plz review this pr |
src/authorization/serializers/update-authorization-resource-options.serializer.ts
Outdated
Show resolved
Hide resolved
src/authorization/serializers/create-authorization-resource-options.serializer.ts
Show resolved
Hide resolved
Additional Comments (1)
This serializer also always includes |
|
@greptile plz re-review this pr |
|
@greptile plz re-review this pr |
Greptile OverviewGreptile SummaryThis PR adds Authorization Resources support to the Node SDK by introducing new resource interfaces, serializers/deserializers, a fixture, and unit tests. The The new code fits into the existing One functional mismatch remains: the new methods currently call Confidence Score: 3/5
Important Files Changed
Sequence DiagramsequenceDiagram
participant U as SDK Consumer
participant A as Authorization client
participant W as WorkOS HTTP client
participant API as WorkOS API
U->>A: getResource(resourceId)
A->>W: GET /authorization/resources/{resourceId}
W->>API: HTTP GET
API-->>W: AuthorizationResourceResponse
W-->>A: data
A-->>U: AuthorizationResource (deserialized)
U->>A: createResource(options)
A->>A: serializeCreateResourceOptions(options)
A->>W: POST /authorization/resources (body)
W->>API: HTTP POST
API-->>W: AuthorizationResourceResponse (201)
W-->>A: data
A-->>U: AuthorizationResource (deserialized)
U->>A: updateResource({resourceId, ...})
A->>A: serializeUpdateResourceOptions(options)
A->>W: PATCH /authorization/resources/{resourceId} (body)
W->>API: HTTP PATCH
API-->>W: AuthorizationResourceResponse
W-->>A: data
A-->>U: AuthorizationResource (deserialized)
U->>A: deleteResource(resourceId)
A->>W: DELETE /authorization/resources/{resourceId}
W->>API: HTTP DELETE
API-->>W: 204 No Content
W-->>A: void
A-->>U: void
|
| async getResource(resourceId: string): Promise<AuthorizationResource> { | ||
| const { data } = await this.workos.get<AuthorizationResourceResponse>( | ||
| `/authorization/resources/${resourceId}`, | ||
| ); |
There was a problem hiding this comment.
Doesn’t call FGA endpoints
PR description says these Authorization Resources methods should call the corresponding FGA endpoints, but Authorization.getResource/createResource/updateResource/deleteResource are wired to /authorization/resources... instead of /fga/v1/resources.... As-is, this will hit a different API surface than intended and will break in environments where only the FGA endpoints exist/are supported for Internal IDs.
There was a problem hiding this comment.
sorry, this is my fault. The new endpoints are part of the new fga flow
atainter
left a comment
There was a problem hiding this comment.
Looks good, but we might want to support those two extra options for the parent resources external_id + type slug
| description?: string | null; | ||
| resourceTypeSlug: string; | ||
| organizationId: string; | ||
| parentResourceId?: string | null; |
There was a problem hiding this comment.
We're also going to support parentResourceExternalId + parentResourceTypeSlug. I haven't added support for them yet, but it's an action item from our bug bash
There was a problem hiding this comment.
updated!, mind doublechecking when you get a chance @atainter. Gonna merge this into my base branchbut if anything is wrong, I can always update the base branch
|
|
||
| const workos = new WorkOS('sk_test_Sz3IQjepeSWaI4cMS4ms4sMuU'); | ||
| const testOrgId = 'org_01HXYZ123ABC456DEF789ABC'; | ||
| const testResourceId = 'resource_01HXYZ123ABC456DEF789ABC'; |
There was a problem hiding this comment.
the prefix will be authz_resource_ after we merge https://github.com/workos/workos/pull/52102
There was a problem hiding this comment.
updated in prep for it
a54e1e1
into
ENT-4372-base-authorization-branch
Adding these endpoints to the sdk #1471 ``` getResource() ~ GET /authorization/resources/{resource_id} createResource() ~ POST /authorization/resources updateResource() ~ PATCH /authorization/resources/{resource_id} deleteResource() ~ DELETE /authorization/resources/{resource_id} ``` #1473 ``` check() | POST /authorization/organization_memberships/{om_id}/check ``` #1472 ``` listResources() | GET /authorization/organizations/{org_id}/resources getResourceByExternalId() | GET /authorization/organizations/{org_id}/resources/{type}/{external_id} updateResourceByExternalId() | PATCH /authorization/organizations/{org_id}/resources/{type}/{external_id} deleteResourceByExternalId() | DELETE /authorization/organizations/{org_id}/resources/{type}/{external_id} ``` #1474 ``` listRoleAssignments() | GET /authorization/organization_memberships/{om_id}/role_assignments assignRole() | POST /authorization/organization_memberships/{om_id}/role_assignments removeRole() | DELETE /authorization/organization_memberships/{om_id}/role_assignments removeRoleAssignment() | DELETE /authorization/organization_memberships/{om_id}/role_assignments/{ra_id} ``` #1478 ``` listResourcesForMembership() | GET /authorization/organization_memberships/{om_id}/resources listMembershipsForResource() | GET /authorization/resources/{resource_id}/organization_memberships listMembershipsForResourceByExternalId() | GET /authorization/organizations/{org_id}/resources/{type}/{external_id}/organization_memberships ```
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 mergesENT-4372-base-authorization-branchinto the main.desc: the goal of this pr is to implement the following endpoints in the node sdk.
Each one should call their corresponding new fga endpoint
getResource() ~ https://github.com/workos/workos/blob/85a2309cabfd6c11dd0fc4f39fed3abc9c45c0bc/packages/api/src/authorization-resources/authorization-resources.controller.ts#L179
createResource() ~ https://github.com/workos/workos/blob/85a2309cabfd6c11dd0fc4f39fed3abc9c45c0bc/packages/api/src/authorization-resources/authorization-resources.controller.ts#L219
updateResource() ~ https://github.com/workos/workos/blob/85a2309cabfd6c11dd0fc4f39fed3abc9c45c0bc/packages/api/src/authorization-resources/authorization-resources.controller.ts#L301
deleteResource() ~ https://github.com/workos/workos/blob/85a2309cabfd6c11dd0fc4f39fed3abc9c45c0bc/packages/api/src/authorization-resources/authorization-resources.controller.ts#L330