Skip to content

Conversation

@kendallstrautman
Copy link
Contributor

Description

Adds roles property to directory user and sso profile for multiple roles support.

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 18:43
@kendallstrautman kendallstrautman requested a review from a team as a code owner November 25, 2025 18:43
@greptile-apps
Copy link
Contributor

greptile-apps bot commented Nov 25, 2025

Greptile Overview

Greptile Summary

Added support for multiple roles on both directory users and SSO profiles by introducing a new Roles field that contains all assigned roles, while maintaining backward compatibility with the existing Role field that represents the highest priority role.

Key Changes

  • Added Roles []common.RoleResponse field to directorysync.User struct
  • Added Roles []common.RoleResponse field to sso.Profile struct
  • Updated comment for existing Role field to clarify it represents the highest priority role
  • Updated all test fixtures to include sample Roles data for proper test coverage

Confidence Score: 5/5

  • This PR is safe to merge with minimal risk
  • The changes are additive and maintain backward compatibility by preserving the existing Role field while adding the new Roles field. The implementation is straightforward, follows Go best practices, includes comprehensive test coverage, and introduces no security concerns or breaking changes.
  • No files require special attention

Important Files Changed

File Analysis

Filename Score Overview
pkg/directorysync/client.go 5/5 Added Roles field to User struct for multiple roles support, updated comment for existing Role field
pkg/directorysync/client_test.go 5/5 Updated test fixtures to include Roles array with sample data (member, developer)
pkg/sso/client.go 5/5 Added Roles field to Profile struct for multiple roles support, updated comment for existing Role field
pkg/sso/client_test.go 5/5 Updated test fixtures to include Roles array with sample data (admin, developer)

Sequence Diagram

sequenceDiagram
    participant Client as Go SDK Client
    participant API as WorkOS API
    participant IDP as Identity Provider
    
    Note over Client,API: SSO Flow with Roles
    Client->>API: GetProfileAndToken(code)
    API->>IDP: Validate & Fetch User Data
    IDP-->>API: User Profile + Roles
    API-->>Client: ProfileAndToken{Profile{Role, Roles[]}}
    Note over Client: Role = highest priority<br/>Roles = all roles
    
    Note over Client,API: Directory Sync Flow with Roles
    Client->>API: ListUsers(directory_id)
    API-->>Client: Users[]{Role, Roles[]}
    Client->>API: GetUser(user_id)
    API-->>Client: User{Role, Roles[]}
    Note over Client: Role = highest priority<br/>Roles = all 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 f919d43 into main Dec 3, 2025
3 checks passed
@kendallstrautman kendallstrautman deleted the feature/ent-4665-go branch December 3, 2025 00:32
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Development

Successfully merging this pull request may close these issues.

3 participants