Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 20 additions & 0 deletions src/app/domain/authentication/utils/deeplinkHandler.spec.ts
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()
})
})
})
21 changes: 21 additions & 0 deletions src/app/domain/authentication/utils/deeplinkHandler.ts
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())
}
5 changes: 5 additions & 0 deletions src/hooks/useAppBootstrap.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import { useEffect, useState } from 'react'
import { deconstructCozyWebLinkWithSlug } from 'cozy-client'

import { handleLogsDeepLink } from '/app/domain/logger/deeplinkHandler'
import { handleLogoutDeepLink } from '/app/domain/authentication/utils/deeplinkHandler'
import rnperformance from '/app/domain/performances/measure'
import { SentryCustomTags, setSentryTag } from '/libs/monitoring/Sentry'
import { manageIconCache } from '/libs/functions/iconTable'
Expand Down Expand Up @@ -190,6 +191,10 @@ export const useAppBootstrap = client => {
return
}

if (handleLogoutDeepLink(url)) {
return
}

if (!client) {
const action = parseOnboardLink(url)

Expand Down
12 changes: 12 additions & 0 deletions src/libs/intents/localMethods.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import {
PostMeMessageOptions
} from 'cozy-intent'
import Minilog from 'cozy-minilog'
import flag from 'cozy-flags'

import * as RootNavigation from '/libs/RootNavigation'
import { isIapAvailable } from '/app/domain/iap/services/availableOffers'
Expand Down Expand Up @@ -64,12 +65,23 @@ export const asyncLogout = async (client?: CozyClient): Promise<null> => {
throw new Error('Logout should not be called with undefined client')
}

const signupUrl = flag('signup.url') as string | undefined
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.

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?

Copy link
Copy Markdown
Member Author

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 ?

Copy link
Copy Markdown
Member

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

Copy link
Copy Markdown
Member

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

Copy link
Copy Markdown
Member Author

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)

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.

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?

Copy link
Copy Markdown
Member Author

@zatteo zatteo Jan 28, 2026

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.url flag here until we fix definitively this issue on backend side.

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.

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.

Copy link
Copy Markdown
Member Author

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 ?)


await sendKonnectorsLogs(client)
await clearClientCachedData(client)
await client.logout()
await deleteKeychain()
await clearCookies()
await clearCozyData()

// Delete SSO cookie from In App Browser to avoid being reconnected to same account
// when logging in again
if (signupUrl) {
const logoutUrl = `${signupUrl}/logout?url=cozy://afterlogout`

await showInAppBrowser({ url: logoutUrl })
}

RootNavigation.reset(routes.welcome, { screen: 'welcome' })
return Promise.resolve(null)
}
Expand Down
Loading