Repository navigation
Require the client secret again when an SSO update moves its destination - #417
Merged
Merged
Conversation
The SSO plugin keeps a saved client secret when an update omits it, and sign-in sends that secret to the token endpoint. An update that changed the issuer without a new secret therefore sent the saved one to the new issuer. Updates that change the issuer, token endpoint or discovery endpoint now have to supply the client secret.
Deploying with
|
| Status | Name | Latest Commit | Updated (UTC) |
|---|---|---|---|
| ✅ Deployment successful! View logs |
widefleet-docs | 85c596c | Nov 26 2026, 09:47 AM |
The update check reads the saved provider before its DNS lookups, and the plugin merges the update after them. A save held up in between could merge a client secret that another save entered into a destination the check had accepted against the earlier state. SSO saves now hold an advisory lock per organization. A second save is rejected instead of waiting, because waiting saves would hold the pool connections the running save needs.
The connection form said to leave the secret blank to keep the saved one, also after the issuer was changed, and the save then failed. Once the issuer differs from the saved one, the secret field is required and its hint says to enter the secret again.
tnkuehne
added a commit
that referenced
this pull request
Nov 26, 2026
#417 runs the SSO saves of one organization one at a time and rejects a save that overlaps a running one with `Another SSO change is still in progress. Try again shortly.` `shared-sso-registration.integration.test.ts` still expected the overlapping save to finish after the first one, so it fails on `main`. ## Changes - `keeps the native provider and app claims together when settings saves overlap` becomes `rejects an overlapping settings save and keeps the running save's provider and app claims together`. The second save, started while the first waits between the native provider and the remaining settings write, is now expected to fail with the conflict message. The saved provider and the published app claims both carry the first save's values. - The first save keeps the OIDC claim type and the rejected one switches to Entra, so the final state is checked against an issuer that does not need to be tenant-specific. ## Testing - `pnpm check` - `tests/shared-sso-registration.integration.test.ts` <!-- greptile_comment --> <!-- greptile_summary --> <h2><ruby><rp>Confidence Score: 5/5 · The PR appears safe to merge.</rp></ruby><a href="https://app.greptile.com/api/retrigger?id=120634052&sig=723a23ae5b49c67f771a2774a5ff5dd4e6a38d40ca4df40fc7c0623bc99eb559"><picture><source media="(prefers-color-scheme: dark)" srcset="https://greptile-static-assets.s3.amazonaws.com/badges/RetriggerDark.svg?v=2"><source media="(prefers-color-scheme: light)" srcset="https://greptile-static-assets.s3.amazonaws.com/badges/Retrigger.svg?v=2"><img alt="Retrigger" src="https://greptile-static-assets.s3.amazonaws.com/badges/Retrigger.svg?v=2" align="right"></picture></a><a href="https://app.greptile.com/-/switch-tenant?tenant=mendra&next=%2Fwidefleet%2Fwidefleet%2Fpull%2F420&utm_source=greptile_review&utm_medium=github&utm_campaign=view_in_greptile"><picture><source media="(prefers-color-scheme: dark)" srcset="https://greptile-static-assets.s3.amazonaws.com/badges/ViewInGreptileDark.svg?v=2"><source media="(prefers-color-scheme: light)" srcset="https://greptile-static-assets.s3.amazonaws.com/badges/ViewInGreptile.svg?v=2"><img alt="View in Greptile" src="https://greptile-static-assets.s3.amazonaws.com/badges/ViewInGreptile.svg?v=2" align="right"></picture></a>Confidence Score: 5/5</h2> <!-- greptile-impact-verdict --> The PR appears safe to merge. <details open><summary><h3>Summary</h3></summary> Updates the overlapping SSO save test to match the existing rejection behavior. - The SSO overlap test now expects the second save to be rejected. </details> <!-- greptile_confidence_score:5 --> <sub>Reviews (1) · Last reviewed commit: ["Expect an overlapping SSO save to be rej..."](30311a5) · [Reviewed by Greptile](https://www.greptile.com/?utm_source=greptile_review&utm_medium=github&utm_campaign=review_public&utm_content=widefleet/widefleet)</sub> <!-- /greptile_comment -->
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
The SSO plugin keeps a saved client secret when an update omits it (
mergeOIDCConfig), and sign-in sends that secret to the token endpoint. An administrator could therefore change the issuer without entering a new secret, and the next sign-in sent the saved secret to the new issuer, although the secret is never shown to administrators. Better Auth refuses issuer changes once accounts are linked, so this applied to connections without linked accounts, for example during setup.Changes
plugin-authentication.ts). An update of a provider with a saved client secret must supply the secret again when it changes the issuer, the token endpoint or the discovery endpoint. Otherwise it fails withEnter the client secret again to change the issuer or token endpoint. The check runs for every/sso/update-providercall, including saves through the settings service.sso-settings.ts). The hook checks the saved provider before its DNS lookups, and the plugin merges the update after them. A save held up in between, for example by a slow DNS answer for a host the administrator controls, could otherwise merge a secret that another save entered meanwhile.saveSsoProvidernow holds a transaction-scoped advisory lock per organization around the whole save. A second save fails withAnother SSO change is still in progress. Try again shortly.instead of waiting, because waiting saves would hold the pool connections the running save needs. The settings service is the only caller of the SSO plugin endpoints, which are not reachable over HTTP.SsoConnectionFields.svelte). The form only exposes the issuer, not the endpoints. Once the issuer differs from the saved one, the client secret field is required and its hint readsThe issuer changed. Enter the client secret again.instead ofLeave blank to keep the saved secret.Testing
pnpm checktests/company-sso-plugin.integration.test.ts: a new case changes the issuer through the settings service, and the token and discovery endpoints through the plugin API, each without a secret. All are refused and the stored configuration stays unchanged. A mapping change without the secret and an issuer change with a new secret are saved. The new case fails without the fix.tests/company-sso-plugin.integration.test.ts: a save while the organization's SSO lock is held is rejected, and succeeds once the lock is released. The case fails without the lock.tests/settings.integration.test.ts: twelve concurrent saves, more than the pool's connections, all settle. At least one succeeds and the others are rejected with the conflict message.tests/organization-settings.integration.test.ts,tests/self-hosted-sso.integration.test.tstests/e2e/onboarding.spec.ts: editing a saved connection, a changed issuer makes the secret required with the new hint, and restoring the issuer brings back the old hint. The steps fail without the form change.

Confidence Score: 5/5
The PR appears safe to merge; no new actionable issues were found.Summary
The PR requires administrators to re-enter the client secret when an SSO update changes its destination.
Both earlier, unnumbered findings are addressed: saves share the organization lock, and the mapping test now saves and checks
given_name.Reviews (3) · Last reviewed commit: "Ask for the client secret again when the..." · Reviewed by Greptile