Skip to content

Conversation

@kendallstrautman
Copy link
Contributor

Description

Adds the roles property to SSO profile and directory user 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.

@linear
Copy link

linear bot commented Nov 25, 2025

ENT-4662 Ruby

@kendallstrautman kendallstrautman requested review from a team, ericroberts and nave91 and removed request for a team November 25, 2025 18:56
@kendallstrautman kendallstrautman marked this pull request as ready for review November 25, 2025 20:51
@greptile-apps
Copy link

greptile-apps bot commented Nov 25, 2025

Greptile Overview

Greptile Summary

Added roles array attribute to both Profile and DirectoryUser classes to support multiple role assignments, alongside the existing single role attribute. The DirectoryUser class was refactored to separate authorization attributes (role and roles) from base attributes in the to_json method for better organization.

  • Added roles attribute to Profile and DirectoryUser classes
  • Updated initialization methods to parse roles from API responses
  • Refactored DirectoryUser.to_json to separate base and authorization attributes
  • Updated all test fixtures and expectations to include roles arrays
  • Tests verify to_json output includes roles but lack direct attribute accessor tests

Confidence Score: 5/5

  • Safe to merge - straightforward attribute addition with proper test coverage
  • Clean implementation that adds the new roles attribute alongside existing role without breaking changes. All fixtures updated, tests pass, and the refactoring in DirectoryUser improves code organization
  • No files require special attention

Important Files Changed

File Analysis

Filename Score Overview
lib/workos/directory_user.rb 5/5 Added roles attribute alongside existing role, reorganized to_json to separate authorization attributes
lib/workos/profile.rb 5/5 Added roles attribute to Profile class alongside existing role attribute
spec/lib/workos/sso_spec.rb 4/5 Updated test expectations to include roles array, but lacks direct assertion tests for the new attribute

Sequence Diagram

sequenceDiagram
    participant API as WorkOS API
    participant SDK as Ruby SDK
    participant App as Application Code
    
    Note over API,App: SSO Profile Flow
    App->>SDK: SSO.profile(code)
    SDK->>API: POST /sso/token
    API-->>SDK: JSON response with role & roles
    SDK->>SDK: Profile.initialize(json)
    Note over SDK: Parses role (single) and<br/>roles (array) attributes
    SDK-->>App: Profile object with role & roles
    
    Note over API,App: Directory User Flow
    App->>SDK: DirectorySync.get_user(id)
    SDK->>API: GET /directory_users/:id
    API-->>SDK: JSON response with role & roles
    SDK->>SDK: DirectoryUser.initialize(json)
    Note over SDK: Parses role (single) and<br/>roles (array) attributes
    SDK->>SDK: to_json() merges base_attributes<br/>with authorization_attributes
    SDK-->>App: DirectoryUser object with role & roles
Loading

Copy link

@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.

7 files reviewed, 1 comment

Edit Code Review Agent Settings | Greptile

@kendallstrautman kendallstrautman merged commit 987ceb5 into main Dec 2, 2025
2 checks passed
@kendallstrautman kendallstrautman deleted the feature/ent-4662-ruby branch December 2, 2025 21:38
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