Skip to content

Add custom_attributes field to OrganizationMembership#318

Merged
ajworkos merged 2 commits intomainfrom
feature/add-idp-attributes-to-org-membership
Feb 3, 2026
Merged

Add custom_attributes field to OrganizationMembership#318
ajworkos merged 2 commits intomainfrom
feature/add-idp-attributes-to-org-membership

Conversation

@ajworkos
Copy link
Contributor

@ajworkos ajworkos commented Feb 1, 2026

Summary

Adds custom_attributes field to OrganizationMembership model to expose custom attributes from identity providers.

Changes

  • Added custom_attributes field to OrganizationMembership type/model
  • Field type: Record/Map/Dictionary of string keys to any values
  • Always present, defaults to empty object {}
  • Updated fixtures and tests

API Field Details

The field will be present in:

  • REST API responses
  • Webhook events
  • Events API responses

JSON field name: custom_attributes (snake_case)

- Add @Property array<string, mixed> $idpAttributes to PHPDoc
- Add "idpAttributes" to RESOURCE_ATTRIBUTES array
- Add "idp_attributes" => "idpAttributes" to RESPONSE_TO_RESOURCE_KEY mapping
- Update test fixtures to include idp_attributes field
- All 13 tests pass

This change adds support for IDP custom attributes on organization
memberships, which are sourced from the identity provider and stored
as customAttributes in the API.

Related to workos/workos PR #50470

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
@ajworkos ajworkos requested a review from a team as a code owner February 1, 2026 16:18
@greptile-apps
Copy link
Contributor

greptile-apps bot commented Feb 1, 2026

Greptile Overview

Greptile Summary

This PR adds the idpAttributes field to the OrganizationMembership resource, enabling access to custom attributes from identity providers.

Key Changes:

  • Added @property array<string, mixed> $idpAttributes PHPDoc annotation
  • Added "idpAttributes" to RESOURCE_ATTRIBUTES array
  • Added "idp_attributes" => "idpAttributes" mapping in RESPONSE_TO_RESOURCE_KEY
  • Updated test fixtures with empty idp_attributes arrays

Implementation:
The field follows the existing SDK pattern: API responses use snake_case (idp_attributes), which gets automatically mapped to camelCase (idpAttributes) for PHP property access. The implementation is consistent with other fields like userId, organizationId, createdAt, and updatedAt.

Confidence Score: 5/5

  • This PR is safe to merge with minimal risk
  • The implementation follows established patterns in the codebase, properly handles the field mapping, includes appropriate type documentation, and updates test fixtures. No security concerns identified - the field doesn't contain sensitive authentication data and follows existing patterns for similar fields.
  • No files require special attention

Important Files Changed

Filename Overview
lib/Resource/OrganizationMembership.php Added idpAttributes field with proper PHPDoc, RESOURCE_ATTRIBUTES entry, and snake_case to camelCase mapping
tests/WorkOS/UserManagementTest.php Updated test fixtures to include empty idp_attributes array in mock responses

Sequence Diagram

sequenceDiagram
    participant API as WorkOS API
    participant Client as PHP SDK Client
    participant Resource as OrganizationMembership Resource
    participant App as Application Code

    API->>Client: Response with idp_attributes field
    Note over API,Client: JSON: {"idp_attributes": {"department": "eng"}}
    
    Client->>Resource: constructFromResponse($response)
    Note over Resource: Maps "idp_attributes" → "idpAttributes"
    Resource->>Resource: Store in $values["idpAttributes"]
    
    App->>Resource: Access $membership->idpAttributes
    Resource->>App: Returns array<string, mixed>
    Note over App: Contains IDP custom attributes
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.

2 files reviewed, no comments

Edit Code Review Agent Settings | Greptile

@ajworkos ajworkos changed the title Add idpAttributes field to OrganizationMembership Add custom_attributes field to OrganizationMembership Feb 2, 2026
@ajworkos ajworkos merged commit aca8804 into main Feb 3, 2026
7 checks passed
@ajworkos ajworkos deleted the feature/add-idp-attributes-to-org-membership branch February 3, 2026 13:06
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.

2 participants