-
Notifications
You must be signed in to change notification settings - Fork 137
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Edge: Implement AuthenticationListener handling for BasicAuth #1571
Conversation
Differences to IE engine: - Location attribute: - IE does not provide the 'location' for the callback, so this has to be guessed from lastNavigateURL which does not work consistently, e.g. after an immediate Browser.setUrl(); - Edge does provide the 'location' information consistently - When returning invalid credentials - IE does not call the authentication handler again for further attempts - Edge calls the authentication handler again and again. Keeping track of this is out-of-scope for SWT. There is no retryCount field or similar in the event. AuthenticationHandler implementations need to account for unbounded repetitive calls in case the server does not bail out. Resolves #730.
Can be manually tested, e.g. using https://httpbin.org: import org.eclipse.swt.SWT;
import org.eclipse.swt.browser.Browser;
import org.eclipse.swt.layout.FillLayout;
import org.eclipse.swt.widgets.Display;
import org.eclipse.swt.widgets.Shell;
public class EdgeAuth {
public static void main(String[] args) {
Display display = new Display();
Shell shell = new Shell(display);
shell.setLayout(new FillLayout());
Browser browser = new Browser(shell, SWT.EDGE);
browser.addAuthenticationListener(event -> {
System.out.println(event.location);
// testable scenarios
{
// 1: fallback to browser dialog
}
{
// 2: failure (causing repeated calls)
event.user = "foo";
event.password = "WRONG";
}
{
// 3: correct credentials
event.user = "foo";
event.password = "bar";
}
{
// 4: cancel authentication
event.doit = false;
}
});
browser.setUrl("https://httpbin.org/basic-auth/foo/bar");
shell.open();
while (!shell.isDisposed()) {
if (!display.readAndDispatch())
display.sleep();
}
display.dispose();
}
} |
Test Results 483 files ±0 483 suites ±0 9m 10s ⏱️ + 1m 19s For more details on these failures, see this check. Results for commit 4858107. ± Comparison against base commit ce2795a. |
...2/org/eclipse/swt/internal/ole/win32/ICoreWebView2BasicAuthenticationRequestedEventArgs.java
Show resolved
Hide resolved
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The code looks good and works as expected. Differences to IE sound okay or even beneficial.
Implementing the commented out code in ICoreWebView2BasicAuthenticationRequestedEventArg
sounds reasonable, but from my side would not be necessary if it is currently not used anymore. Feel free to decide whether you want to change/add that. My approval holds no matter whether that change is made.
Thanks for reviewing. Agreed, the Edge behavior feels better / more intuitive.
I added the method implementation so the interface definition is complete. |
Test failures on Linux are unrelated. |
Differences to IE engine:
Resolves #730.