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

Embed not working on Safari #2

Closed
simurai opened this issue Nov 8, 2017 · 26 comments
Closed

Embed not working on Safari #2

simurai opened this issue Nov 8, 2017 · 26 comments

Comments

@simurai
Copy link
Contributor

simurai commented Nov 8, 2017

your component is not working on Safari. For him, it doesn't display at all, while for me it displays but doesn't send the messages. It wipes the input box but doesn't ever actually append the message to the end of the list.

@simurai simurai added the bug label Nov 8, 2017
@simurai
Copy link
Contributor Author

simurai commented Nov 8, 2017

I tested on:

Seems to work fine:

safari

@simurai
Copy link
Contributor Author

simurai commented Nov 8, 2017

The person reporting the issue is using:

  • macOS El Capitan
  • Safari 11.0.1

So maybe it's an issue with an older OS version?

@antstorm are you by any chance still on El Capitan? Probably not.. 😄

@simurai simurai added the safari label Nov 8, 2017
@warrendugan
Copy link

http://www.giphy.com/gifs/xT0xeDQDvEXtiOTHH2 - File size too large to upload here

Went to your codepen on my iMac:

  • macOS High Sierra
  • Safari 11.0.1

@simurai
Copy link
Contributor Author

simurai commented Nov 8, 2017

Ha.. interesting. Thanks for posting the gif.

So not really the OS then. Also interesting how it scrolls up/down after pressing enter.

@antstorm Any clue what it could be?

@warrendugan
Copy link

warrendugan commented Nov 8, 2017 via email

@simurai
Copy link
Contributor Author

simurai commented Nov 8, 2017

Sorry, that was me scrolling to show that it was not just hidden overflow
or something.

Ah.. I see. Ok, so then messages just don't get posted.

Are there any errors in the console of the web inspector (DevTools)?

@warrendugan
Copy link

Throws an error in the console every time I click send. Here's what I get:

  • Failed to load resource: the server responded with a status of 403 (HTTP/2.0 403)
  • Then it gives me a reference URL of https://embed.tlk.io/api/chats/283/messages which appears to be just a JSON file and does not seem to show the messages I tried to send as my username was safari.

@warrendugan
Copy link

This is what I get in the network tab:
Response:
{
"error": "Unauthorized Access"
}
Request:
{
"body": "test",
"expired": false
}
Note: the body matches what I wrote into the input box.

@antstorm
Copy link

antstorm commented Nov 8, 2017

Pasting an earlier email:

Hi Warren,

I’ve spent some time trying to understand the underlying issue and it turns out that Safari no longer supports 3rd party iframe cookies. It is just dropping these, that’s why the messages won’t come through — they fail authentication on our side.

I’ve also tried implementing what seems to be the common solution for this problem — basically you open up a pop-up that sets a cookie, making the target website “familiar”, thus allowing cookies. But it doesn’t seem to work — seems like the newest Safari disabled these altogether. There is a setting in Safari that will enable this behaviour, depending on your use case it may or may not be a solution for you.

As for the permanent fix — seems like we’ll need to use other means for session management within the iframe (something like JWT or a self-signed token). I’ll start working on this straight away, but I won’t be able to commit to releasing it this Thursday.

Really sorry for this inconvenience. I’ll ping you on the progress within a couple of days.

@antstorm
Copy link

antstorm commented Nov 8, 2017

@warrendugan @simurai what do your cookie settings in Safari look like? Here's mine:

screenshot 2017-11-08 21 54 53

I don't remember ever changing this. If this is the current default then there's no simple fix.

Here's a demo of the fix (which doesn't work for me because of my settings) — http://vitr.github.io/safari-cookie-in-iframe/demo.html. When you click on the "fixed page" it should say that cookies work.

If it's just my settings that are off then there is a quicker fix for this problem.

@warrendugan
Copy link

This is what I get:

screen shot 2017-11-08 at 2 42 35 pm

@simurai
Copy link
Contributor Author

simurai commented Nov 9, 2017

I have the same settings as @warrendugan ☝️ .

But now I know why tlk.io worked for me even after updating to High Sierra. It's because it still used the cookies saved from the previous Safari version. After removing them...

screen shot 2017-11-09 at 3 18 05 pm

the chat doesn't show up anymore. So it should still work in Safari for people that used tlk.io in the past, but not for new users (or when deleting the cookies).

@antstorm
Copy link

antstorm commented Nov 9, 2017

@simurai so it doesn't show up at all? Or you just can't post messages?

Yeah, seems like we'll need to find a way around it. It seems like you can manually access parent window's cookies, which might be a solution.

@simurai
Copy link
Contributor Author

simurai commented Nov 10, 2017

It doesn't show up at all:

screen shot 2017-11-10 at 1 00 15 pm

Failed to load resource: the server responded with a status of 404 (HTTP/2.0 404) https://tlk.io/embed.js

But this is probably another issue. It also happens in Chrome and Firefox. Sounds the same as:

@antstorm
Copy link

This is really weird! Can you access https://tlk.io/embed.js directly in your browser?

I wonder if HTTP/2.0 has to do anything with it…

@simurai
Copy link
Contributor Author

simurai commented Nov 14, 2017

I get a 404:

screen shot 2017-11-14 at 10 29 03 am

Or maybe a caching/CDN issue? I think I remember something like deleting tlk.io's cookies in Chrome and refresh a 2nd time until I saw the issue.

@antstorm
Copy link

Hmm… really odd. We don't use CDN, the files should be served directly. What if you try requesting it from the console directly curl -I https://tlk.io/embed.js?

@warrendugan
Copy link

I'm able to access https://tlk.io/embed in Safari and Chrome but not with the .js after it. Also, I'm able to send and receive messages in Safari and Chrome on that URL.

@simurai
Copy link
Contributor Author

simurai commented Nov 14, 2017

Ohh.. now https://tlk.io/embed.js works again for me. 👍 Also https://codepen.io/anon/pen/ooYNaV works fine. In both, Safari and Chrome. Weird eh?

@antstorm
Copy link

Ok, so the issue with https://tlk.io/embed.js should now be resolved and it should return a JS file. @warrendugan can you please confirm this?

@simurai totally weird! It might be that Safari will allow to use the cookie that was when visiting the embedded webpage directly. The most popular solution for this issue also suggested opening a popup to your website, setting the cookie, immediately closing it and then reloading the iframe. Which should probably work, but UX in this case would be awful, not to mention the iPhone experience.

I'm looking into solutions to resolve cookies issue.

@brettdonald
Copy link

Apple has added further restrictions to its "Intelligent Tracking Protection" and now blocks cross-site cookies completely. These blog posts point to some alternative methods which developers can use instead -- not sure if they will apply to tlk.io.

https://www.theverge.com/2020/3/24/21192830/apple-safari-intelligent-tracking-privacy-full-third-party-cookie-blocking
https://webkit.org/blog/10218/full-third-party-cookie-blocking-and-more/

@antstorm
Copy link

@brettdonald thank you for linking these! 👍 Unfortunately the ones I've read so far were not very clear, but maybe these are better

@brettdonald
Copy link

brettdonald commented May 27, 2020 via email

@antstorm
Copy link

antstorm commented Jul 7, 2020

@brettdonald local storage is not passed back to the server, which makes it unusable for authentication purposes. I've just posted another fix and tried it out and it seems to be working correctly, can you please check if that also works for you?

I'm on Mac OS X 10.15.4, Safari 13.1 (15609.1.20.111.8)

@brettdonald
Copy link

brettdonald commented Jul 8, 2020

Yes, it works! That's fantastic! I'm on macOS 10.14.6, Safari 13.0.3 (14608.3.10.10.1). Thanks so much for your time working on this. I think you can mark the issue as resolved/closed.

Can you describe briefly the changes you had to make? Have you fundamentally changed the way tlk.io works, or did you add a separate code path for Safari, and keep the code the same for all other browsers?

@antstorm
Copy link

@brettdonald this is great, thank you for confirming! 👍

Basically I had to call hasStorageAccess and requestStorageAccess APIs (only Safari supports these right now as far as I know) to explicitly request the use of cookies from the client's browser. This has to be done on user action making the intent obvious.

No fundamental changes were necessary, but there was some confusion in how those APIs work and the amount of information on this issue is unfortunately limited. Here's a good thread on the matter — https://gist.github.com/iansltx/18caf551baaa60b79206

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants