Support embedding Discourse in an iframe

Howdy!

I’m developing a web app, and I’d love to use Discourse as my forums / community discussion platform. One of my main requirements though is that the forum should be able to be opened in an iframe docked to the side of my UI, so that users can browse tutorials, talk to other people, or contact support all within the comfort of the app itself. This is a huge win for UX, and because Discourse is responsive and mobile friendly, a small iframe should work well for this use case. It seems like this would be an awesome feature for Discourse that many people might use.

I saw this old discussion about this topic, which includes one proposed solution.

So I wanted to ask the maintainers and folks here, is this a feature that you would be open to a PR for? Would you consider adding this feature? Are there any issues with that solution that was proposed that would need to be dealt with?

The main issue I see is that of opening up possible Security problems. eg.

Cross Frame Scripting

Interesting, thanks for pointing that out.

If Cross Frame Scripting was a concern, could we allow people to specify a trusted domain(s)?

For example, the ALLOW-FROM URI in the X-FRAME-OPTIONS header. See here.

pasted the wrong URL - link fixed

Yes, sending headers should take care of most if not all security risks.
(I say most because I don’t know if some older browsers might not use the headers)

Okie dokie :thumbsup:

Not being a developer, this thread leaves me puzzled about what the conclusion is regarding embedding discourse in an IFRAME. When you say:

This sounds to me like: problem solved, especially since - in my case - everything would not only be happening under the same domain but even on the same server. But my understaning is also that this is nevertheless not supported and therefore not recommended for people like me. But why? If trusted domains can be specified?

Because it’s an extremely fragile configuration. Discourse expects to control the browser tightly as a JavaScript app. This is not a static 1996 era web page to be slapped in an <iframe> willy-nilly, it’s far more complex.

2 лайка

@codinghorror Есть какие-то новости по этому вопросу? Было бы здорово иметь возможность встроить календарь на наш сайт, чтобы всё выглядело единообразно.

Редактирование: Я просто хочу иметь возможность встроить эту страницу: Julia Programming Language

Возможно, существует скрытая настройка, отключающая директиву no-iframe, но я сейчас не помню, однако мы добавили её не просто так.

Думаю, это скорее запрос на новую функцию для плагина: вставка должна отличаться от целой страницы.

Cc @j.jaffeux

5 лайков

Существует простой плагин. Однако он не работает. Можно ли сделать его рабочим с помощью простого изменения, так как он был обновлен 6 лет назад?


   
# name: Разрешить встраивание iFrame
# about: Изменяет X-Frame-Options, чтобы сайт можно было встроить
# version: 1
# authors: bex-team, riking,

Rails.application.config.action_dispatch.default_headers.merge!({'X-Frame-Options' => 'ALLOWALL'})

Для того чтобы без ограничений встраивать Discourse в iframes, потребуется изменить два параметра:

  1. Снимите флажок с ограничений CSP в настройках

  2. Включите скрытую настройку сайта allow_embedding_site_in_an_iframe

cd /var/discourse
./launcher enter app
rails c
SiteSetting.allow_embedding_site_in_an_iframe=true
exit
exit
2 лайка

@denvergeeks Я пробовал это, но мой форум всё равно не встраивается в iframe.

Какой URL вашего сайта вы пытаетесь встроить?

forum.dreambyte.ai

Ссылка, которую вы опубликовали, вообще не загружается у меня… Если вы сможете заставить её открыться, я смогу протестировать её на своём сайте, где встраивание через iFrame работает.

Было бы очень полезно для меня внедрить Discourse Calendar на другой сайт. Есть ли какие-либо успехи в этом?