Repository navigation
Conversation
Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
…ery OAuth error Retry the token exchange on a network error or 5xx, up to three attempts, requesting a fresh GitHub OIDC token each time because WorkOS accepts each one once. Never retry a 4xx. Re-exchange and re-send an API call once when the API answers 401. Handle unauthorized_client, and make each OAuth error hint name the setting to change.
[Medium impact] The reviewed changes appear safe to merge; no new actionable issues were found. SummaryAdds bounded WIF retries and clearer errors while preserving stored-key access when no token endpoint is configured.
Both earlier findings are fixed: body-read failures enter the retry path, and rejected responses are cancelled before another exchange. nicknisi explicitly defers command-level scope filtering while the server's supported scopes are being decided. Reviews (5) · Last reviewed commit: "fix(wif): match the server in error hint..." · Reviewed by Greptile |
…se before re-exchanging A connection that dropped while the token response body was read ended the exchange as 'the response was not JSON' instead of being retried like any other network failure. A 401 response was cancelled only after the re-exchange, so a failed re-exchange left it open.
The exchange now issues one-hour tokens. The comment on the fallback lifetime called five minutes the documented minimum. The fallback stays at 300 seconds, used only when the server omits expires_in, so the CLI exchanges again early.
… has no endpoint, and time out stalled requests - Hints no longer name an enabled switch or a per-trust audience, which the server does not have, and invalid_client mentions expired trust rules. - A job with a stored profile key and no WORKOS_WIF_TOKEN_URL keeps using the stored key. - The GitHub token request and each exchange attempt time out after 15 s. - A 401 or 403 with a WIF token says the token was refused instead of calling the API key invalid. - verify-login no longer exchanges a token it then refuses.
This branch has not been deployed
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.
Stacked on #268. Review this after it; the diff here is only what was added on top.
What changes
unauthorized_client: check that the client has an active trust, that workload identity federation is on for the team, and that the client targets a non-production environment.unauthorized_client, andWORKOS_ENVIRONMENT_IDbeing optional (it must match the client's bound environment when set).invalid_clientsays that an application whose trust rules have all expired gets a "missing client secret" answer, and that no secret is needed.WORKOS_WIF_TOKEN_URLkeeps using the stored key. Before,WORKOS_CLIENT_IDplusid-token: write(both often set for other reasons) made WIF the credential and the job exitedwif_token_url_missing.workos auth login.verify-loginno longer exchanges a token it then refuses.The branch also merges
main(release 0.24.0), so the release files show in the diff.The server now issues one-hour tokens. The CLI reads
expires_in, so only a comment changed. Its fallback when a response has noexpires_instays 300 seconds.Checked
workos apilisted organizations and created one using only the job's OIDC token. It passed again with this branch ataeaa5adagainst a later build of the server stack (b2c42179c, from before the data model rework): https://github.com/nicknisi/wif-test/actions/runs/43374371447. After the server's data model rework it passed again with this branch's head (951f005) against the server stack's current tip: https://github.com/nicknisi/wif-test/actions/runs/43974834175.b876257) have unit tests only: the stored-key fallback, both timeouts with a request that never answers, the new hint wording, and the refused-token message for the handler and forworkos api. The whole suite (3,586 tests) passes. The branch atb876257then passed a real job against the server stack's current build: https://github.com/nicknisi/wif-test/actions/runs/44273623233. That job takes the normal path, so the fallback, the timeouts and the refused-token message were not exercised in it.Not checked
bun run build.api-key,vault,audit-logand the writes inseed,setup-organdonboard-userstill exchange a token and are then refused by the API, now with a message that says the WIF token was refused. The README says which scopes the server offers today. The list of scopes is still being decided on the server, so the CLI does not hardcode it.