<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0"><channel><title><![CDATA[Using Fusion auth inside iframe]]></title><description><![CDATA[<p dir="auto">Hi all,</p>
<p dir="auto">I'm currently setting up FusionAuth for use in our application (React frond-end + NestJS backend). We host FusionAuth ourselves (version 1.49.2), let's say <a href="https://fusion.domain.com" rel="nofollow ugc">https://fusion.domain.com</a> and my application is running on <a href="https://application.domain.com" rel="nofollow ugc">https://application.domain.com</a>. We've set up a tenant with OIDC.<br />
The top domain is the same, so everything works fine when I go to <a href="https://application.domain.com" rel="nofollow ugc">https://application.domain.com</a> directly.</p>
<p dir="auto">However, for some use cases, our application will be loaded by external apps in an iframe. These external apps will be hosted on <em>different domains</em>, say <a href="https://app.other.com" rel="nofollow ugc">https://app.other.com</a>. So far I've not been able to get it to run. I've had a look at <a href="https://fusionauth.io/community/forum/topic/904/sso-not-working-inside-iframe?_=1717598295666">this other post</a> without success.</p>
<p dir="auto">The first issue I have is with the X-Frame-Options header. As per <a href="https://fusionauth.io/docs/get-started/core-concepts/applications" rel="nofollow ugc">the documentation</a> I've added the domain <a href="https://app.other.com" rel="nofollow ugc">https://app.other.com</a> in the <code>Authorized request origin URLs</code> so that the <code>X-Frame-Options: DENY</code> is removed. I've also added the <a href="https://app.other.com" rel="nofollow ugc">https://app.other.com</a> to the allowed CORS origins. This works partially. Sometimes the <code>X-Frame-Options: DENY</code> is indeed removed, sometimes it's there.</p>
<p dir="auto">However, even when it is removed, the following problem is that the cookies set by the Hosted app are sent back with SameSite=Lax attribute. This means they are not sent on subsequent requests and the authentication fails.</p>
<p dir="auto">To overcome this issue, I've set up the oauth endpoints myself as described in <a href="https://fusionauth.io/docs/quickstarts/quickstart-javascript-express-web" rel="nofollow ugc">the express tutorial</a>. Now I can set SameSite=None and cookies are correctly set. But even with that the authentication fails. From what I see, it's the redirection from the OIDC provider to FusionAuth which fails because a code is missing.</p>
<p dir="auto">I've also tried the following:</p>
<ul>
<li>Switch from Cookies to Bearer auth. Using a popup opened by the iframe and try to send back the token to the opener with postMessage. This doesn't work because the opener object is cleared upon redirection to a different domain.</li>
<li>Try to use a SharedWorker as a channel to send the token. Does not work either because of CSP. The app loaded in the iframe creates a different worker</li>
</ul>
<p dir="auto">I'm currently trying to set up a proxy for FusionAuth to be able to control the cookies and their attributes but that seems a bit overkill.</p>
<p dir="auto">So my question is: what is the standard approach when dealing with such cases? How can I use FusionAuth for my app in an cross-domain iframe?</p>
<p dir="auto">Thanks and sorry for the long post.</p>
]]></description><link>https://fusionauth.io/community/forum/topic/2698/using-fusion-auth-inside-iframe</link><generator>RSS for Node</generator><lastBuildDate>Tue, 17 Nov 2026 04:16:17 GMT</lastBuildDate><atom:link href="https://fusionauth.io/community/forum/topic/2698.rss" rel="self" type="application/rss+xml"/><pubDate>Wed, 05 Jun 2024 15:00:04 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to Using Fusion auth inside iframe on Fri, 16 Aug 2024 16:20:16 GMT]]></title><description><![CDATA[<p dir="auto">For future readers, there's an open GH issue here to better support iframes: <a href="https://github.com/FusionAuth/fusionauth-issues/issues/2830" rel="nofollow ugc">https://github.com/FusionAuth/fusionauth-issues/issues/2830</a></p>
<p dir="auto">Please add your use cases, upvotes and comments there.</p>
]]></description><link>https://fusionauth.io/community/forum/post/7473</link><guid isPermaLink="true">https://fusionauth.io/community/forum/post/7473</guid><dc:creator><![CDATA[dan]]></dc:creator><pubDate>Fri, 16 Aug 2024 16:20:16 GMT</pubDate></item><item><title><![CDATA[Reply to Using Fusion auth inside iframe on Fri, 02 Aug 2024 18:34:24 GMT]]></title><description><![CDATA[<p dir="auto"><a class="mention plugin-mentions-user plugin-mentions-a" href="https://fusionauth.io/community/forum/uid/3053">@maxime-guitet</a></p>
<p dir="auto">Hi, did you ever solve your problem? We also encountered this after updating from 1.44 to 1.51.2 -- it seems like iFrames are completely broken now across domains.</p>
]]></description><link>https://fusionauth.io/community/forum/post/7427</link><guid isPermaLink="true">https://fusionauth.io/community/forum/post/7427</guid><dc:creator><![CDATA[dustin]]></dc:creator><pubDate>Fri, 02 Aug 2024 18:34:24 GMT</pubDate></item><item><title><![CDATA[Reply to Using Fusion auth inside iframe on Mon, 10 Jun 2024 08:04:26 GMT]]></title><description><![CDATA[<p dir="auto">Hi <a class="mention plugin-mentions-user plugin-mentions-a" href="https://fusionauth.io/community/forum/uid/3036">@vatsal</a>,</p>
<p dir="auto">Thanks for the input, I will try that.<br />
However, if I understand correctly what you say, I think my setup is slightly different. The iframe is in a page hosted in a <em>different</em> domain. I load the app in it which then redirects to the fusion auth app. So even when the X-Frame-Options header is correctly set, then I face the third-party cookies issue with SameSite=Lax.</p>
<p dir="auto">The question is actually more general: with 3rd-party cookies being phased out, what will be the strategy to load FA in an iframe on a different domain?</p>
]]></description><link>https://fusionauth.io/community/forum/post/7336</link><guid isPermaLink="true">https://fusionauth.io/community/forum/post/7336</guid><dc:creator><![CDATA[maxime.guitet]]></dc:creator><pubDate>Mon, 10 Jun 2024 08:04:26 GMT</pubDate></item><item><title><![CDATA[Reply to Using Fusion auth inside iframe on Thu, 06 Jun 2024 02:19:21 GMT]]></title><description><![CDATA[<p dir="auto"><a class="mention plugin-mentions-user plugin-mentions-a" href="https://fusionauth.io/community/forum/uid/3053">@maxime-guitet</a> Hi , I was facing a similar issue when I was trying to load the self-service account page in Iframe in our application.</p>
<p dir="auto">Our setup was same as yours. Fusion auth hosted on <code>auth.domain.com</code> and the iframe is hosted on <code>app.domain.com</code>. So they both share the same top level domain. The issue regarding the X-Frame-Options: Deny being not available in every request was solved by adding referrer policy attribute to the iframe tag.</p>
<p dir="auto">The final iframe code looks like below</p>
<pre><code class="language-html">&lt;iframe
        src="https://auth.domain.com/account/?client_id=&lt;your id for application&gt;"
        referrerpolicy="strict-origin-when-cross-origin"&gt;&lt;/iframe&gt;
</code></pre>
<p dir="auto">Hope this helps!</p>
<p dir="auto">Regards<br />
Vatsal</p>
]]></description><link>https://fusionauth.io/community/forum/post/7329</link><guid isPermaLink="true">https://fusionauth.io/community/forum/post/7329</guid><dc:creator><![CDATA[vatsal]]></dc:creator><pubDate>Thu, 06 Jun 2024 02:19:21 GMT</pubDate></item></channel></rss>