Skip to content

Add roles to directory user & profile#1401

Merged
kendallstrautman merged 4 commits intomainfrom
feature/ent-4658-node
Dec 3, 2025
Merged

Add roles to directory user & profile#1401
kendallstrautman merged 4 commits intomainfrom
feature/ent-4658-node

Conversation

@kendallstrautman
Copy link
Contributor

@kendallstrautman kendallstrautman commented Nov 25, 2025

Description

Adds roles property to directory user and SSO profile to support multiple roles.

Documentation

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

  • Yes

If yes, link a related docs PR and add a docs maintainer as a reviewer. Their approval is required.

@kendallstrautman kendallstrautman marked this pull request as ready for review November 25, 2025 01:05
@kendallstrautman kendallstrautman requested a review from a team as a code owner November 25, 2025 01:05
@greptile-apps
Copy link
Contributor

greptile-apps bot commented Nov 25, 2025

Greptile Overview

Greptile Summary

This PR adds support for multiple roles by introducing an optional roles array property to directory users and SSO profiles. The existing singular role field is preserved for backward compatibility.

Key changes:

  • Added optional roles?: RoleResponse[] field to DirectoryUser, DirectoryUserResponse, Profile, and ProfileResponse interfaces
  • Updated serializers to properly map the roles field between API responses and client objects
  • Updated all test fixtures and snapshots to include the new roles array alongside the existing role field
  • The implementation maintains backward compatibility by keeping both role (singular) and roles (array) as optional fields

Implementation notes:

  • The serializers correctly handle the optional roles field by passing it through unchanged (no transformation needed since RoleResponse structure is the same in both formats)
  • Event interfaces automatically inherit the new field through the DirectoryUser and DirectoryUserResponse types
  • Test coverage includes both directory sync and SSO flows with role data

Confidence Score: 5/5

  • This PR is safe to merge with minimal risk
  • The changes are straightforward, well-tested, and maintain backward compatibility. The implementation follows existing patterns in the codebase, properly updates both interfaces and serializers, includes comprehensive test coverage with updated snapshots, and doesn't introduce any security concerns or breaking changes.
  • No files require special attention

Important Files Changed

File Analysis

Filename Score Overview
src/directory-sync/interfaces/directory-user.interface.ts 5/5 Added optional roles array field to DirectoryUser and DirectoryUserResponse interfaces
src/directory-sync/serializers/directory-user.serializer.ts 5/5 Updated serializers to map roles field between API response and client format
src/sso/interfaces/profile.interface.ts 5/5 Added optional roles array field to Profile and ProfileResponse interfaces
src/sso/serializers/profile.serializer.ts 5/5 Updated profile serializer to map roles field from snake_case to camelCase

Sequence Diagram

sequenceDiagram
    participant API as WorkOS API
    participant Serializer as Serializer Layer
    participant Client as Client Application
    
    Note over API,Client: Directory Sync Flow
    API->>Serializer: DirectoryUserResponse<br/>{role, roles, ...}
    Serializer->>Client: DirectoryUser<br/>{role, roles, ...}
    
    Note over API,Client: SSO Profile Flow
    API->>Serializer: ProfileResponse<br/>{role, roles, ...}
    Serializer->>Client: Profile<br/>{role, roles, ...}
    
    Note over Client: Both role (singular) and<br/>roles (array) are now<br/>available to support<br/>multiple roles
Loading

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.

6 files reviewed, no comments

Edit Code Review Agent Settings | Greptile

@kendallstrautman kendallstrautman merged commit c9ac713 into main Dec 3, 2025
5 checks passed
@kendallstrautman kendallstrautman deleted the feature/ent-4658-node branch December 3, 2025 20:16
@greptile-apps greptile-apps bot mentioned this pull request Dec 3, 2025
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