# Authentication between a website and an embedded widget (iframe or shadowDOM)

**URL:** <https://community.auth0.com/t/authentication-between-a-website-and-an-embedded-widget-iframe-or-shadowdom/189500>\
**Category:** Get Help\
**Tags:** authentication-sessions, sessions\
**Created:** [July 22, 2025, 10:29am UTC](https://community.auth0.com/t/authentication-between-a-website-and-an-embedded-widget-iframe-or-shadowdom/189500 "2025-07-22T10:29:06Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![nish\_rm](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/nish_rm/32/70821_2.png) [@nish\_rm](https://community.auth0.com/u/nish_rm)\
**Post date:** [July 22, 2025, 10:29am UTC](https://community.auth0.com/t/authentication-between-a-website-and-an-embedded-widget-iframe-or-shadowdom/189500/1 "2025-07-22T10:29:06Z")

</div>

I am extending a widget application(Client B) to be added to a website(Client A) of a business client.

An authenticated user in Client A should be able to seamlessly login to Client B. If that is not possible, the user should be able to log in to Client B using a login form.

**Client A**

- NextJS with Auth0 Regular Web App Configuration
- No Auth0 custom domain available.
- Not managed by me.

**Client B**

- Planning to host in a separate domain. But can be hosted under the Client A website if essential for the configuration.
- Can be served as an embedded iframe site or a shadowDOM(customElement and a script tag) widget in Client A.
- Planning to add an Auth0 SPA client config with the same database connection.

**Question**  
this [**previous thread**](https://community.auth0.com/t/seamless-authentication-between-two-apps/151065) suggests that SSO can be used for seamlessly authenticating with multiple apps.

**Are there any other approaches that I can take for this scenario?**

**Or should I fix the custom domain issue first and implement SSO with silent authentication?**

Issues recap:

- no custom domain. If this is a major blocker, I will need to ask the business client to add a custom domain.
- Login form inside iframe is vulnerable to Clickjacking.

---

<div class="post-metadata">

**Author:** ![Billy958Browne](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/billy958browne/32/74006_2.png) [@Billy958Browne](https://community.auth0.com/u/Billy958Browne)\
**Post date:** [July 23, 2025, 5:40am UTC](https://community.auth0.com/t/authentication-between-a-website-and-an-embedded-widget-iframe-or-shadowdom/189500/2 "2025-07-23T05:40:43Z")

</div>

Hello!  
I faced similar kind of issue last time, I am still searching for some proper answer.

---

<div class="post-metadata">

**Author:** ![nish\_rm](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/nish_rm/32/70821_2.png) [@nish\_rm](https://community.auth0.com/u/nish_rm)\
**Post date:** [July 23, 2025, 11:56am UTC](https://community.auth0.com/t/authentication-between-a-website-and-an-embedded-widget-iframe-or-shadowdom/189500/3 "2025-07-23T11:56:30Z")

</div>

[ShadowDOM is not secure enough](https://www.imperva.com/learn/application-security/shadow-dom/#potential-security-concerns-with-shadow-dom) to handle auth sessions. My main concern is that cookies are managed per host and ShadowDOM widgets donot live inside a separate host. It just creates an isolated DOM in the main host site using the loaded script.  
So there can be many security loopholes when using it.

I ended up with an iframe solution that loads the widget from the widget host. It uses SSO and Silent Authentication to automatically sign-in the users. It worked without a custom domain in Chrome and Firefox. Not tested in other browsers yet.

Next task is to find how to explicitly sign out the session in the widget host when the user logs out from the main host site. It will just make sure everything in the widget is invalidated.

---

<div class="post-metadata">

**Author:** ![vlad.murarasu](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/vlad.murarasu/32/72793_2.png) [@vlad.murarasu](https://community.auth0.com/u/vlad.murarasu)\
**Post date:** [July 24, 2025, 6:54pm UTC](https://community.auth0.com/t/authentication-between-a-website-and-an-embedded-widget-iframe-or-shadowdom/189500/5 "2025-07-24T18:54:00Z")

</div>

Hi @nish_rm,

Welcome to the Auth0 Community!

I am glad that you managed to find a solution for establishing the session between the client app and the embedded widget. As you mentioned, a custom domain was not required to establish SSO between these two components as long as both applications used the same tenant and databases.

Regarding your clickjacking concern, you can read out [documentation](https://auth0.com/docs/troubleshoot/product-lifecycle/past-migrations/clickjacking-protection-for-universal-login) on enabling the necessary HTTP headers.

Otherwise, invalidating the widget’s session once the user has logged out of Client A can be quite complicated. One possible solution would be to store the widget’s session ID inside `app_metadata`, retrieve it on user logout, and use the management API to [revoke the session](https://auth0.com/docs/api/management/v2/sessions/revoke-session).

If you have any other questions, feel free to reach out!

Have a good one,  
Vlad

---

<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:** [August 7, 2025, 6:54pm UTC](https://community.auth0.com/t/authentication-between-a-website-and-an-embedded-widget-iframe-or-shadowdom/189500/6 "2025-08-07T18:54:24Z")

</div>

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