Skip to content

Implement user management#199

Open
richclement wants to merge 7 commits intoworkos:mainfrom
richclement:implement-user-management
Open

Implement user management#199
richclement wants to merge 7 commits intoworkos:mainfrom
richclement:implement-user-management

Conversation

@richclement
Copy link

Description

Implement User Management for the dotnet SDK. This is a direct implementation of the WorkOS APIs per the public documentation following the patterns used elsewhere in this SDK.

Includes support for the following User Management capabilities:

There are additional capabilities that can and should be implemented in follow up PRs. These are all the capabilities I implemented internally to support migrating an application to WorkOS.

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.

…t, list, create, update, and delete actions for user management. Tests implemented for methods in UserManagementService
…. Created unit tests for new methods in service.
…ment in the UserManagementService. Added unit test for each new method.
…s to strongly type the full response object, and associated unit test.
@richclement richclement requested a review from a team as a code owner December 8, 2025 03:53
@greptile-apps
Copy link

greptile-apps bot commented Dec 8, 2025

Greptile Overview

Greptile Summary

This PR implements comprehensive User Management functionality for the WorkOS .NET SDK, following the established patterns used throughout the codebase.

  • Adds UserManagementService with methods for user CRUD, organization membership management, password reset flows, authentication (code and refresh token), JWKS URL retrieval, and logout URL generation
  • Introduces entity classes (User, AuthenticationResponse, OrganizationMembership, PasswordReset, OAuthTokens, Impersonator, OrganizationMembershipRole) that map to WorkOS API responses
  • Adds enums for AuthenticationMethod and UserPasswordHashType with proper JSON serialization
  • Implements options classes for all API operations following the existing BaseOptions/ListOptions patterns
  • Includes comprehensive unit tests covering all new service methods with mocked HTTP responses

The implementation correctly follows the SDK's existing architectural patterns, including proper use of WorkOSRequest, async/await patterns, cancellation tokens, and JSON serialization attributes.

Confidence Score: 5/5

  • This PR is safe to merge - it adds new functionality without modifying existing code, follows established patterns, and includes comprehensive tests.
  • Score reflects: (1) Clean implementation following existing SDK patterns, (2) No modifications to existing code that could cause regressions, (3) Comprehensive test coverage for all new methods, (4) No security issues identified - sensitive fields are properly handled by the SDK infrastructure, (5) Proper use of async patterns, cancellation tokens, and JSON serialization.
  • No files require special attention.

Important Files Changed

File Analysis

Filename Score Overview
src/WorkOS.net/Services/UserManagement/UserManagementService.cs 5/5 Implements UserManagementService with methods for user CRUD, password reset, organization membership, authentication, JWKS URL, and logout URL. Well-structured and follows existing patterns in the codebase.
src/WorkOS.net/Services/UserManagement/Entities/AuthenticationResponse.cs 5/5 Entity class for authentication response containing user, tokens, auth method, impersonator, and OAuth tokens. Follows existing entity patterns.
src/WorkOS.net/Services/UserManagement/Entities/User.cs 5/5 Entity for user with standard fields like email, name, verification status, profile picture, external ID, metadata, locale, and timestamps.
src/WorkOS.net/Services/UserManagement/_interfaces/AuthenticateWithCodeOptions.cs 5/5 Options for authorization code authentication including code, client credentials, PKCE verifier, and optional parameters.
src/WorkOS.net/Services/UserManagement/_interfaces/AuthenticateWithRefreshTokenOptions.cs 5/5 Options for refresh token authentication including token, client credentials, and optional organization ID.
test/WorkOSTests/Services/UserManagement/UserManagementServiceTest.cs 5/5 Comprehensive test suite covering all UserManagementService methods with mocked HTTP responses and assertions.

Sequence Diagram

sequenceDiagram
    participant Client as Client App
    participant SDK as UserManagementService
    participant API as WorkOS API

    rect rgb(230, 245, 255)
        Note over Client, API: Authentication with Code Flow
        Client->>SDK: AuthenticateWithCode(options)
        SDK->>API: POST /user_management/authenticate
        API-->>SDK: AuthenticationResponse
        SDK-->>Client: User + Access/Refresh Tokens
    end

    rect rgb(255, 245, 230)
        Note over Client, API: Token Refresh Flow
        Client->>SDK: AuthenticateWithRefreshToken(options)
        SDK->>API: POST /user_management/authenticate
        API-->>SDK: AuthenticationResponse
        SDK-->>Client: User + New Tokens
    end

    rect rgb(245, 255, 230)
        Note over Client, API: User Management Operations
        Client->>SDK: CreateUser/GetUser/UpdateUser/DeleteUser
        SDK->>API: POST/GET/PUT/DELETE /user_management/users
        API-->>SDK: User Response
        SDK-->>Client: User Entity
    end

    rect rgb(255, 230, 245)
        Note over Client, API: Organization Membership
        Client->>SDK: Create/Get/Update/Delete OrganizationMembership
        SDK->>API: POST/GET/PUT/DELETE /user_management/organization_memberships
        API-->>SDK: OrganizationMembership Response
        SDK-->>Client: OrganizationMembership Entity
    end
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.

21 files reviewed, no comments

Edit Code Review Agent Settings | Greptile

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.

1 participant