-
Notifications
You must be signed in to change notification settings - Fork 46
Authorization Resources endpoints for Internal ID #1471
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
Authorization Resources endpoints for Internal ID #1471
Conversation
a1466df to
60dff4c
Compare
04b9596 to
685643c
Compare
|
@greptile plz review this pr |
|
@claude plz review this pr |
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.
9 files reviewed, 4 comments
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
|
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.
9 files reviewed, 1 comment
| async getResource(resourceId: string): Promise<AuthorizationResource> { | ||
| const { data } = await this.workos.get<AuthorizationResourceResponse>( | ||
| `/authorization/resources/${resourceId}`, | ||
| ); |
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.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
the prefix will be authz_resource_ after we merge https://github.com/workos/workos/pull/52102
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.
updated in prep for it
a54e1e1
into
ENT-4372-base-authorization-branch
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