-
Notifications
You must be signed in to change notification settings - Fork 46
Authorization Resources (external ID) endpoints and listResources endpoint #1472
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 (external ID) endpoints and listResources endpoint #1472
Conversation
|
@greptile can you plz do a first pass review |
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.
11 files reviewed, 1 comment
|
@greptile plz re-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.
12 files reviewed, 1 comment
|
@greptile plz re-review this pr |
Greptile OverviewGreptile SummaryThis PR implements four new authorization resource endpoints that enable operations using external IDs instead of internal resource IDs:
The implementation follows established patterns in the codebase with consistent serialization, proper TypeScript typing, and comprehensive test coverage. All new methods properly handle nullable fields ( Confidence Score: 5/5
Important Files Changed
Sequence DiagramsequenceDiagram
participant Client
participant SDK as WorkOS SDK
participant Serializer
participant API as WorkOS API
Note over Client,API: List Resources Flow
Client->>SDK: listResources(options)
SDK->>Serializer: serializeListAuthorizationResourcesOptions()
Serializer->>Serializer: Convert arrays to comma-separated strings
Serializer->>Serializer: Convert camelCase to snake_case
Serializer-->>SDK: serialized params
SDK->>API: GET /authorization/resources?params
API-->>SDK: AuthorizationResourceListResponse
SDK->>SDK: deserializeAuthorizationResource() for each item
SDK-->>Client: AuthorizationResourceList
Note over Client,API: Get/Update/Delete by External ID Flow
Client->>SDK: getResourceByExternalId({org, type, externalId})
SDK->>API: GET /authorization/organizations/{org}/resources/{type}/{externalId}
API-->>SDK: AuthorizationResourceResponse
SDK->>SDK: deserializeAuthorizationResource()
SDK-->>Client: AuthorizationResource
Client->>SDK: updateResourceByExternalId(options)
SDK->>Serializer: serializeUpdateResourceByExternalIdOptions()
Serializer->>Serializer: Filter undefined fields
Serializer-->>SDK: serialized body
SDK->>API: PATCH /authorization/organizations/{org}/resources/{type}/{externalId}
API-->>SDK: AuthorizationResourceResponse
SDK->>SDK: deserializeAuthorizationResource()
SDK-->>Client: AuthorizationResource
Client->>SDK: deleteResourceByExternalId({org, type, externalId})
SDK->>API: DELETE /authorization/organizations/{org}/resources/{type}/{externalId}
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.
12 files reviewed, 1 comment
src/authorization/serializers/list-authorization-resources-options.serializer.ts
Outdated
Show resolved
Hide resolved
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.
12 files reviewed, no comments
src/authorization/authorization.ts
Outdated
| await this.workos.delete(`/authorization/resources/${resourceId}`); | ||
| } | ||
|
|
||
| // part 2 |
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.
| // part 2 |
| ): Promise<AuthorizationResource> { | ||
| const { organizationId, resourceTypeSlug, externalId } = options; | ||
| const { data } = await this.workos.get<AuthorizationResourceResponse>( | ||
| `/authorization/organizations/${organizationId}/resources/${resourceTypeSlug}/${externalId}`, |
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.
suggestion: could externalId contain URL-significant characters? Not sure if this is gated elsewhere but could be good to wrap with encodeURIComponent.
| } | ||
|
|
||
| export interface SerializedListAuthorizationResourcesOptions { | ||
| organization_ids?: 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 have a ticket to change this and slugs to singular organization_id, resource_type_slug
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.
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'll update with a change once it is merged
| @@ -31,8 +31,6 @@ export interface CreateAuthorizationResourceOptions { | |||
| 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.
Same comment about type_slug + external_id
4be4df5
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 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.
Each one will call the corresponding new fga endpoints within workos repo
listResources() ~ https://github.com/workos/workos/blob/51f5a445c3a247f5f093bfaae8e385629df56d36/packages/api/src/authorization-resources/authorization-resources.controller.ts#L83
getResourceByExternalId() ~ https://github.com/workos/workos/blob/51f5a445c3a247f5f093bfaae8e385629df56d36/packages/api/src/authorization-resources/authorization-resources-by-external-id.controller.ts#L90
updateResourceByExternalId() ~ https://github.com/workos/workos/blob/51f5a445c3a247f5f093bfaae8e385629df56d36/packages/api/src/authorization-resources/authorization-resources-by-external-id.controller.ts#L183
deleteResourceByExternalId() ~ https://github.com/workos/workos/blob/51f5a445c3a247f5f093bfaae8e385629df56d36/packages/api/src/authorization-resources/authorization-resources-by-external-id.controller.ts#L221