Changeset 263645 in webkit


Ignore:
Timestamp:
Jun 29, 2020 12:39:36 AM (4 years ago)
Author:
Carlos Garcia Campos
Message:

[GTK][WPE] Add webkit_authentication_request_get_security_origin
https://bugs.webkit.org/show_bug.cgi?id=213596

Reviewed by Michael Catanzaro.

Source/WebKit:

Returns the security origin for the authentication protection space.

  • UIProcess/API/glib/WebKitAuthenticationRequest.cpp:

(webkit_authentication_request_get_security_origin):

  • UIProcess/API/gtk/WebKitAuthenticationRequest.h:
  • UIProcess/API/gtk/docs/webkit2gtk-4.0-sections.txt:
  • UIProcess/API/wpe/WebKitAuthenticationRequest.h:
  • UIProcess/API/wpe/docs/wpe-1.0-sections.txt:

Tools:

Update the unit tests to check the new API.

  • TestWebKitAPI/Tests/WebKitGLib/TestAuthentication.cpp:

(testWebViewAuthenticationRequest):
(testWebViewAuthenticationProxy):
(testWebViewAuthenticationProxyHTTPS):

Location:
trunk
Files:
8 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebKit/ChangeLog

    r263644 r263645  
     12020-06-29  Carlos Garcia Campos  <cgarcia@igalia.com>
     2
     3        [GTK][WPE] Add webkit_authentication_request_get_security_origin
     4        https://bugs.webkit.org/show_bug.cgi?id=213596
     5
     6        Reviewed by Michael Catanzaro.
     7
     8        Returns the security origin for the authentication protection space.
     9
     10        * UIProcess/API/glib/WebKitAuthenticationRequest.cpp:
     11        (webkit_authentication_request_get_security_origin):
     12        * UIProcess/API/gtk/WebKitAuthenticationRequest.h:
     13        * UIProcess/API/gtk/docs/webkit2gtk-4.0-sections.txt:
     14        * UIProcess/API/wpe/WebKitAuthenticationRequest.h:
     15        * UIProcess/API/wpe/docs/wpe-1.0-sections.txt:
     16
    1172020-06-29  Alexander Mikhaylenko  <alexm@gnome.org>
    218
  • trunk/Source/WebKit/UIProcess/API/glib/WebKitAuthenticationRequest.cpp

    r263444 r263645  
    2626#include "WebKitAuthenticationRequestPrivate.h"
    2727#include "WebKitCredentialPrivate.h"
     28#include "WebKitSecurityOriginPrivate.h"
    2829#include "WebProtectionSpace.h"
    2930#include <WebCore/AuthenticationChallenge.h>
     
    330331
    331332/**
     333 * webkit_authentication_request_get_security_origin:
     334 * @request: a #WebKitAuthenticationRequest
     335 *
     336 * Get the #WebKitSecurityOrigin that this authentication challenge is applicable to.
     337 *
     338 * Returns: (transfer full): a newly created #WebKitSecurityOrigin.
     339 *
     340 * Since: 2.30
     341 */
     342WebKitSecurityOrigin* webkit_authentication_request_get_security_origin(WebKitAuthenticationRequest* request)
     343{
     344    g_return_val_if_fail(WEBKIT_IS_AUTHENTICATION_REQUEST(request), nullptr);
     345
     346    const auto& protectionSpace = request->priv->authenticationChallenge->core().protectionSpace();
     347    String protocol;
     348    switch (protectionSpace.serverType()) {
     349    case ProtectionSpaceServerHTTP:
     350    case ProtectionSpaceProxyHTTP:
     351        protocol = "http"_s;
     352        break;
     353    case ProtectionSpaceServerHTTPS:
     354    case ProtectionSpaceProxyHTTPS:
     355        protocol = "https"_s;
     356        break;
     357    case ProtectionSpaceServerFTP:
     358    case ProtectionSpaceProxyFTP:
     359        protocol = "ftp"_s;
     360        break;
     361    case ProtectionSpaceServerFTPS:
     362        protocol = "ftps"_s;
     363        break;
     364    case ProtectionSpaceProxySOCKS:
     365        protocol = "socks"_s;
     366        break;
     367    }
     368    return webkitSecurityOriginCreate(SecurityOrigin::create(protocol, protectionSpace.host(), protectionSpace.port()));
     369}
     370
     371/**
    332372 * webkit_authentication_request_get_realm:
    333373 * @request: a #WebKitAuthenticationRequest
  • trunk/Source/WebKit/UIProcess/API/gtk/WebKitAuthenticationRequest.h

    r263444 r263645  
    2828#include <webkit2/WebKitCredential.h>
    2929#include <webkit2/WebKitDefines.h>
     30#include <webkit2/WebKitSecurityOrigin.h>
    3031
    3132G_BEGIN_DECLS
     
    110111webkit_authentication_request_get_port                (WebKitAuthenticationRequest *request);
    111112
     113WEBKIT_API WebKitSecurityOrigin *
     114webkit_authentication_request_get_security_origin     (WebKitAuthenticationRequest *request);
     115
    112116WEBKIT_API const gchar *
    113117webkit_authentication_request_get_realm               (WebKitAuthenticationRequest *request);
  • trunk/Source/WebKit/UIProcess/API/gtk/docs/webkit2gtk-4.0-sections.txt

    r263444 r263645  
    349349webkit_authentication_request_get_host
    350350webkit_authentication_request_get_port
     351webkit_authentication_request_get_security_origin
    351352webkit_authentication_request_is_retry
    352353webkit_authentication_request_get_proposed_credential
  • trunk/Source/WebKit/UIProcess/API/wpe/WebKitAuthenticationRequest.h

    r263444 r263645  
    2727#include <wpe/WebKitCredential.h>
    2828#include <wpe/WebKitDefines.h>
     29#include <wpe/WebKitSecurityOrigin.h>
    2930
    3031G_BEGIN_DECLS
     
    109110webkit_authentication_request_get_port                (WebKitAuthenticationRequest *request);
    110111
     112WEBKIT_API WebKitSecurityOrigin *
     113webkit_authentication_request_get_security_origin     (WebKitAuthenticationRequest *request);
     114
    111115WEBKIT_API const gchar *
    112116webkit_authentication_request_get_realm               (WebKitAuthenticationRequest *request);
  • trunk/Source/WebKit/UIProcess/API/wpe/docs/wpe-1.0-sections.txt

    r263444 r263645  
    352352webkit_authentication_request_get_host
    353353webkit_authentication_request_get_port
     354webkit_authentication_request_get_security_origin
    354355webkit_authentication_request_is_retry
    355356webkit_authentication_request_get_proposed_credential
  • trunk/Tools/ChangeLog

    r263635 r263645  
     12020-06-29  Carlos Garcia Campos  <cgarcia@igalia.com>
     2
     3        [GTK][WPE] Add webkit_authentication_request_get_security_origin
     4        https://bugs.webkit.org/show_bug.cgi?id=213596
     5
     6        Reviewed by Michael Catanzaro.
     7
     8        Update the unit tests to check the new API.
     9
     10        * TestWebKitAPI/Tests/WebKitGLib/TestAuthentication.cpp:
     11        (testWebViewAuthenticationRequest):
     12        (testWebViewAuthenticationProxy):
     13        (testWebViewAuthenticationProxyHTTPS):
     14
    1152020-06-28  Geoffrey Garen  <ggaren@apple.com>
    216
  • trunk/Tools/TestWebKitAPI/Tests/WebKitGLib/TestAuthentication.cpp

    r263444 r263645  
    135135    g_assert_false(webkit_authentication_request_is_for_proxy(request));
    136136    g_assert_false(webkit_authentication_request_is_retry(request));
     137    auto* origin = webkit_authentication_request_get_security_origin(request);
     138    g_assert_nonnull(origin);
     139    g_assert_cmpstr(webkit_security_origin_get_protocol(origin), ==, soup_uri_get_scheme(kServer->baseURI()));
     140    g_assert_cmpstr(webkit_security_origin_get_host(origin), ==, soup_uri_get_host(kServer->baseURI()));
     141    g_assert_cmpuint(webkit_security_origin_get_port(origin), ==, soup_uri_get_port(kServer->baseURI()));
     142    webkit_security_origin_unref(origin);
    137143}
    138144
     
    463469    g_assert_true(webkit_authentication_request_is_for_proxy(request));
    464470    g_assert_false(webkit_authentication_request_is_retry(request));
     471    auto* origin = webkit_authentication_request_get_security_origin(request);
     472    g_assert_nonnull(origin);
     473    g_assert_cmpstr(webkit_security_origin_get_protocol(origin), ==, soup_uri_get_scheme(kServer->baseURI()));
     474    g_assert_cmpstr(webkit_security_origin_get_host(origin), ==, soup_uri_get_host(kServer->baseURI()));
     475    g_assert_cmpuint(webkit_security_origin_get_port(origin), ==, soup_uri_get_port(kServer->baseURI()));
     476    webkit_security_origin_unref(origin);
    465477}
    466478
     
    479491    g_assert_true(webkit_authentication_request_is_for_proxy(request));
    480492    g_assert_false(webkit_authentication_request_is_retry(request));
     493    auto* origin = webkit_authentication_request_get_security_origin(request);
     494    g_assert_nonnull(origin);
     495    g_assert_cmpstr(webkit_security_origin_get_protocol(origin), ==, soup_uri_get_scheme(httpsServer->baseURI()));
     496    g_assert_cmpstr(webkit_security_origin_get_host(origin), ==, soup_uri_get_host(httpsServer->baseURI()));
     497    g_assert_cmpuint(webkit_security_origin_get_port(origin), ==, soup_uri_get_port(httpsServer->baseURI()));
     498    webkit_security_origin_unref(origin);
    481499}
    482500
Note: See TracChangeset for help on using the changeset viewer.