Skip to content
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

[webview_flutter_wkwebview] Support NTLM for authentication #7670

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
## 3.16.0

* Support NTLM for authentication

## 3.15.0

* Adds macOS support.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -505,6 +505,9 @@ class NSUrlAuthenticationMethod {

/// Use HTTP digest authentication for this protection space.
static const String httpDigest = 'NSURLAuthenticationMethodHTTPDigest';

/// Use NTLM authentication for this protection space.
static const String httpNtlm = 'NSURLAuthenticationMethodNTLM';
}

/// A challenge from a server requiring authentication from the client.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1147,7 +1147,9 @@ class WebKitNavigationDelegate extends PlatformNavigationDelegate {
) completionHandler,
) {
if (challenge.protectionSpace.authenticationMethod ==
NSUrlAuthenticationMethod.httpBasic) {
NSUrlAuthenticationMethod.httpBasic ||
challenge.protectionSpace.authenticationMethod ==
NSUrlAuthenticationMethod.httpNtlm) {
final void Function(HttpAuthRequest)? callback =
weakThis.target?._onHttpAuthRequest;
final String? host = challenge.protectionSpace.host;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ name: webview_flutter_wkwebview
description: A Flutter plugin that provides a WebView widget based on Apple's WKWebView control.
repository: https://github.com/flutter/packages/tree/main/packages/webview_flutter/webview_flutter_wkwebview
issue_tracker: https://github.com/flutter/flutter/issues?q=is%3Aissue+is%3Aopen+label%3A%22p%3A+webview%22
version: 3.15.0
version: 3.16.0

environment:
sdk: ^3.5.0
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -309,6 +309,44 @@ void main() {
expect(callbackHost, expectedHost);
expect(callbackRealm, expectedRealm);
});

test('onHttpNtlmAuthRequest emits host and realm', () {
final WebKitNavigationDelegate iosNavigationDelegate =
WebKitNavigationDelegate(
const WebKitNavigationDelegateCreationParams(
webKitProxy: WebKitProxy(
createNavigationDelegate: CapturingNavigationDelegate.new,
),
),
);

String? callbackHost;
String? callbackRealm;

iosNavigationDelegate.setOnHttpAuthRequest((HttpAuthRequest request) {
callbackHost = request.host;
callbackRealm = request.realm;
});

const String expectedHost = 'expectedHost';
const String expectedRealm = 'expectedRealm';

CapturingNavigationDelegate
.lastCreatedDelegate.didReceiveAuthenticationChallenge!(
WKWebViewIOS.detached(),
NSUrlAuthenticationChallenge.detached(
protectionSpace: NSUrlProtectionSpace.detached(
host: expectedHost,
realm: expectedRealm,
authenticationMethod: NSUrlAuthenticationMethod.httpNtlm,
),
),
(NSUrlSessionAuthChallengeDisposition disposition,
NSUrlCredential? credential) {});

expect(callbackHost, expectedHost);
expect(callbackRealm, expectedRealm);
});
});
}

Expand Down