Repository navigation
feat: Add native group authorization - #136
Merged
Merged
Conversation
[High impact] The PR appears safe to merge, with the previous member-removal issue fixed. SummaryAdds native group role assignments and includes their grants in permission checks and assignment lists.
|
The emulator's group grants diverged from the pinned spec (0.98.0) and
from production in ways SDK fixtures and id-matching consumers would
trip over:
- Criteria DELETE on /authorization/groups/{id}/role_assignments always
answered 204. The spec says "Returns 404 when no matching active
assignment is found", and production resolves the slug first
(group-role-assignments.orchestrator.ts:199 throws
RoleNotFoundException) before group-role-assignments.service.ts:395
throws GroupRoleAssignmentNotFoundException on `affected === 0`.
- The duplicate 409 used an invented code. The spec's const, and the
controller at authorization-group-role-assignments.controller.ts
lines 271/331/462, is `duplicate_group_role_assignment`.
- Ids were minted with a literal `gra` outside ID_PREFIXES, so the
prefix conformance test never saw the spec's `gra_01HXYZ…` example.
- An omitted resource was stored as nulls, but the spec requires
`resource.id`, `external_id` and `resource_type_slug` as strings:
production's resolveResource (orchestrator lines 238-281) maps an
omitted selector to findOrCreateOrganizationResource. Group grants
are therefore always resource-scoped, and the organization rename
sync must refresh their denormalized `resource_external_id` too.
The direct membership criteria DELETE gains the same 404 for an unknown
slug (organization-membership-user-roles-orchestrator.ts:2433) but keeps
204 when nothing matches, because production's removeSubResourceScopedRole
(lines 2387-2393) and removeRoleFromAllUserRolesForLockedMembership
(line 1282) are no-ops there.
Moving the formatter into helpers.ts and registering
`group_role_assignment` in OBJECT_SCHEMA_MAP puts the shape under the
spec-conformance harness, which is what would have caught the nulls.
…each group once Removal by criteria on a membership resolved the slug to a role but then matched assignments by slug, so when an organization role shadows an environment role of the same slug both grants went, taking the environment role's permissions with them. Match the resolved role's id, as the group route already does. A seed that repeats a member email links the membership to the same group more than once, and each link re-expanded the group's grants under the same derived id. With limit=1 the cursor then pointed at the first copy forever. Expand each group once per membership.
A seed that names the same member email twice created two links to the same membership. Removing the member then deleted only one of them, so the member kept the group's permissions. Link once at seed time, which is also what the POST route already does, and drop the per-request guard that worked around the duplicates when deriving role assignments.
Collaborator
|
thanks! |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Native AuthKit group role assignments are missing from the emulator, so apps using group permissions cannot exercise their authorization flows locally. This adds group assignment create/list/get/delete endpoints, role-and-resource criteria removal for group and direct grants, and the Node SDK's resource PATCH paths.
Checks, effective permissions, resource discovery, and assignment listings resolve current group memberships and resource ancestors through the existing stored roles and resources. Deleting members or groups revokes their derived grants; deleting roles, resources, or organizations cleans up group grants, including grants scoped to the organization itself. Derived role assignments use stable
role_assignment_IDs across membership and resource listings. No assignment webhooks or delayed reconciliation are simulated. Bulk group replacement and resource-type configuration remain outside this subset.The supported-feature matrix and README describe the added behavior and limits. This is based on the latest upstream
mainand contains no request-budget changes from #133.Validation:
@workos/emulate@0.14.0; its nine changed authorization runtime/type files match this branch's build byte for byte.API references: group role assignments and criteria removal.