# Is it secure to embed SPA in iframe?

**URL:** <https://community.auth0.com/t/is-it-secure-to-embed-spa-in-iframe/61380>\
**Category:** Get Help\
**Tags:** iframe, spa, embedded-login, login\
**Created:** [April 19, 2021, 8:13pm UTC](https://community.auth0.com/t/is-it-secure-to-embed-spa-in-iframe/61380 "2021-04-19T20:13:28Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![msiracusa](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/msiracusa/32/13207_2.png) [@msiracusa](https://community.auth0.com/u/msiracusa)\
**Post date:** [April 19, 2021, 8:13pm UTC](https://community.auth0.com/t/is-it-secure-to-embed-spa-in-iframe/61380/1 "2021-04-19T20:13:28Z")

</div>

Hi all

I have an application that is using Auth0 to authenticate users. Now I would like that any third party sites can embed my application in an iframe so that they can use the services from my app.

I’m not sure about the security implications of this. I did a PoC and tried to access the id token from the third party site and I can see that it is forbidden by the browser:

` Uncaught DOMException: Permission denied to access property "document" on cross-origin object`

But the fact that the token lives in the local session storage makes me a little uneasy about this use case.

What would be the recommendation?

---

<div class="post-metadata">

**Author:** ![msiracusa](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/msiracusa/32/13207_2.png) [@msiracusa](https://community.auth0.com/u/msiracusa)\
**Post date:** [May 10, 2021, 8:26pm UTC](https://community.auth0.com/t/is-it-secure-to-embed-spa-in-iframe/61380/2 "2021-05-10T20:26:25Z")

</div>

Replying to myself, in case that anyone has a question like this.

I asked Auth0’s professional services and they told me that it’s not a good idea.

I proposed a mitigation strategy (using CSP HTTP header to whitelist the domains that are allowed to embed the login page) but they didn’t comment about that.

---

<div class="post-metadata">

**Author:** ![konrad.sopala](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/konrad.sopala/32/13516_2.png) [@konrad.sopala](https://community.auth0.com/u/konrad.sopala)\
**Post date:** [May 11, 2021, 8:55am UTC](https://community.auth0.com/t/is-it-secure-to-embed-spa-in-iframe/61380/3 "2021-05-11T08:55:36Z")

</div>

Thanks for sharing that with the rest of community!

---

<div class="post-metadata">

**Author:** ![system](https://global.discourse-cdn.com/auth0/original/3X/b/5/b560f266932fcce5d57f09a6595bd50518cae3f3.jpeg) [@system](https://community.auth0.com/u/system)\
**Post date:** [May 26, 2021, 8:56am UTC](https://community.auth0.com/t/is-it-secure-to-embed-spa-in-iframe/61380/4 "2021-05-26T08:56:10Z")

</div>

This topic was automatically closed 15 days after the last reply. New replies are no longer allowed.
