Replies: 3 comments 4 replies
-
the year is 2021 (you wrote 2020)...😂 but I guess it stopped for most of us last year... 🤪 Looks like a nice work otherwise! |
Beta Was this translation helpful? Give feedback.
4 replies
-
I've been using the JWT method instead of this HOC for supporting an iframe since I need to support chrome. Is there any downside to using JWTs over this HOC? In short,
|
Beta Was this translation helpful? Give feedback.
0 replies
-
@unsphere how do you encrypt session token cookies, aren't they already encrypted? |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
Hi there,
I want to share my hoc that I had to create for my app to support authentication for my embedded protected pages.
I use the suggested Storage Access API that is supported for Safari, Firefox, and Edge. Chrome and others will follow in 2022 I guess.
Using this API makes it possible to use cookies inside an iframe so that next auth works fine.
So basically what we have to do is:
It even works if the user checked Safari's preventing cross-site tracking and Firefox's Strict Enhanced Tracking Protection (see screenshot below).
When this protection is enabled the user has to allow cookie access every time the panel is reloaded (applies only for Safari / Firefox remembers cookie access) but will be logged in directly if the session is not expired. Perhaps this can be made even better. But it works though. Maybe we can ask the user to turn this off and let them know that it will come up every time when you render the allow button.
ITP limits your cookie expiry to 7 days. So you can persist the session at least for 7 days which is fine.
Let me know if I missed or can improve something and feel free to use it in your project :)
You can wrap your protected components like that:
Here is my login route that I point to new window which initiates oauth:
And here are my cookie settings. Make sure to encrypt your session token cookie, because we have to set sameSite none to make it available for iframes.
And here is a screenshot proof:


Example video without "Prevent cross-site tracking": https://recordit.co/jom3dehnDX
Example video with "Prevent cross-site tracking": https://recordit.co/jom3dehnDX
Beta Was this translation helpful? Give feedback.
All reactions