Skip to content

feat(sdk): complete management SDK methods + fix mgmt user logout - #123

Merged
dorsha merged 7 commits into
mainfrom
feat/mgmt-sdk-go-parity
Jul 9, 2026
Merged

feat(sdk): complete management SDK methods + fix mgmt user logout#123
dorsha merged 7 commits into
mainfrom
feat/mgmt-sdk-go-parity

Conversation

@dorsha

@dorsha dorsha commented Jul 8, 2026

Copy link
Copy Markdown
Member

Relates to descope/etc#16685.

TL;DR

Completes the management SDK surface (follow-up to #122) by filling the method gaps in all 11 existing management modules, and fixes the real bugs surfaced by descope/etc#16685.

Bug findings from descope/etc#16685

  1. Missing mgmt user logout — REAL, fixed. The SDK only had auth-side logout($refreshToken) / logoutAll($refreshToken), which can't do a service-to-service revoke by userId/loginId. Added User::logoutUser() and User::logoutUserByUserId() (POST /v1/mgmt/user/logout).
  2. User::update() sends displayName not name — NOT a bug. Verified empirically against the generated backend proto: protojson accepts both displayName (proto field name) and name (its json_name) for the same field. Sending displayName does not clear the name. Left unchanged.

Bonus bug fixed

OutboundApps fetchUserToken / deleteUserTokens / deleteTokenById used dead paths (/v1/mgmt/outboundapp/...). The backend serves /v1/mgmt/outbound/app/.... Corrected.

What's added (~75 methods, request bodies/paths matched to the Descope management API)

  • Tenant: createWithId, getSettings, configureSettings, generateSSOConfigurationLink, revokeSSOConfigurationLink, updateDefaultRoles
  • SSOApplication: createWSFedApplication, updateWSFedApplication, getApplicationSecret, rotateApplicationSecret
  • User: logoutUser, logoutUserByUserId, createBatch, patch, patchBatch, deleteBatch, import, loadUsers, searchAllTestUsers, updateRecoveryEmail, updateRecoveryPhone, getCustomAttributes, createCustomAttributes, deleteCustomAttributes, updateUserNames, addTenantRoles, removePasskey, listPasskeys, removeTotpSeed, getProviderTokenWithOptions, generateEmbeddedLinkSignUp, listTrustedDevices, removeTrustedDevices
  • AccessKey: activateBatch, deactivateBatch, deleteBatch, rotate
  • SSO: loadAllSettings (v2), configureSSORedirectURL, newSettings, getSettings, configureSettings, configureMetadata, configureMapping, recalculateSSOMappings
  • JWT: impersonateStepup, stopImpersonation, signIn, signUp, signUpOrIn, anonymous
  • Permission / Role: createBatch, updateWithId, updateBatch, deleteWithId, deleteBatch
  • Flow: runManagementFlow, runManagementFlowAsync, getManagementFlowAsyncResult, deleteFlows
  • Audit: searchAll, createAuditWebhook (both on v2 endpoints)
  • OutboundApps: create/update/delete/load/loadAllApplications, fetchLatest*Token, fetchTenantToken, listAppsWithUserToken, upload*ApiKey, upload*Token, batchUpload*Tokens

Infra

  • API::doPatch() for the user patch endpoints.
  • ~65 new MgmtV1 path constants, verified against the backend proto HTTP rules. The audit-webhook and SSO load-all-settings endpoints correctly use the v2 prefix.
  • Extended the management method-existence test to assert every new method is wired per module.

Verification

  • php -l clean on all changed files.
  • Full phpunit suite green: 80 tests, 389 assertions.
  • Every new method's HTTP verb, path constant, and request-body keys were reviewed against the backend proto/route table; the issues found (v1/v2 path prefixes, a createBatch that was wrongly forcing invite=true, always-send verified on recovery updates, a nested-user duplicate field in mgmt signup) were fixed on this branch.

Not included (out of scope for this PR)

  • Management modules not yet present in the PHP SDK (Authz/FGA, Project, List, Engine, Group, ManagementKey, Descoper, JWTTemplate, ScopeClaimMapping, Analytics, Password-settings) and the auth-side surface (EnchantedLink/TOTP/NOTP/WebAuthn/session management). Can follow in a subsequent PR.

🤖 Generated with Claude Code

… logout

Adds ~75 missing management methods across the 11 existing modules to reach
parity with the Go SDK, and fixes real bugs found along the way.

Bug fixes:
- User: add mgmt logoutUser()/logoutUserByUserId() (service-to-service
  revoke-by-loginId/userId, no refresh token) — the auth-side logout() only
  revokes by refresh token and could not serve this flow. Closes descope/etc#16685.
- OutboundApps: existing fetchUserToken/deleteUserTokens/deleteTokenById used
  dead paths (/v1/mgmt/outboundapp/...); corrected to /v1/mgmt/outbound/app/...
  to match the backend/go-sdk routes.

Note: the reported User::update() "displayName vs name" bug is NOT a bug —
the backend accepts both keys (protojson recognizes the proto field name and
the json_name), and go-sdk itself sends displayName. Left as-is.

New methods per module (bodies/paths matched to go-sdk verbatim):
- Tenant: createWithId, getSettings, configureSettings,
  generate/revokeSSOConfigurationLink, updateDefaultRoles
- SSOApplication: create/updateWSFedApplication, get/rotateApplicationSecret
- User: createBatch, patch, patchBatch, deleteBatch, import, loadUsers,
  searchAllTestUsers, updateRecoveryEmail/Phone, get/create/deleteCustomAttributes,
  updateUserNames, addTenantRoles, removePasskey, listPasskeys, removeTotpSeed,
  getProviderTokenWithOptions, generateEmbeddedLinkSignUp,
  list/removeTrustedDevices
- AccessKey: activateBatch, deactivateBatch, deleteBatch, rotate
- SSO: loadAllSettings, configureSSORedirectURL, newSettings, getSettings,
  configureSettings, configureMetadata, configureMapping, recalculateSSOMappings
- JWT: impersonateStepup, stopImpersonation, signIn, signUp, signUpOrIn, anonymous
- Permission/Role: createBatch, updateWithId, updateBatch, deleteWithId, deleteBatch
- Flow: runManagementFlow, runManagementFlowAsync, getManagementFlowAsyncResult,
  deleteFlows
- Audit: searchAll, createAuditWebhook (both on the v2 endpoints)
- OutboundApps: create/update/delete/load/loadAllApplications, token
  fetch/upload/batch-upload variants, listAppsWithUserToken

Also: add API::doPatch() (user patch endpoints), ~65 MgmtV1 path constants, and
extend ManagementParityTest to assert every new method exists. All 80 tests pass.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@shuni-bot

shuni-bot Bot commented Jul 8, 2026

Copy link
Copy Markdown
Contributor

🐕 Review complete — View session on Shuni Portal 🐾

@shuni-bot

shuni-bot Bot commented Jul 8, 2026

Copy link
Copy Markdown
Contributor

🐕 Suggested Reviewers

The review strategy emphasizes selecting contributors with diverse file coverage to ensure both broad management SDK expertise and specific focus on user management features, facilitating thorough review of the SDK parity extensions and bug fixes.

Reviewer Reason
gaokevin1 Gaokevin1 should review because they have extensive contributions across multiple management files, including src/SDK/Management/Audit.php and src/SDK/Management/MgmtV1.php, ensuring broad expertise in management SDK updates.
omercnet Omercnet is suitable for review given their contributions to src/SDK/Management/User.php and src/SDK/API.php, which are directly involved in user management and API interactions relevant to the new logout functionality.
aviadl Aviadl's focus on src/SDK/Management/MgmtV1.php makes them a good reviewer for the core management module changes and ensuring consistency in SDK management features.
talberry Talberry, who contributed to src/SDK/Management/User.php, should review the updates related to user logout to ensure correctness and integration within the existing user management code.

Suggested by Shuni based on git history and PR context. Names are not @-mentioned to avoid notifying anyone — request a review from whoever fits best.

@shuni-bot shuni-bot Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🐕 Shuni's Review

Completes the management-SDK go-parity effort — ~75 new methods across 11 modules, ~65 path constants, and a new doPatch. I fetched the go-sdk route table and diffed the new paths/bodies against it; the vast majority line up (outbound app create-flat / update-app-wrapped asymmetry is intentional and matches go-sdk).

Sniffed out 2 issues:

  • 1 🟠 HIGH: test-user search uses the wrong API version (v1, should be v2)
  • 1 🟡 MEDIUM: configureSettings lets caller settings override the target tenant

See inline comments. Otherwise good bones! Woof!

Comment thread src/SDK/Management/MgmtV1.php Outdated
Comment thread src/SDK/Management/Tenant.php Outdated
Add usage examples for the ~75 new management methods across all 11 module
sections (User, Tenant, Role, Permission, AccessKey, SSOApplication, SSO
Settings, JWT, Flow, Outbound Apps) plus a new Audit Management Functions
section. Signatures match the implementation exactly.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@dorsha

dorsha commented Jul 8, 2026

Copy link
Copy Markdown
Member Author

Update: README docs for all ~75 new methods added in e4a173a (per-module usage examples + new Audit section). The "README docs (follow-up)" item in the description is now done and included in this PR.

…fig link

- TEST_USER_SEARCH_ALL_PATH: v1 → v2 (/v2/mgmt/user/search/test; backend only
  serves v2, v1 would 404).
- TENANT_GENERATE_SSO_CONFIGURATION_LINK_PATH: v1 → v2 to match go-sdk
  (backend serves both; v2 is the go-sdk route).
- Tenant::configureSettings: merge explicit tenantId last so a stray 'tenantId'
  key in the caller's $settings array cannot redirect the call to another tenant.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@dorsha

dorsha commented Jul 8, 2026

Copy link
Copy Markdown
Member Author

@shuni please re-review

@shuni-bot

shuni-bot Bot commented Jul 8, 2026

Copy link
Copy Markdown
Contributor

🐕 Review complete — View session on Shuni Portal 🐾

@dorsha
dorsha requested review from avigloz, gaokevin1 and omercnet July 8, 2026 19:35
@dorsha
dorsha enabled auto-merge (squash) July 8, 2026 19:36

@shuni-bot shuni-bot Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🐕 Shuni's Review

Re-sniffed the management-SDK go-parity PR. Both issues from the prior pass are fixed in 0160885 and the threads are resolved:

  • 🟠 test-user search path v1 → v2
  • 🟡 configureSettings now merges the explicit tenantId last ✅

I also re-verified the author's bonus fix (tenant/adminlinks/sso/generate → v2, revoke left on v1) against the go-sdk route table — the version split is exactly right.

No new issues found — good bones! Woof! 🦴

Comment thread src/SDK/Management/User.php
@omercnet

omercnet commented Jul 9, 2026

Copy link
Copy Markdown
Member

@shuni-dev review like linus

@shuni-bot-dev

shuni-bot-dev Bot commented Jul 9, 2026

Copy link
Copy Markdown

🐕 Review complete — View session on Shuni Portal 🐾

@shuni-bot-dev shuni-bot-dev Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🐕 Shuni's Review

Fills the management-SDK parity gaps across 11 modules and fixes the mgmt user logout + outbound-app path bugs. Solid, careful work — request bodies and v1/v2 prefixes check out against go-sdk.

Sniffed out 3 issues:

  • 1 🟡 MEDIUM: Permission batch methods drop the API response (Role's don't)
  • 2 🟢 LOW: dead duplicate path constant, duplicate deleteFlows/delete

Nothing blocking — good bones! Woof!

Comment thread src/SDK/Management/Permission.php
Comment thread src/SDK/Management/MgmtV1.php Outdated
Comment thread src/SDK/Management/Flow.php
dorsha and others added 3 commits July 9, 2026 10:35
…s alias

- Remove unused $OUTBOUND_APP_FETCH_USER_TOKEN_PATH (dead duplicate of
  $OUTBOUND_APP_USER_TOKEN_PATH; fetchUserToken already uses the latter).
- deleteFlows() now delegates to delete() instead of duplicating the body,
  keeping the go-sdk-parity method name without a second implementation.

Permission::createBatch/updateBatch intentionally return void — go-sdk's
Permission.CreateBatch/UpdateBatch return error only (unlike Role's batch which
returns the roles), so void matches parity.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Rename all "go-sdk" references in code comments, PHPDoc, and README to "Go SDK".

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Reword the added code comments, PHPDoc, and README so they describe the
methods' own request shapes and behavior directly, instead of referencing
another SDK.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@dorsha dorsha changed the title feat(sdk): complete management SDK go-parity + fix mgmt user logout feat(sdk): complete management SDK methods + fix mgmt user logout Jul 9, 2026
@dorsha
dorsha merged commit 6e96618 into main Jul 9, 2026
14 checks passed
@dorsha
dorsha deleted the feat/mgmt-sdk-go-parity branch July 9, 2026 07:59
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants