Skip to content

Commit 4e6c092

Browse files
konczdevsratz
authored andcommitted
[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 9c0cf66 commit 4e6c092

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
@@ -50,6 +50,7 @@ class Edge extends WebBrowser {
5050
// System.getProperty() keys
5151
static final String BROWSER_DIR_PROP = "org.eclipse.swt.browser.EdgeDir";
5252
static final String BROWSER_ARGS_PROP = "org.eclipse.swt.browser.EdgeArgs";
53+
static final String ALLOW_SINGLE_SIGN_ON_USING_OS_PRIMARY_ACCOUNT_PROP = "org.eclipse.swt.browser.Edge.allowSingleSignOnUsingOSPrimaryAccount";
5354
static final String DATA_DIR_PROP = "org.eclipse.swt.browser.EdgeDataDir";
5455
static final String LANGUAGE_PROP = "org.eclipse.swt.browser.EdgeLanguage";
5556
static final String VERSIONT_PROP = "org.eclipse.swt.browser.EdgeVersion";
@@ -565,6 +566,9 @@ WebViewEnvironment createEnvironment() {
565566
String browserDir = System.getProperty(BROWSER_DIR_PROP);
566567
String browserArgs = System.getProperty(BROWSER_ARGS_PROP);
567568
String language = System.getProperty(LANGUAGE_PROP);
569+
570+
boolean allowSSO = Boolean.getBoolean(ALLOW_SINGLE_SIGN_ON_USING_OS_PRIMARY_ACCOUNT_PROP);
571+
568572
String dataDir = getDataDir(display);
569573

570574
// Initialize options
@@ -582,6 +586,11 @@ WebViewEnvironment createEnvironment() {
582586
options.put_Language(pLanguage);
583587
}
584588

589+
if (allowSSO) {
590+
int[] pAllowSSO = new int[]{1};
591+
options.put_AllowSingleSignOnUsingOSPrimaryAccount(pAllowSSO);
592+
}
593+
585594
// Create the environment
586595
char[] pBrowserDir = stringToWstr(browserDir);
587596
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)