Repository navigation
feat(permission): add schemas for permissions, role mappings and token claims - #154
Merged
Merged
Conversation
…n claims Adds the contract for permissions and organization roles: the catalogue and mapping requests and responses, the access token's authorization claims, the live permissions response, and exact permission matching with a Zod-free subpath. MeUser and SeamlessAuthUser gain optional fields for the same data. Closes #98.
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.
Closes #98. Part of the v0.23 Wave 3 work on fells-code/seamless-auth-api#415 and #416.
Why this lands first
The API re-exports its route schemas from this package and parses responses through them, so it cannot build the new routes, or return the new
/users/mefields, until this is published. The API PRs follow on the published version.What
schemas/permissionAccessTokenClaimsSchema:permissions,org_roles,org_permissionsandpermissions_omittedbeside the existing claims. It is a loose object, so a verifier does not refuse a claim added laterEffectivePermissionsResponseSchemaforGET /users/me/permissionshasPermission(any of) andhasAllPermissions(all of), matching exactly. Both refuse an empty requirement, so a guard built from an empty list cannot open a route. Also available without Zod from@seamless-auth/types/permission/matchingMeUserSchemaandSeamlessAuthUserSchema, which an older API does not sendAUTH_EVENT_TYPESPermission names use the role alphabet, which has no
*, so a wildcard cannot be stored as a grant that exact matching would never honor.RoleDefinitionSchemaand the role path params accept any membership role string, because the migration keeps legacy names likeTeam Leadas they are. New organization roles are held to the role name pattern.Testing
npm test(27 files, all passing),typecheck,lint,format:check,buildandtest:zod-floorall passed locally.The API branch was also built against a tarball of this package, and its unit and Postgres suites pass against it. That tarball predates one comment-only edit to
AccessTokenClaimsSchema. The API branch is not pushed yet because it needs the published version.After merge
Merging this and its Version Packages PR publishes the version the API PRs pin.
AUTH_EVENT_TYPESgains values, so an exhaustive switch overAuthEventTypehas to handle them. No system config key is added, so the CLIWRITABLE_KEYStest does not trip.