Skip to content

Commit 5645307

Browse files
committed
isSecureContext checks for localhost
1 parent e3eee5e commit 5645307

File tree

1 file changed

+8
-14
lines changed
  • packages/auth/src/platform_browser

1 file changed

+8
-14
lines changed

packages/auth/src/platform_browser/index.ts

Lines changed: 8 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -90,20 +90,14 @@ export function getAuth(app: FirebaseApp = getApp()): Auth {
9090
});
9191

9292
const authTokenSyncPath = getExperimentalSetting('authTokenSyncURL');
93-
if (authTokenSyncPath) {
94-
// Reduce the chances of an XSS attack by only allowing secure contexts or the same origin.
95-
const isLocalHost = ['localhost', '127.0.0.1', '0.0.0.0'].includes(
96-
location.hostname
97-
);
98-
if (isSecureContext || isLocalHost) {
99-
const authTokenSyncUrl = new URL(authTokenSyncPath, location.origin);
100-
if (location.origin === authTokenSyncUrl.origin) {
101-
const mintCookie = mintCookieFactory(authTokenSyncUrl.toString());
102-
beforeAuthStateChanged(auth, mintCookie, () =>
103-
mintCookie(auth.currentUser)
104-
);
105-
onIdTokenChanged(auth, user => mintCookie(user));
106-
}
93+
if (authTokenSyncPath && isSecureContext) {
94+
const authTokenSyncUrl = new URL(authTokenSyncPath, location.origin);
95+
if (location.origin === authTokenSyncUrl.origin) {
96+
const mintCookie = mintCookieFactory(authTokenSyncUrl.toString());
97+
beforeAuthStateChanged(auth, mintCookie, () =>
98+
mintCookie(auth.currentUser)
99+
);
100+
onIdTokenChanged(auth, user => mintCookie(user));
107101
}
108102
}
109103

0 commit comments

Comments
 (0)