-
Notifications
You must be signed in to change notification settings - Fork 4
fix: Avoid to log in again with same account because of SSO cookie #1339
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
Merged
Merged
Changes from all commits
Commits
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
20 changes: 20 additions & 0 deletions
20
src/app/domain/authentication/utils/deeplinkHandler.spec.ts
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,20 @@ | ||
| import { handleLogoutDeepLink } from '/app/domain/authentication/utils/deeplinkHandler' | ||
| import { closeInAppBrowser } from '/libs/intents/InAppBrowser' | ||
|
|
||
| jest.mock('/libs/intents/InAppBrowser') | ||
|
|
||
| describe('deeplinkHandler', () => { | ||
| describe('handleLogoutDeepLink', () => { | ||
| it('should handle AfterLogout deep links', () => { | ||
| handleLogoutDeepLink('cozy://afterlogout') | ||
|
|
||
| expect(closeInAppBrowser).toHaveBeenCalled() | ||
| }) | ||
|
|
||
| it('should handle AfterLogout universal links', () => { | ||
| handleLogoutDeepLink('https://links.mycozy.cloud/flagship/afterlogout') | ||
|
|
||
| expect(closeInAppBrowser).toHaveBeenCalled() | ||
| }) | ||
| }) | ||
| }) |
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,21 @@ | ||
| import strings from '/constants/strings.json' | ||
| import { closeInAppBrowser } from '/libs/intents/InAppBrowser' | ||
|
|
||
| export const handleLogoutDeepLink = (url: string): boolean => { | ||
| if (isAfterLogoutDeepLink(url)) { | ||
| void closeInAppBrowser() | ||
|
|
||
| return true | ||
| } | ||
|
|
||
| return false | ||
| } | ||
|
|
||
| const isAfterLogoutDeepLink = (url: string): boolean => { | ||
| const deepLinks = [ | ||
| `${strings.COZY_SCHEME}afterlogout`, | ||
| `${strings.UNIVERSAL_LINK_BASE}/afterlogout` | ||
| ] | ||
|
|
||
| return deepLinks.includes(url.toLowerCase()) | ||
| } |
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.
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.
I'm not sure we should rely on
signup.url. Don't we already have config for that? Since cozy-stack call this logout url when we logout from the stack, can't we reuse that? (EndSessionEndpoint I think)Can we have access to this config there?
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.
I will check what else is available.
Another point is here we load an page that is not standardized by OIDC/SSO protocols so we should only use this for sign up I think ?
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.
@Crash-- is it relevant right now?
as far as all the complexity with multi-account will be in sign-up applicaition, and I hope soon we will have this call to a specific OIDC in stack to end specific OIDC session, maybe we can leave with harcoded logout for now?
anyway, if we don't want our app to be an relying party for OIDC flow, id doesn't need OIDC config. and it doesn't have it right now
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.
@Crash-- pr for just one logout url in instance settings
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.
(to test this PR I will need it on int env because I have no oidc setup locally)
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.
I don't know if it's still relevant or not. I know that today we have a misuse of the 'signup.url' flag, and we rely on it for things we should not.
Here if we are sure that we want to call signup/logout then why not, but what about the future if we have external OIDC Provider for our saas platform?
Uh oh!
There was an error while loading. Please reload this page.
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.
That's a part of the problem. We should load this signup/logout page only when this page exists.
@shepilov told me that we may add sign up as proxy before external provider. In this case, his PR is relevant, we should merge it and I should slightly update mine to use his PR.
Otherwise, maybe the best is to do nothing else, rely on
signup.urlflag here until we fix definitively this issue on backend side.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.
I'm pretty sure we'll have a proxy, but not sure if it'll be signup. Maybe directly lemon?
Maybe let's just keep signup right now and we'll find a way to achieve that one day.
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.
Ok so I keep this PR like this. In the future we will find a better way @shepilov I think you can close yours (or keep it opened if you prefer ?)