Skip to content

Commit b0cfa3d

Browse files
committed
[Win32] Add SSO support for SWT Browser using Edge backend
Introduces a new system property to enable Single Sign-On: - org.eclipse.swt.browser.Edge.allowSingleSignOnUsingOSPrimaryAccount This allows SWT Browser to use the logged-in Windows account for SSO with Azure AD resources and Microsoft account-enabled websites when using the Edge backend.
1 parent f720f49 commit b0cfa3d

File tree

2 files changed

+13
-0
lines changed

2 files changed

+13
-0
lines changed

bundles/org.eclipse.swt/Eclipse SWT Browser/win32/org/eclipse/swt/browser/Edge.java

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,7 @@ class Edge extends WebBrowser {
4949
// System.getProperty() keys
5050
static final String BROWSER_DIR_PROP = "org.eclipse.swt.browser.EdgeDir";
5151
static final String BROWSER_ARGS_PROP = "org.eclipse.swt.browser.EdgeArgs";
52+
static final String ALLOW_SINGLE_SIGN_ON_USING_OS_PRIMARY_ACCOUNT_PROP = "org.eclipse.swt.browser.Edge.allowSingleSignOnUsingOSPrimaryAccount";
5253
static final String DATA_DIR_PROP = "org.eclipse.swt.browser.EdgeDataDir";
5354
static final String LANGUAGE_PROP = "org.eclipse.swt.browser.EdgeLanguage";
5455
static final String VERSIONT_PROP = "org.eclipse.swt.browser.EdgeVersion";
@@ -564,6 +565,9 @@ WebViewEnvironment createEnvironment() {
564565
String browserDir = System.getProperty(BROWSER_DIR_PROP);
565566
String browserArgs = System.getProperty(BROWSER_ARGS_PROP);
566567
String language = System.getProperty(LANGUAGE_PROP);
568+
569+
boolean allowSSO = Boolean.getBoolean(ALLOW_SINGLE_SIGN_ON_USING_OS_PRIMARY_ACCOUNT_PROP);
570+
567571
String dataDir = getDataDir(display);
568572

569573
// Initialize options
@@ -581,6 +585,11 @@ WebViewEnvironment createEnvironment() {
581585
options.put_Language(pLanguage);
582586
}
583587

588+
if (allowSSO) {
589+
int[] pAllowSSO = new int[]{1};
590+
options.put_AllowSingleSignOnUsingOSPrimaryAccount(pAllowSSO);
591+
}
592+
584593
// Create the environment
585594
char[] pBrowserDir = stringToWstr(browserDir);
586595
char[] pDataDir = stringToWstr(dataDir);

bundles/org.eclipse.swt/Readme.WebView2.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,10 @@ language+country code that defines the browser UI language and preferred
6767
language for HTTP requests (`Accept-Languages` header).
6868
Example values: `en`, `ja`, `en-GB`, `de-AT`.
6969

70+
The property `org.eclipse.swt.browser.Edge.allowSingleSignOnUsingOSPrimaryAccount` enables Single Sign-On with Azure Active Directory (AAD) resources using the logged-in Windows account. This also enables SSO with websites using Microsoft accounts associated with the Windows login. Setting this property to true enables this feature. The default value is false.
71+
72+
See also: https://learn.microsoft.com/en-us/dotnet/api/microsoft.web.webview2.core.corewebview2environmentoptions.allowsinglesignonusingosprimaryaccount
73+
7074
_Note_: All of the properties described above must be set before the first
7175
instance of the `Browser` with `SWT.EDGE` style is created.
7276

0 commit comments

Comments
 (0)