49 lines
2.0 KiB
Diff
49 lines
2.0 KiB
Diff
diff --git a/fluxer_desktop/src/main/Window.ts b/fluxer_desktop/src/main/Window.ts
|
|
index f537d89..b0a3454 100644
|
|
--- a/fluxer_desktop/src/main/Window.ts
|
|
+++ b/fluxer_desktop/src/main/Window.ts
|
|
@@ -104,13 +104,22 @@ function getSanitizedPath(rawUrl: string): string | null {
|
|
}
|
|
}
|
|
|
|
+function isAllowedSsoNavigation(url: string): boolean {
|
|
+ try {
|
|
+ const origin = new URL(url).origin;
|
|
+ return origin === 'https://sso.gandc.ru' || origin === 'https://ds.gandc.ru';
|
|
+ } catch {
|
|
+ return false;
|
|
+ }
|
|
+}
|
|
+
|
|
function preventUntrustedNavigation(event: Electron.Event, url: string, isMainFrame: boolean): void {
|
|
if (isLocalAppURL(url) && !isLocalAppRendererDocumentURL(url)) {
|
|
logger.warn('Blocked a navigation to a reserved local app path', {url, isMainFrame});
|
|
event.preventDefault();
|
|
return;
|
|
}
|
|
- if (isMainFrame && !isTrustedOrigin(url)) {
|
|
+ if (isMainFrame && !isTrustedOrigin(url) && !isAllowedSsoNavigation(url)) {
|
|
event.preventDefault();
|
|
}
|
|
}
|
|
@@ -128,6 +137,9 @@ function attachChildWindowGuards(webContents: Electron.WebContents): void {
|
|
webContents.on('will-frame-navigate', (event) => {
|
|
preventUntrustedChildNavigation(event, event.url, event.isMainFrame);
|
|
});
|
|
+ webContents.on('will-redirect', (event, url, _isInPlace, isMainFrame) => {
|
|
+ preventUntrustedChildNavigation(event, url, isMainFrame);
|
|
+ });
|
|
webContents.setWindowOpenHandler(({url}) => {
|
|
openExternalDeduped(url).catch((error) => {
|
|
log.warn('Failed to open external URL from a popout window-open:', error);
|
|
@@ -1081,6 +1093,9 @@ export function createWindow(options: CreateWindowOptions = {}): BrowserWindow {
|
|
webContents.on('will-frame-navigate', (event) => {
|
|
preventUntrustedNavigation(event, event.url, event.isMainFrame);
|
|
});
|
|
+ webContents.on('will-redirect', (event, url, _isInPlace, isMainFrame) => {
|
|
+ preventUntrustedNavigation(event, url, isMainFrame);
|
|
+ });
|
|
webContents.on('did-create-window', (window, details) => {
|
|
if (
|
|
details.frameName === THEME_STUDIO_POPOUT_WINDOW_NAME &&
|