-
Notifications
You must be signed in to change notification settings - Fork 44
Add multiple roles support #1358
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
Conversation
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.
Greptile Summary
This PR implements comprehensive multiple roles support across the WorkOS Node.js SDK, moving from a single-role model to a multi-role model for organization memberships. The changes span three main areas:
Organization Membership API Updates: New roleSlugs parameter has been added to both create and update organization membership options, allowing assignment of multiple roles during membership operations. The serializers properly transform camelCase roleSlugs arrays to snake_case role_slugs for API communication while maintaining the existing roleSlug/role_slug fields for backward compatibility.
Response Interface Extensions: The OrganizationMembership and OrganizationMembershipResponse interfaces now include an optional roles array alongside the existing required role field. The membership serializer uses conditional object spreading to include the roles array only when present in API responses, preventing undefined values in the output.
Session Authentication Enhancement: JWT token decoding and session authentication have been extended to handle multiple roles. Both the authenticateWithSessionCookie method in user-management and session management extract roles arrays from JWT access tokens alongside the existing role field. The AccessToken interface and authentication response types now include optional roles: string[] fields.
The implementation follows a careful backward-compatible approach by keeping all existing single-role functionality intact while adding parallel multi-role support. This allows gradual migration from single to multiple role assignments without breaking existing integrations. The changes are consistent across interfaces, serializers, and authentication flows, maintaining the established patterns in the codebase.
Additionally, the PR includes a minor improvement to .gitignore by adding the .idea/ directory for JetBrains IDE configuration files.
Confidence score: 5/5
- This PR is safe to merge with minimal risk as it maintains full backward compatibility while adding new functionality
- Score reflects well-structured implementation with consistent patterns, comprehensive test coverage, and proper TypeScript typing
- No files require special attention as the changes follow established codebase conventions and maintain API compatibility
12 files reviewed, no comments
## Summary Version bump to 7.70.0 ## Changes - Bump version to 7.70.0 in package.json, package-lock.json, and src/workos.ts - Update snapshot tests with new version ## Changes in this version - #1358
Description
rolesto organization membership resource responses (get, list, create, update, deactivate, reactivate)roleSlugsparameter to organization membership create and update optionsrolessupport to session authentication and JWT decodingDocumentation
Does this require changes to the WorkOS Docs? E.g. the API Reference or code snippets need updates.
Will update the docs for these changes in ENT-3687
Testing
Tested locally against a team with multiple roles enabled. I tested OM get and update, along with the user management auth flow.