-
Notifications
You must be signed in to change notification settings - Fork 322
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
Adrienne / Add front channel and silent login to replace logged_state cookies #18069
base: master
Are you sure you want to change the base?
Adrienne / Add front channel and silent login to replace logged_state cookies #18069
Conversation
The latest updates on your projects. Learn more about Vercel for Git ↗︎
|
A production App ID was automatically generated for this PR. (log)
Click here to copy & paste above information.
|
⏳ Generating Lighthouse report... |
// use logged_state cookie login checks for Safari | ||
useLoggedStateLoginAndLogout({ | ||
is_client_store_initialized, | ||
isOAuth2Enabled, |
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.
This is to ensure Safari is still using logged_state
, because at the moment front channels do not work in Safari due to Storage partitioning in Intelligent Tracking Prevention
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.
So if we log out at https://hub.deriv.com
, Hydra will render front channels (i.e. creating iframes in https://hub.deriv.com
to https://app.deriv.com/front-channel.html
) which SHOULD clear local storage in Chrome and Firefox, but it will not work in Safari due to the issue mentioned above
packages/core/src/index.html
Outdated
const isAuthFlow = /\/(silent-callback|front-channel)($|\/)/.test(self.location.pathname); | ||
if (!isAuthFlow) { | ||
top.location = self.location; | ||
} |
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.
This prevents the silent-callback.html
and front-channel.html
iframes to be navigated in the main window
localStorage.removeItem('verification_code.system_email_change'); | ||
localStorage.removeItem('verification_code.request_email'); | ||
localStorage.removeItem('new_email.system_email_change'); | ||
} |
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.
When we call OIDC logout, it will render all front-channels (including the caller's front channel). This caused an issue in Deriv.app where if you clear the local storage while you are still signing out, after signing out it redirects you to the /authorize
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.
* }} params - The arguments required for silent login and logout management | ||
*/ | ||
const useLoggedStateLoginAndLogout = ({ | ||
is_client_store_initialized, |
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.
This is the main hook for the logged_state
logic, I just renamed it to useLoggedStateLoginAndLogout
from useSilentLoginAndLogout
|
||
useEffect(() => { | ||
const isSafariBrowser = isSafari(); | ||
if (isSafariBrowser) return; | ||
|
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.
If we are in Safari, don't use prompt none
|
||
useEffect(() => { | ||
const isSafariBrowser = isSafari(); | ||
if (!isSafariBrowser) return; |
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.
Only trigger logged_state
checks in Safari
packages/core/src/index.html
Outdated
@@ -85,7 +85,10 @@ | |||
var antiClickjack = document.getElementById('antiClickjack'); | |||
antiClickjack.parentNode.removeChild(antiClickjack); | |||
} else { | |||
top.location = self.location; | |||
const isAuthFlow = /\/(silent-callback|front-channel)($|\/)/.test(self.location.pathname); |
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.
[Q] is callback needed here?
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.
Tested this, this is not needed anymore since the silent callback and front channel are served statically under /silent-callback.html
and /front-channel.html
, will remove this change
Changes:
Please provide a summary of the change.
logged_state
syncing logic to only be used in Safariprompt=none
, which will automatically checks if the user is logged in ifclient.accounts
have not been populated yet, local storage is empty/silent-callback.html
which will check if user has session in Hydra (which will return acode
parameter in the URL)error=login_required
which indicates that the user is logged outScreenshots:
Please provide some screenshots of the change.