IWithAuth.cs 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  1. // Copyright (c) 2024 Vuplex Inc. All rights reserved.
  2. //
  3. // Licensed under the Vuplex Commercial Software Library License, you may
  4. // not use this file except in compliance with the License. You may obtain
  5. // a copy of the License at
  6. //
  7. // https://vuplex.com/commercial-library-license
  8. //
  9. // Unless required by applicable law or agreed to in writing, software
  10. // distributed under the License is distributed on an "AS IS" BASIS,
  11. // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  12. // See the License for the specific language governing permissions and
  13. // limitations under the License.
  14. using System;
  15. namespace Vuplex.WebView {
  16. /// <summary>
  17. /// An interface implemented by a webview if it supports entering credentials for [HTTP authentication](https://developer.mozilla.org/en-US/docs/Web/HTTP/Authentication)
  18. /// and/or connecting to a proxy server.
  19. /// </summary>
  20. public interface IWithAuth {
  21. /// <summary>
  22. /// Indicates that the browser has requested credentials from the user, either because a server requested [HTTP authentication](https://developer.mozilla.org/en-US/docs/Web/HTTP/Authentication)
  23. /// or because credentials are needed for connecting to a proxy server.
  24. /// </summary>
  25. /// <remarks>
  26. /// If no handler is attached to this event, then the host's authentication request will be ignored
  27. /// and the page will not be paused. If a handler is attached to this event, then the page will
  28. /// be paused until Continue() or Cancel() is called.
  29. ///
  30. /// You can test basic HTTP auth using [this page](https://jigsaw.w3.org/HTTP/Basic/)
  31. /// with the username "guest" and the password "guest".
  32. /// </remarks>
  33. /// <remarks>
  34. /// This event is not raised for most websites because most sites implement a custom sign-in page
  35. /// instead of using HTTP authentication to show the browser's built-in authentication UI.
  36. /// </remarks>
  37. /// <example>
  38. /// <code>
  39. /// await webViewPrefab.WaitUntilInitialized();
  40. /// var webViewWithAuth = webViewPrefab.WebView as IWithAuth;
  41. /// if (webViewWithAuth == null) {
  42. /// Debug.Log("This 3D WebView plugin doesn't yet support IWithAuth: " + webViewPrefab.WebView.PluginType);
  43. /// return;
  44. /// }
  45. /// webViewWithAuth.AuthRequested += (sender, eventArgs) => {
  46. /// Debug.Log("Auth requested by " + eventArgs.Host);
  47. /// eventArgs.Continue("myUsername", "myPassword");
  48. /// };
  49. /// </code>
  50. /// </example>
  51. event EventHandler<AuthRequestedEventArgs> AuthRequested;
  52. }
  53. // Renamed in v4.8.
  54. [Obsolete("The IWithHttpAuth interface has been renamed to IWithAuth. Please use IWithAuth instead.", true)]
  55. public interface IWithHttpAuth {}
  56. }