Skip to content

fix: Caching wrong auth token when fetching destination from provider account#6007

Draft
ZhongpinWang wants to merge 10 commits intomainfrom
fix-destination-cache-with-provider
Draft

fix: Caching wrong auth token when fetching destination from provider account#6007
ZhongpinWang wants to merge 10 commits intomainfrom
fix-destination-cache-with-provider

Conversation

@ZhongpinWang
Copy link
Copy Markdown
Contributor

Closes SAP/cloud-sdk-backlog#1278.

@ZhongpinWang ZhongpinWang requested a review from deekshas8 August 28, 2025 07:40
@ZhongpinWang ZhongpinWang requested review from marikaner and removed request for deekshas8 March 13, 2026 11:08
Copy link
Copy Markdown
Contributor

@marikaner marikaner left a comment

Choose a reason for hiding this comment

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

I don't fully understand the comments, maybe let's talk about them.

// -> Auth token can be cached in destination cache as subscriber is not used.
// If origin is subscriber, subscriber jwt + refresh token is used.
// -> Auth token can be cached in destination cache as destination is tenant-isolated.
destination = await this.fetchDestinationWithRefreshTokenFlow(
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.

Suggested change
destination = await this.fetchDestinationWithRefreshTokenFlow(
return this.fetchDestinationWithRefreshTokenFlow(

!this.usesSystemUser(destination))
) {
// VERY BAD...
// If origin is provider, next time subscriber jwt might change.
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.

[q] I don't understand this sentence.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

I think I meant

If destination is fetched from the provider subaccount (origin = 'provider'), then we use provider tenant id to build the cache key.

But these auth flows need specific user jwt, which comes from certain subscriber tenant, and the auth token will be cached together with the destination using provider tenant id + user id only (no subscriber tenant id). This is a problem for multi-tenant app as next get destination may be for a user from a different subscriber.

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