Skip to content

fix: Generate a new refresh token if an instance domain was changed#4657

Merged
shepilov merged 1 commit intomasterfrom
fix/update_refresh_token_for_changed_domain
Feb 4, 2026
Merged

fix: Generate a new refresh token if an instance domain was changed#4657
shepilov merged 1 commit intomasterfrom
fix/update_refresh_token_for_changed_domain

Conversation

@shepilov
Copy link
Contributor

@shepilov shepilov commented Feb 4, 2026

After migrating an instance from one domain to another (e.g., alice.mycozy.cloud → alice.twake.app), sharings between migrated and non-migrated instances can break.

When the migration is done by:

  1. Changing the instance's Domain attribute
  2. Setting OldDomain to the previous domain value

The OAuth tokens behave as follows:

  • Refresh token: Still has iss: "alice.mycozy.cloud" (old domain)
  • Access token: After refresh, has iss: "alice.twake.app" (new domain)

However, after a successful refresh:

  1. A new access token is generated with the current domain as issuer ✅
  2. The refresh token is NOT regenerated ❌

This means the client continues using the old refresh token. While this works as long as OldDomain is set, it's fragile, and the refresh token should be updated to use the current domain.

@shepilov shepilov requested a review from a team as a code owner February 4, 2026 09:47
@shepilov shepilov merged commit 2a10446 into master Feb 4, 2026
4 checks passed
@shepilov shepilov deleted the fix/update_refresh_token_for_changed_domain branch February 4, 2026 11:07
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.

2 participants