Skip to content
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

Fix/use same cookie for all apps #277

Merged
merged 3 commits into from
Jun 17, 2022
Merged

Conversation

Ldoppea
Copy link
Member

@Ldoppea Ldoppea commented Jun 14, 2022

When calling /apps/:slug/open, cozy-stack generates a new cookie that
should be used for the displayed cozy-app

Each call returns a newly generated cookie that is associated with the
returned token

This may be problematic as all those cookies share the same domain and
so we cannot discriminate them when displaying cozy-home or any other
cozy-app and when we have multiple cookies available

The easiest way to handle this is to force having the same cookie for
all cozy-app and so to have all cozy-apps' tokens generated from this
cookie

By passing any existing cookie to /apps/:slug/open, we ensure the
cozy-stack will use it to generate the token

Related PR: cozy/cozy-stack#3429

@Ldoppea Ldoppea force-pushed the fix/use_same_cookie_for_all_apps branch from 2bb2fc0 to 60824ba Compare June 17, 2022 08:54
Ldoppea added 3 commits June 17, 2022 11:03
Instead of trying to sync the used cookie with the displayed WebView we
prefer to use the same cookie for all WebViews. This will be
implemented in next commit

This reverts commit 2b92e64
When calling `/apps/:slug/open`, cozy-stack generates a new cookie that
should be used for the displayed cozy-app

Each call returns a newly generated cookie that is associated with the
returned token

This may be problematic as all those cookies share the same domain and
so we cannot discriminate them when displaying cozy-home or any other
cozy-app and when we have multiple cookies available

The easiest way to handle this is to force having the same cookie for
all cozy-app and so to have all cozy-apps' tokens generated from this
cookie

By passing any existing cookie to `/apps/:slug/open`, we ensure the
cozy-stack will use it to generate the token

Related PR: cozy/cozy-stack#3429
When executed in Jest, react-native-cookies already return a mock so we
don't need to handle it by ourselves
@Ldoppea Ldoppea force-pushed the fix/use_same_cookie_for_all_apps branch from 60824ba to fa43753 Compare June 17, 2022 09:03
@Ldoppea Ldoppea merged commit b421ead into master Jun 17, 2022
@Ldoppea Ldoppea deleted the fix/use_same_cookie_for_all_apps branch June 17, 2022 09:49
Ldoppea added a commit that referenced this pull request Sep 22, 2022
In some scenario (mainly in production) we observed that cookie was
duplicated in the HTTP headers. Also both cookies were separated by a
comma instead of a semicolon

This form is not supported by cozy-stack and the result is that the
cozy-stack consider the request is not cookie-authenticated

So when calling `/apps/:slug/open`, a new generated cookie would be
returned instead of the provided one as expected in #277

To fix this we want to specify `credentials:omit` into the fetch
options, this would prevent react-native to inject a copy of the same
cookie

More info: facebook/react-native#23185 (comment)
Ldoppea added a commit that referenced this pull request Sep 30, 2022
In some scenario (mainly in production) we observed that cookie was
duplicated in the HTTP headers. Also both cookies were separated by a
comma instead of a semicolon

This form is not supported by cozy-stack and the result is that the
cozy-stack consider the request is not cookie-authenticated

So when calling `/apps/:slug/open`, a new generated cookie would be
returned instead of the provided one as expected in #277

To fix this we want to specify `credentials:omit` into the fetch
options, this would prevent react-native to inject a copy of the same
cookie

More info: facebook/react-native#23185 (comment)
Ldoppea added a commit that referenced this pull request Sep 30, 2022
In some scenario (mainly in production) we observed that cookie was
duplicated in the HTTP headers. Also both cookies were separated by a
comma instead of a semicolon

This form is not supported by cozy-stack and the result is that the
cozy-stack consider the request is not cookie-authenticated

So when calling `/apps/:slug/open`, a new generated cookie would be
returned instead of the provided one as expected in #277

To fix this we want to specify `credentials:omit` into the fetch
options, this would prevent react-native to inject a copy of the same
cookie

More info: facebook/react-native#23185 (comment)
Ldoppea added a commit that referenced this pull request Sep 30, 2022
In some scenario (mainly in production) we observed that cookie was
duplicated in the HTTP headers. Also both cookies were separated by a
comma instead of a semicolon

This form is not supported by cozy-stack and the result is that the
cozy-stack consider the request is not cookie-authenticated

So when calling `/apps/:slug/open`, a new generated cookie would be
returned instead of the provided one as expected in #277

To fix this we want to specify `credentials:omit` into the fetch
options, this would prevent react-native to inject a copy of the same
cookie

More info: facebook/react-native#23185 (comment)
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