Changeset 258961 in webkit


Ignore:
Timestamp:
Mar 24, 2020 5:03:19 PM (4 years ago)
Author:
jiewen_tan@apple.com
Message:

[WebAuthn] Customize a bit more on the macOS LocalAuthentication prompt
https://bugs.webkit.org/show_bug.cgi?id=208703
<rdar://problem/60136974>

Reviewed by Brent Fulgham.

Part 2.

This patch adds a different LocalAuthentication prompt title for getAssertion.
It also polishes the text used for makeCredential.

Besides that, it also enhances the iOS title strings.

Source/WebCore:

  • en.lproj/Localizable.strings:
  • platform/LocalizedStrings.cpp:

(WebCore::getAssertionTouchIDPromptTitle):

  • platform/LocalizedStrings.h:

Source/WebKit:

  • UIProcess/WebAuthentication/Cocoa/LocalAuthenticator.mm:

(WebKit::LocalAuthenticator::continueMakeCredentialAfterDecidePolicy):
(WebKit::LocalAuthenticator::continueGetAssertionAfterResponseSelected):

  • UIProcess/WebAuthentication/Cocoa/LocalConnection.h:
  • UIProcess/WebAuthentication/Cocoa/LocalConnection.mm:

(WebKit::LocalConnection::verifyUser const):

  • UIProcess/WebAuthentication/Mock/MockLocalConnection.h:
  • UIProcess/WebAuthentication/Mock/MockLocalConnection.mm:

(WebKit::MockLocalConnection::verifyUser const):

Location:
trunk/Source
Files:
13 edited
1 copied

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebCore/ChangeLog

    r258959 r258961  
     12020-03-24  Jiewen Tan  <jiewen_tan@apple.com>
     2
     3        [WebAuthn] Customize a bit more on the macOS LocalAuthentication prompt
     4        https://bugs.webkit.org/show_bug.cgi?id=208703
     5        <rdar://problem/60136974>
     6
     7        Reviewed by Brent Fulgham.
     8
     9        Part 2.
     10
     11        This patch adds a different LocalAuthentication prompt title for getAssertion.
     12        It also polishes the text used for makeCredential.
     13
     14        Besides that, it also enhances the iOS title strings.
     15
     16        * en.lproj/Localizable.strings:
     17        * platform/LocalizedStrings.cpp:
     18        (WebCore::getAssertionTouchIDPromptTitle):
     19        * platform/LocalizedStrings.h:
     20
    1212020-03-24  Chris Dumez  <cdumez@apple.com>
    222
  • trunk/Source/WebCore/en.lproj/Localizable.strings

    r258442 r258961  
     1/* Allow the specified bundle to use Touch ID to sign in to the specified website on this device */
     2"“%@” would like to use Touch ID for “%@”." = "“%@” would like to use Touch ID for “%@”.";
     3
     4/* "Allow the specified bundle to sign in to the specified website */
     5"“%@” would like to sign in to “%@”." = "“%@” would like to sign in to “%@”.";
     6
    17/* accessibility help text for media controller time value >= 1 day */
    28"%1$d days %2$d hours %3$d minutes %4$d seconds" = "%1$d days %2$d hours %3$d minutes %4$d seconds";
     
    314320"Enter Full Screen" = "Enter Full Screen";
    315321
    316 /* Use passcode as a fallback to sign into this website */
    317 "Enter passcode to sign into this website." = "Enter passcode to sign into this website.";
    318 
    319322/* menu item */
    320323"Enter Picture in Picture" = "Enter Picture in Picture";
     
    866869"This website may try to trick you into installing software that harms your browsing experience, like changing your settings without your permission or showing you unwanted ads. Once installed, it may be difficult to remove." = "This website may try to trick you into installing software that harms your browsing experience, like changing your settings without your permission or showing you unwanted ads. Once installed, it may be difficult to remove.";
    867870
     871/* This website would like to use Touch ID */
     872"This website would like to use Touch ID." = "This website would like to use Touch ID.";
     873
    868874/* Informative text for requesting cross-site cookie and website data access. */
    869875"This will allow “%@” to track your activity." = "This will allow “%@” to track your activity.";
     
    884890"To view this page, you must log in to this area on %@:" = "To view this page, you must log in to this area on %@:";
    885891
    886 /* Use Touch ID to sign into this website */
    887 "Touch ID to sign into this website." = "Touch ID to sign into this website.";
    888 
    889 /* Allow using Touch ID to sign into the specified website on this device */
    890 "Touch ID to allow signing into “%@” with Touch ID." = "Touch ID to allow signing into “%@” with Touch ID.";
     892/* Use Touch ID to sign in to this website */
     893"Touch ID to sign in to this website." = "Touch ID to sign in to this website.";
    891894
    892895/* Transformations context sub-menu item */
  • trunk/Source/WebCore/platform/LocalizedStrings.cpp

    r258442 r258961  
    12091209
    12101210#if ENABLE(WEB_AUTHN)
    1211 String genericTouchIDPromptTitle()
    1212 {
    1213     return WEB_UI_STRING("Touch ID to sign into this website.", "Use Touch ID to sign into this website");
    1214 }
    1215 
    1216 String makeCredentialTouchIDPromptTitle(const String& domain)
    1217 {
    1218     return formatLocalizedString(WEB_UI_CFSTRING("Touch ID to allow signing into “%@” with Touch ID.", "Allow using Touch ID to sign into the specified website on this device"), domain.createCFString().get());
    1219 }
    1220 
    1221 String biometricFallbackPromptTitle()
    1222 {
    1223     return WEB_UI_STRING("Enter passcode to sign into this website.", "Use passcode as a fallback to sign into this website");
    1224 }
    1225 #endif
     1211// On macOS, Touch ID prompt is not guaranteed to show on top of the UI client, and therefore additional
     1212// information is provided to help users to make decisions.
     1213#if PLATFORM(MAC)
     1214String makeCredentialTouchIDPromptTitle(const String& bundleName, const String& domain)
     1215{
     1216    return formatLocalizedString(WEB_UI_CFSTRING("“%@” would like to use Touch ID for “%@”.", "Allow the specified bundle to use Touch ID to sign in to the specified website on this device"), bundleName.createCFString().get(), domain.createCFString().get());
     1217}
     1218
     1219String getAssertionTouchIDPromptTitle(const String& bundleName, const String& domain)
     1220{
     1221    return formatLocalizedString(WEB_UI_CFSTRING("“%@” would like to sign in to “%@”.", "Allow the specified bundle to sign in to the specified website"), bundleName.createCFString().get(), domain.createCFString().get());
     1222}
     1223#else
     1224String makeCredentialTouchIDPromptTitle(const String&, const String&)
     1225{
     1226    return WEB_UI_STRING("This website would like to use Touch ID.", "This website would like to use Touch ID");
     1227}
     1228
     1229String getAssertionTouchIDPromptTitle(const String&, const String&)
     1230{
     1231    return WEB_UI_STRING("Touch ID to sign in to this website.", "Use Touch ID to sign in to this website");
     1232}
     1233#endif // PLATFORM(MAC)
     1234#endif // ENABLE(WEB_AUTHN)
    12261235
    12271236} // namespace WebCore
  • trunk/Source/WebCore/platform/LocalizedStrings.h

    r258442 r258961  
    341341
    342342#if ENABLE(WEB_AUTHN)
    343     WEBCORE_EXPORT String genericTouchIDPromptTitle();
    344     WEBCORE_EXPORT String makeCredentialTouchIDPromptTitle(const String& domain);
    345     WEBCORE_EXPORT String biometricFallbackPromptTitle();
     343    WEBCORE_EXPORT String makeCredentialTouchIDPromptTitle(const String& bundleName, const String& domain);
     344    WEBCORE_EXPORT String getAssertionTouchIDPromptTitle(const String& bundleName, const String& domain);
    346345#endif
    347346
  • trunk/Source/WebKit/ChangeLog

    r258958 r258961  
     12020-03-24  Jiewen Tan  <jiewen_tan@apple.com>
     2
     3        [WebAuthn] Customize a bit more on the macOS LocalAuthentication prompt
     4        https://bugs.webkit.org/show_bug.cgi?id=208703
     5        <rdar://problem/60136974>
     6
     7        Reviewed by Brent Fulgham.
     8
     9        Part 2.
     10
     11        This patch adds a different LocalAuthentication prompt title for getAssertion.
     12        It also polishes the text used for makeCredential.
     13
     14        Besides that, it also enhances the iOS title strings.
     15
     16        * UIProcess/WebAuthentication/Cocoa/LocalAuthenticator.mm:
     17        (WebKit::LocalAuthenticator::continueMakeCredentialAfterDecidePolicy):
     18        (WebKit::LocalAuthenticator::continueGetAssertionAfterResponseSelected):
     19        * UIProcess/WebAuthentication/Cocoa/LocalConnection.h:
     20        * UIProcess/WebAuthentication/Cocoa/LocalConnection.mm:
     21        (WebKit::LocalConnection::verifyUser const):
     22        * UIProcess/WebAuthentication/Mock/MockLocalConnection.h:
     23        * UIProcess/WebAuthentication/Mock/MockLocalConnection.mm:
     24        (WebKit::MockLocalConnection::verifyUser const):
     25
    1262020-03-24  Kate Cheney  <katherine_cheney@apple.com>
    227
  • trunk/Source/WebKit/Sources.txt

    r258734 r258961  
    470470UIProcess/WebAuthentication/Authenticator.cpp
    471471UIProcess/WebAuthentication/WebAuthenticatorCoordinatorProxy.cpp
     472UIProcess/WebAuthentication/WebAuthenticationRequestData.cpp
    472473
    473474UIProcess/WebsiteData/WebDeviceOrientationAndMotionAccessController.cpp
  • trunk/Source/WebKit/UIProcess/WebAuthentication/AuthenticatorManager.cpp

    r257954 r258961  
    144144}
    145145
    146 static ClientDataType getClientDataType(const Variant<PublicKeyCredentialCreationOptions, PublicKeyCredentialRequestOptions>& options)
    147 {
    148     if (WTF::holds_alternative<PublicKeyCredentialCreationOptions>(options))
    149         return ClientDataType::Create;
    150     return ClientDataType::Get;
    151 }
    152 
    153146} // namespace
    154147
  • trunk/Source/WebKit/UIProcess/WebAuthentication/Cocoa/LocalAuthenticator.mm

    r258602 r258961  
    264264        weakThis->continueMakeCredentialAfterUserVerification(accessControl.get(), verification, context);
    265265    };
    266     m_connection->verifyUser(creationOptions.rp.id, accessControlRef, WTFMove(callback));
     266    m_connection->verifyUser(creationOptions.rp.id, getClientDataType(requestData().options), accessControlRef, WTFMove(callback));
    267267}
    268268
     
    492492        weakThis->continueGetAssertionAfterUserVerification(WTFMove(response), verification, context);
    493493    };
    494     m_connection->verifyUser(requestOptions.rpId, accessControlRef, WTFMove(callback));
     494    m_connection->verifyUser(requestOptions.rpId, getClientDataType(requestData().options), accessControlRef, WTFMove(callback));
    495495}
    496496
  • trunk/Source/WebKit/UIProcess/WebAuthentication/Cocoa/LocalConnection.h

    r258442 r258961  
    3838namespace WebCore {
    3939class AuthenticatorAssertionResponse;
     40enum class ClientDataType : bool;
    4041}
    4142
     
    6061
    6162    LocalConnection() = default;
     63    // FIXME(183534): Invalidate the LAContext.
    6264    virtual ~LocalConnection() = default;
    6365
    6466    // Overrided by MockLocalConnection.
    65     virtual void verifyUser(const String& rpId, SecAccessControlRef, UserVerificationCallback&&) const;
     67    virtual void verifyUser(const String& rpId, WebCore::ClientDataType, SecAccessControlRef, UserVerificationCallback&&) const;
    6668    virtual RetainPtr<SecKeyRef> createCredentialPrivateKey(LAContext *, SecAccessControlRef, const String& secAttrLabel, NSData *secAttrApplicationTag) const;
    6769    virtual void getAttestation(SecKeyRef, NSData *authData, NSData *hash, AttestationCallback&&) const;
  • trunk/Source/WebKit/UIProcess/WebAuthentication/Cocoa/LocalConnection.mm

    r258442 r258961  
    4040
    4141namespace WebKit {
     42using namespace WebCore;
    4243
    43 void LocalConnection::verifyUser(const String& rpId, SecAccessControlRef accessControl, UserVerificationCallback&& completionHandler) const
     44namespace {
     45static String bundleName()
    4446{
     47    String bundleName;
     48
     49#if PLATFORM(MAC)
     50    bundleName = [[NSRunningApplication currentApplication] localizedName];
     51#endif
     52
     53    return bundleName;
     54}
     55} // namespace
     56
     57void LocalConnection::verifyUser(const String& rpId, ClientDataType type, SecAccessControlRef accessControl, UserVerificationCallback&& completionHandler) const
     58{
     59    String title;
     60    switch (type) {
     61    case ClientDataType::Create:
     62        title = makeCredentialTouchIDPromptTitle(bundleName(), rpId);
     63        break;
     64    case ClientDataType::Get:
     65        title = getAssertionTouchIDPromptTitle(bundleName(), rpId);
     66        break;
     67    default:
     68        ASSERT_NOT_REACHED();
     69    }
     70
    4571    auto context = adoptNS([allocLAContextInstance() init]);
    4672
    4773    auto options = adoptNS([[NSMutableDictionary alloc] init]);
    4874    if ([context biometryType] == LABiometryTypeTouchID) {
    49 #if PLATFORM(IOS)
    50         [options setObject:WebCore::genericTouchIDPromptTitle() forKey:@(LAOptionAuthenticationTitle)];
    51         ASSERT_UNUSED(rpId, rpId);
    52 #else
    53         [options setObject:WebCore::makeCredentialTouchIDPromptTitle(rpId) forKey:@(LAOptionAuthenticationTitle)];
    54 #endif
     75        [options setObject:title forKey:@(LAOptionAuthenticationTitle)];
    5576        [options setObject:@NO forKey:@(LAOptionFallbackVisible)];
    5677    }
    57 #if PLATFORM(IOS)
    58     [options setObject:WebCore::biometricFallbackPromptTitle() forKey:@(LAOptionPasscodeTitle)];
    59 #endif
    6078
    6179    auto reply = makeBlockPtr([context, completionHandler = WTFMove(completionHandler)] (NSDictionary *, NSError *error) mutable {
  • trunk/Source/WebKit/UIProcess/WebAuthentication/Mock/MockLocalConnection.h

    r258442 r258961  
    3838
    3939private:
    40     void verifyUser(const String&, SecAccessControlRef, UserVerificationCallback&&) const final;
     40    void verifyUser(const String&, WebCore::ClientDataType, SecAccessControlRef, UserVerificationCallback&&) const final;
    4141    RetainPtr<SecKeyRef> createCredentialPrivateKey(LAContext *, SecAccessControlRef, const String& secAttrLabel, NSData *secAttrApplicationTag) const final;
    4242    void getAttestation(SecKeyRef, NSData *authData, NSData *hash, AttestationCallback&&) const final;
  • trunk/Source/WebKit/UIProcess/WebAuthentication/Mock/MockLocalConnection.mm

    r258442 r258961  
    4545}
    4646
    47 void MockLocalConnection::verifyUser(const String&, SecAccessControlRef, UserVerificationCallback&& callback) const
     47void MockLocalConnection::verifyUser(const String&, WebCore::ClientDataType, SecAccessControlRef, UserVerificationCallback&& callback) const
    4848{
    4949    // Mock async operations.
  • trunk/Source/WebKit/UIProcess/WebAuthentication/WebAuthenticationRequestData.cpp

    r258960 r258961  
    11/*
    2  * Copyright (C) 2018 Apple Inc. All rights reserved.
     2 * Copyright (C) 2020 Apple Inc. All rights reserved.
    33 *
    44 * Redistribution and use in source and binary forms, with or without
     
    2424 */
    2525
    26 #pragma once
     26#include "config.h"
     27#include "WebAuthenticationRequestData.h"
    2728
    2829#if ENABLE(WEB_AUTHN)
    2930
    30 #include "LocalConnection.h"
    31 #include <WebCore/MockWebAuthenticationConfiguration.h>
     31namespace WebKit {
     32using namespace WebCore;
    3233
    33 namespace WebKit {
    34 
    35 class MockLocalConnection final : public LocalConnection {
    36 public:
    37     explicit MockLocalConnection(const WebCore::MockWebAuthenticationConfiguration&);
    38 
    39 private:
    40     void verifyUser(const String&, SecAccessControlRef, UserVerificationCallback&&) const final;
    41     RetainPtr<SecKeyRef> createCredentialPrivateKey(LAContext *, SecAccessControlRef, const String& secAttrLabel, NSData *secAttrApplicationTag) const final;
    42     void getAttestation(SecKeyRef, NSData *authData, NSData *hash, AttestationCallback&&) const final;
    43     void filterResponses(HashSet<Ref<WebCore::AuthenticatorAssertionResponse>>&) const final;
    44 
    45     WebCore::MockWebAuthenticationConfiguration m_configuration;
    46 };
     34ClientDataType getClientDataType(const Variant<PublicKeyCredentialCreationOptions, PublicKeyCredentialRequestOptions>& options)
     35{
     36    if (WTF::holds_alternative<PublicKeyCredentialCreationOptions>(options))
     37        return ClientDataType::Create;
     38    return ClientDataType::Get;
     39}
    4740
    4841} // namespace WebKit
  • trunk/Source/WebKit/UIProcess/WebAuthentication/WebAuthenticationRequestData.h

    r257571 r258961  
    3434#include <WebCore/PublicKeyCredentialCreationOptions.h>
    3535#include <WebCore/PublicKeyCredentialRequestOptions.h>
     36#include <WebCore/WebAuthenticationConstants.h>
    3637#include <wtf/Variant.h>
    3738#include <wtf/Vector.h>
     
    5253};
    5354
     55WebCore::ClientDataType getClientDataType(const Variant<WebCore::PublicKeyCredentialCreationOptions, WebCore::PublicKeyCredentialRequestOptions>&);
     56
    5457} // namespace WebKit
    5558
Note: See TracChangeset for help on using the changeset viewer.