Changeset 220805 in webkit


Ignore:
Timestamp:
Aug 16, 2017 1:20:56 PM (7 years ago)
Author:
eric.carlson@apple.com
Message:

Consider allow gUM to be called from localhost without https
https://bugs.webkit.org/show_bug.cgi?id=173457
<rdar://problem/33900527>

Reviewed by Youenn Fablet.

Source/WebCore:

Tests: http/tests/media/media-stream/get-user-media-localhost.html

http/tests/media/media-stream/get-user-media-loopback-ip.html

  • Modules/mediastream/UserMediaRequest.cpp:

(WebCore::isSecure): Call SchemeRegistry::shouldTreatURLSchemeAsSecure instead of looking for
the string 'https'.
(WebCore::canCallGetUserMedia): Allow localhost or loopback address.

  • page/SecurityOrigin.cpp:

(WebCore::isLoopbackIPAddress): Add a comment.
(WebCore::shouldTreatAsPotentionallyTrustworthy): Move tests for localhost and loopback address
to isLocalHostOrLoopbackIPAddress, call it.
(WebCore::SecurityOrigin::isLocalHostOrLoopbackIPAddress):

  • page/SecurityOrigin.h:

LayoutTests:

  • http/tests/media/media-stream/get-user-media-localhost-expected.txt: Added.
  • http/tests/media/media-stream/get-user-media-localhost.html: Added.
  • http/tests/media/media-stream/get-user-media-loopback-ip-expected.txt: Added.
  • http/tests/media/media-stream/get-user-media-loopback-ip.html: Added.
Location:
trunk
Files:
4 added
5 edited

Legend:

Unmodified
Added
Removed
  • trunk/LayoutTests/ChangeLog

    r220804 r220805  
     12017-08-16  Eric Carlson  <eric.carlson@apple.com>
     2
     3        Consider allow gUM to be called from localhost without https
     4        https://bugs.webkit.org/show_bug.cgi?id=173457
     5        <rdar://problem/33900527>
     6
     7        Reviewed by Youenn Fablet.
     8
     9        * http/tests/media/media-stream/get-user-media-localhost-expected.txt: Added.
     10        * http/tests/media/media-stream/get-user-media-localhost.html: Added.
     11        * http/tests/media/media-stream/get-user-media-loopback-ip-expected.txt: Added.
     12        * http/tests/media/media-stream/get-user-media-loopback-ip.html: Added.
     13
    1142017-08-16  Ryan Haddad  <ryanhaddad@apple.com>
    215
  • trunk/Source/WebCore/ChangeLog

    r220799 r220805  
     12017-08-16  Eric Carlson  <eric.carlson@apple.com>
     2
     3        Consider allow gUM to be called from localhost without https
     4        https://bugs.webkit.org/show_bug.cgi?id=173457
     5        <rdar://problem/33900527>
     6
     7        Reviewed by Youenn Fablet.
     8
     9        Tests: http/tests/media/media-stream/get-user-media-localhost.html
     10               http/tests/media/media-stream/get-user-media-loopback-ip.html
     11
     12        * Modules/mediastream/UserMediaRequest.cpp:
     13        (WebCore::isSecure): Call SchemeRegistry::shouldTreatURLSchemeAsSecure instead of looking for
     14        the string 'https'.
     15        (WebCore::canCallGetUserMedia): Allow localhost or loopback address.
     16
     17        * page/SecurityOrigin.cpp:
     18        (WebCore::isLoopbackIPAddress): Add a comment.
     19        (WebCore::shouldTreatAsPotentionallyTrustworthy): Move tests for localhost and loopback address
     20        to isLocalHostOrLoopbackIPAddress, call it.
     21        (WebCore::SecurityOrigin::isLocalHostOrLoopbackIPAddress):
     22        * page/SecurityOrigin.h:
     23
    1242017-08-16  Chris Dumez  <cdumez@apple.com>
    225
  • trunk/Source/WebCore/Modules/mediastream/UserMediaRequest.cpp

    r219856 r220805  
    22 * Copyright (C) 2011 Ericsson AB. All rights reserved.
    33 * Copyright (C) 2012 Google Inc. All rights reserved.
    4  * Copyright (C) 2013-2016 Apple Inc. All rights reserved.
     4 * Copyright (C) 2013-2017 Apple Inc. All rights reserved.
    55 * Copyright (C) 2013 Nokia Corporation and/or its subsidiary(-ies).
    66 *
     
    4545#include "MediaConstraints.h"
    4646#include "RealtimeMediaSourceCenter.h"
     47#include "SchemeRegistry.h"
    4748#include "Settings.h"
    4849#include "UserMediaController.h"
     
    9596{
    9697    auto& response = documentLoader.response();
    97     return response.url().protocolIs("https")
     98    return SchemeRegistry::shouldTreatURLSchemeAsSecure(response.url().protocol().toStringWithoutCopying())
    9899        && response.certificateInfo()
    99100        && !response.certificateInfo()->containsNonRootSHA1SignedCertificate();
     
    103104{
    104105    bool requiresSecureConnection = document.settings().mediaCaptureRequiresSecureConnection();
    105     if (requiresSecureConnection && !isSecure(*document.loader())) {
     106    auto& documentLoader = *document.loader();
     107    if (requiresSecureConnection && !isSecure(documentLoader) && !SecurityOrigin::isLocalHostOrLoopbackIPAddress(documentLoader.response().url())) {
    106108        errorMessage = "Trying to call getUserMedia from an insecure document.";
    107109        return false;
  • trunk/Source/WebCore/page/SecurityOrigin.cpp

    r218028 r220805  
    102102static bool isLoopbackIPAddress(const URL& url)
    103103{
     104    // The IPv6 loopback address is 0:0:0:0:0:0:0:1, which compresses to ::1.
    104105    ASSERT(url.isValid());
    105106    auto host = url.host();
     
    131132        return true;
    132133
    133     if (isLoopbackIPAddress(url))
    134         return true;
    135 
    136     // FIXME: Ensure that localhost resolves to the loopback address.
    137     if (equalLettersIgnoringASCIICase(url.host(), "localhost"))
     134    if (SecurityOrigin::isLocalHostOrLoopbackIPAddress(url))
    138135        return true;
    139136
     
    588585}
    589586
     587bool SecurityOrigin::isLocalHostOrLoopbackIPAddress(const URL& url)
     588{
     589    if (isLoopbackIPAddress(url))
     590        return true;
     591
     592    // FIXME: Ensure that localhost resolves to the loopback address.
     593    if (equalLettersIgnoringASCIICase(url.host(), "localhost"))
     594        return true;
     595
     596    return false;
     597}
     598
    590599} // namespace WebCore
  • trunk/Source/WebCore/page/SecurityOrigin.h

    r220497 r220805  
    203203    bool isPotentionallyTrustworthy() const { return m_isPotentionallyTrustworthy; }
    204204
     205    static bool isLocalHostOrLoopbackIPAddress(const URL&);
     206
    205207private:
    206208    SecurityOrigin();
Note: See TracChangeset for help on using the changeset viewer.