Repository navigation
fix(auth): preserve token refreshes across caller cancellation #1172
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
coderdan
wants to merge
7
commits into
main
Choose a base branch
from
fix/1170-cancel-safe-auth-refresh
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
aa88579
fix(stack-auth)!: finish token refreshes after caller cancellation
coderdan 9a0707a
test(auth): run native guest exchange under Tokio
coderdan 75e359e
test(auth): cover token expiry boundaries in refresh
coderdan 530ea59
fix(stack-auth): give the initiating caller the token its refresh ins…
coderdan 6503f06
test(stack-auth): run the cancellation soak on a multi-thread runtime
coderdan f5cd428
docs(golang): say why the auth guest's block_on is wasm32-only
coderdan 1b270d7
ci(release-plz): run the auth refresh soak only on an armed crates line
coderdan File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,5 @@ | ||
| --- | ||
| '@cipherstash/auth': patch | ||
| --- | ||
|
|
||
| Keep native token refreshes running when their caller is cancelled, so rotated device-session credentials are saved and subsequent requests can still authenticate. Close a refresh-waiter notification race, and give the caller that started a refresh the new token rather than the expiring one it replaced. |
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,37 @@ | ||
| name: Auth refresh cancellation soak | ||
|
|
||
| on: | ||
| workflow_call: | ||
| inputs: | ||
| long: | ||
| type: boolean | ||
| default: false | ||
|
|
||
| permissions: | ||
| contents: read | ||
|
|
||
| jobs: | ||
| soak: | ||
| runs-on: blacksmith-16vcpu-ubuntu-2204 | ||
| timeout-minutes: 30 | ||
| env: | ||
| MISE_ENV: test | ||
| NEXTEST_PROFILE: ci | ||
| steps: | ||
| - uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6 | ||
| with: | ||
| persist-credentials: false | ||
| - uses: jdx/mise-action@1648a7812b9aeae629881980618f079932869151 # v4 | ||
| with: | ||
| version: 2026.4.0 | ||
| install: true | ||
| working_directory: . | ||
| cache: true | ||
| cache_key_prefix: mise-v1-ubuntu-2204 | ||
| - uses: Swatinem/rust-cache@e18b497796c12c097a38f9edb9d0641fb99eee32 # v2 | ||
| - name: Short seeded soak | ||
| if: ${{ !inputs.long }} | ||
| run: cargo nextest run --locked -p stack-auth --all-features -E 'test(cancellation_soak_short)' --success-output final | ||
| - name: Long seeded soak | ||
| if: inputs.long | ||
| run: mise run test:soak:stack-auth |
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
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,50 @@ | ||
| name: Tests (auth refresh cancellation) | ||
|
|
||
| # The short run covers every PR, including Version Packages. The longer run | ||
| # also covers release PRs and changes to the engine, refreshers or toolchain. | ||
| on: | ||
| pull_request: {} | ||
| workflow_dispatch: {} | ||
|
|
||
| permissions: | ||
| contents: read | ||
|
|
||
| concurrency: | ||
| group: ${{ github.workflow }}-${{ github.ref }} | ||
| cancel-in-progress: true | ||
|
|
||
| jobs: | ||
| short: | ||
| uses: ./.github/workflows/_test-auth-refresh-soak.yml | ||
|
|
||
| changes: | ||
| runs-on: ubuntu-latest | ||
| timeout-minutes: 5 | ||
| permissions: | ||
| contents: read | ||
| pull-requests: read | ||
| outputs: | ||
| refresh: ${{ steps.paths.outputs.refresh }} | ||
| steps: | ||
| - uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6 | ||
| with: | ||
| persist-credentials: false | ||
| - uses: dorny/paths-filter@0e4a8c6effa4802afeda77dc8d303f8176d7dfad # v3 | ||
| id: paths | ||
| with: | ||
| filters: | | ||
| refresh: | ||
| - 'packages/stack-auth/**' | ||
| - 'Cargo.toml' | ||
| - 'Cargo.lock' | ||
| - 'mise*.toml' | ||
| - '.config/nextest.toml' | ||
| - '.github/workflows/*auth-refresh*.yml' | ||
| - '.github/workflows/release-plz.yml' | ||
|
|
||
| long: | ||
| needs: changes | ||
| if: github.event_name == 'workflow_dispatch' || github.head_ref == 'changeset-release/main' || needs.changes.outputs.refresh == 'true' | ||
| uses: ./.github/workflows/_test-auth-refresh-soak.yml | ||
| with: | ||
| long: true |
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
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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
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
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
Oops, something went wrong.
Oops, something went wrong.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Follow-up (non-blocking). This job runs on every push that matches the path filter. It runs before
release-crateschecks whether a crate version is unpublished. A soak that fails or times out also stops thestack-kms,stack-encryptandstack-encrypt-derivereleases, which do not depend on the refresh engine for publication. Gate the job onneeds.crates-armed.outputs.armed == 'true'. Better, move the unpublished-version preflight into its own job, and run the soak only whenstack-authhas an unpublished version.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Partly done in b8df909.
auth-refresh-soaknow needscrates-armedand has the samearmed == 'true'condition asrelease-crates.eql-pipeline-armed.test.mjslists it as a gated job. I did not move the preflight into its own job. Thenrelease-crateswould need!cancelled()or similar to run past a skipped soak, andauth-refresh-soak-ci.test.mjsforbids that on the publish job. So a failed soak still holds stack-kms and stack-encrypt. The commit message says so.