Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Conversation

@csrbarber
Copy link
Contributor

@csrbarber csrbarber commented Sep 17, 2025

Description

  • Add roles to organization membership resource responses (get, list, create, update, deactivate, reactivate)
  • Add roleSlugs parameter to organization membership create and update options
  • Add roles support to session authentication and JWT decoding

Documentation

Does this require changes to the WorkOS Docs? E.g. the API Reference or code snippets need updates.

[X] Yes

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.

@csrbarber csrbarber requested a review from a team as a code owner September 17, 2025 15:19
@csrbarber csrbarber self-assigned this Sep 17, 2025
Copy link
Contributor

@greptile-apps greptile-apps bot left a 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

Edit Code Review Bot Settings | Greptile

@csrbarber csrbarber requested a review from nicknisi September 17, 2025 17:02
@csrbarber csrbarber merged commit a0b2c55 into main Sep 18, 2025
5 checks passed
@csrbarber csrbarber deleted the add-multiple-roles-support branch September 18, 2025 13:28
csrbarber added a commit that referenced this pull request Sep 18, 2025
## 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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

4 participants