-
Notifications
You must be signed in to change notification settings - Fork 3.3k
[webview_flutter] Support for handling basic authentication requests #4140
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
Conversation
9f79b3b
to
38311df
Compare
@bparrishMines should I proceed with the PR containing only the platform interface package? |
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.
This also needs an implementation for webview_flutter_wkwebview
. Using https://developer.apple.com/documentation/webkit/wknavigationdelegate/3601237-webview?language=objc I believe.
@@ -30,6 +30,9 @@ typedef WebResourceErrorCallback = void Function(WebResourceError error); | |||
/// url of the web view. | |||
typedef UrlChangeCallback = void Function(UrlChange change); | |||
|
|||
/// Signature for callbacks that report basic auth events by the native web view |
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.
nit:
/// Signature for callbacks that report basic auth events by the native web view | |
/// Signature for callbacks that report basic auth events by the native web view. |
@@ -261,6 +261,13 @@ abstract class PlatformWebViewController extends PlatformInterface { | |||
'setUserAgent is not implemented on the current platform'); | |||
} | |||
|
|||
/// Sets the auth credentials for basic authentication and can be used on onReceiveHttpAuthRequest with NavigationDelegate. |
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.
nit:
/// Sets the auth credentials for basic authentication and can be used on onReceiveHttpAuthRequest with NavigationDelegate. | |
/// Sets the auth credentials for basic authentication and can be used with | |
/// [PlatformNavigationDelegate.onReceiveHttpAuthRequest]. |
@@ -95,6 +98,13 @@ public void doUpdateVisitedHistory( | |||
flutterApi.doUpdateVisitedHistory(this, view, url, isReload, reply -> {}); | |||
} | |||
|
|||
@Override | |||
public void onReceivedHttpAuthRequest( | |||
@NonNull WebView view, HttpAuthHandler handler, String host, String realm) { |
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 FlutterAPI should pass back the HttpAuthHandler
instead of adding a setAuthCredentials
method. Mainly because the HttpAuthHandler
has multiple methods that could be used. e.g. cancel
and useHttpAuthUsernamePassword.
Hey @bparrishMines , @JeroenWeener will be taking over for the IOS implementation of this PR. |
38311df
to
3fb8d80
Compare
: nil; | ||
|
||
completionHandler(disposition, credential); | ||
} |
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.
When there is an error, don't we also need to call completionHandler
in production?
Thank @stuartmorgan and @bparrishMines for merging the related PRs. The final PR that exposes the iOS and Android implementations can be found here: #5727. @andreisas06 could you close this PR? |
…(iOS) (flutter#5455) Adds the iOS implementation for basic http authentication. This PR is part of a series of PRs that aim to close flutter/flutter#83556. The PR that contains all changes can be found at flutter#4140.
@bparrishMines and @stuartmorgan can this be closed in favor of #5727 (review) and friends? Seems like this is zombied. |
…(Platform Interface) (flutter#5362) Adds the platform interface implementation for basic http authentication. This PR is part of a series of PRs that aim to close flutter/flutter#83556. The PR that contains all changes can be found at flutter#4140.
…(Android) (flutter#5454) Adds the Android implementation for basic http authentication. This PR is part of a series of PRs that aim to close flutter/flutter#83556. The PR that contains all changes can be found at flutter#4140.
…(iOS) (flutter#5455) Adds the iOS implementation for basic http authentication. This PR is part of a series of PRs that aim to close flutter/flutter#83556. The PR that contains all changes can be found at flutter#4140.
…(iOS) (#5455) Adds the iOS implementation for basic http authentication. This PR is part of a series of PRs that aim to close flutter/flutter#83556. The PR that contains all changes can be found at flutter/packages#4140.
Description
This pull request introduces the handling of HTTP Basic Authentication in our WebView implementation. Specifically, it includes the following changes:
Issues fixed by PR:
Closes flutter/flutter#83556
Pre-launch Checklist
dart format
.)[shared_preferences]
pubspec.yaml
with an appropriate new version according to the [pub versioning philosophy], or this PR is [exempt from version changes].CHANGELOG.md
to add a description of the change, [following repository CHANGELOG style].///
).