Title: [258442] trunk/Source
Revision
258442
Author
jiewen_...@apple.com
Date
2020-03-13 16:15:31 -0700 (Fri, 13 Mar 2020)

Log 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 Darin Adler.

Source/WebCore:

* en.lproj/Localizable.strings:
* platform/LocalizedStrings.cpp:
(WebCore::touchIDPromptTitle):
* platform/LocalizedStrings.h:
Adds a new formatted UI string to help with RP ID.

Source/WebKit:

On macOS, LocalAuthentication prompt can be shown anywhere that is probably not on top of
our UI clients. Therefore, add a RP ID to the dialog to help users to identify what has
happened. In addition, it removes the password fallback button.

* Platform/spi/Cocoa/LocalAuthenticationSPI.h:
* 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):

Modified Paths

Diff

Modified: trunk/Source/WebCore/ChangeLog (258441 => 258442)


--- trunk/Source/WebCore/ChangeLog	2020-03-13 23:04:17 UTC (rev 258441)
+++ trunk/Source/WebCore/ChangeLog	2020-03-13 23:15:31 UTC (rev 258442)
@@ -1,3 +1,17 @@
+2020-03-13  Jiewen Tan  <jiewen_...@apple.com>
+
+        [WebAuthn] Customize a bit more on the macOS LocalAuthentication prompt
+        https://bugs.webkit.org/show_bug.cgi?id=208703
+        <rdar://problem/60136974>
+
+        Reviewed by Darin Adler.
+
+        * en.lproj/Localizable.strings:
+        * platform/LocalizedStrings.cpp:
+        (WebCore::touchIDPromptTitle):
+        * platform/LocalizedStrings.h:
+        Adds a new formatted UI string to help with RP ID.
+
 2020-03-13  Peng Liu  <peng.l...@apple.com>
 
         Safari sometimes crashes when switch video into PiP mode

Modified: trunk/Source/WebCore/en.lproj/Localizable.strings (258441 => 258442)


--- trunk/Source/WebCore/en.lproj/Localizable.strings	2020-03-13 23:04:17 UTC (rev 258441)
+++ trunk/Source/WebCore/en.lproj/Localizable.strings	2020-03-13 23:15:31 UTC (rev 258442)
@@ -886,6 +886,9 @@
 /* Use Touch ID to sign into this website */
 "Touch ID to sign into this website." = "Touch ID to sign into this website.";
 
+/* Allow using Touch ID to sign into the specified website on this device */
+"Touch ID to allow signing into “%@” with Touch ID." = "Touch ID to allow signing into “%@” with Touch ID.";
+
 /* Transformations context sub-menu item */
 "Transformations" = "Transformations";
 

Modified: trunk/Source/WebCore/platform/LocalizedStrings.cpp (258441 => 258442)


--- trunk/Source/WebCore/platform/LocalizedStrings.cpp	2020-03-13 23:04:17 UTC (rev 258441)
+++ trunk/Source/WebCore/platform/LocalizedStrings.cpp	2020-03-13 23:15:31 UTC (rev 258442)
@@ -1208,11 +1208,16 @@
 #endif
 
 #if ENABLE(WEB_AUTHN)
-String touchIDPromptTitle()
+String genericTouchIDPromptTitle()
 {
     return WEB_UI_STRING("Touch ID to sign into this website.", "Use Touch ID to sign into this website");
 }
 
+String makeCredentialTouchIDPromptTitle(const String& domain)
+{
+    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());
+}
+
 String biometricFallbackPromptTitle()
 {
     return WEB_UI_STRING("Enter passcode to sign into this website.", "Use passcode as a fallback to sign into this website");

Modified: trunk/Source/WebCore/platform/LocalizedStrings.h (258441 => 258442)


--- trunk/Source/WebCore/platform/LocalizedStrings.h	2020-03-13 23:04:17 UTC (rev 258441)
+++ trunk/Source/WebCore/platform/LocalizedStrings.h	2020-03-13 23:15:31 UTC (rev 258442)
@@ -340,7 +340,8 @@
 #endif
 
 #if ENABLE(WEB_AUTHN)
-    WEBCORE_EXPORT String touchIDPromptTitle();
+    WEBCORE_EXPORT String genericTouchIDPromptTitle();
+    WEBCORE_EXPORT String makeCredentialTouchIDPromptTitle(const String& domain);
     WEBCORE_EXPORT String biometricFallbackPromptTitle();
 #endif
 

Modified: trunk/Source/WebKit/ChangeLog (258441 => 258442)


--- trunk/Source/WebKit/ChangeLog	2020-03-13 23:04:17 UTC (rev 258441)
+++ trunk/Source/WebKit/ChangeLog	2020-03-13 23:15:31 UTC (rev 258442)
@@ -1,3 +1,26 @@
+2020-03-13  Jiewen Tan  <jiewen_...@apple.com>
+
+        [WebAuthn] Customize a bit more on the macOS LocalAuthentication prompt
+        https://bugs.webkit.org/show_bug.cgi?id=208703
+        <rdar://problem/60136974>
+
+        Reviewed by Darin Adler.
+
+        On macOS, LocalAuthentication prompt can be shown anywhere that is probably not on top of
+        our UI clients. Therefore, add a RP ID to the dialog to help users to identify what has
+        happened. In addition, it removes the password fallback button.
+
+        * Platform/spi/Cocoa/LocalAuthenticationSPI.h:
+        * 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):
+
 2020-03-13  Brent Fulgham  <bfulg...@apple.com>
 
         Remove Unused IPC message PlaybackSessionManagerProxy::PictureInPictureActiveChanged

Modified: trunk/Source/WebKit/Platform/spi/Cocoa/LocalAuthenticationSPI.h (258441 => 258442)


--- trunk/Source/WebKit/Platform/spi/Cocoa/LocalAuthenticationSPI.h	2020-03-13 23:04:17 UTC (rev 258441)
+++ trunk/Source/WebKit/Platform/spi/Cocoa/LocalAuthenticationSPI.h	2020-03-13 23:15:31 UTC (rev 258442)
@@ -36,6 +36,7 @@
 typedef NS_ENUM(NSInteger, LAOption) {
     LAOptionAuthenticationTitle,
     LAOptionPasscodeTitle,
+    LAOptionFallbackVisible,
 };
 
 @interface LAContext(Private) <NSSecureCoding>

Modified: trunk/Source/WebKit/UIProcess/WebAuthentication/Cocoa/LocalAuthenticator.mm (258441 => 258442)


--- trunk/Source/WebKit/UIProcess/WebAuthentication/Cocoa/LocalAuthenticator.mm	2020-03-13 23:04:17 UTC (rev 258441)
+++ trunk/Source/WebKit/UIProcess/WebAuthentication/Cocoa/LocalAuthenticator.mm	2020-03-13 23:15:31 UTC (rev 258442)
@@ -237,6 +237,8 @@
     ASSERT(m_state == State::RequestReceived);
     m_state = State::PolicyDecided;
 
+    auto& creationOptions = WTF::get<PublicKeyCredentialCreationOptions>(requestData().options);
+
     if (policy == LocalAuthenticatorPolicy::Disallow) {
         receiveRespond(ExceptionData { UnknownError, "Disallow local authenticator."_s });
         return;
@@ -261,7 +263,7 @@
 
         weakThis->continueMakeCredentialAfterUserVerification(accessControl.get(), verification, context);
     };
-    m_connection->verifyUser(accessControlRef, WTFMove(callback));
+    m_connection->verifyUser(creationOptions.rp.id, accessControlRef, WTFMove(callback));
 }
 
 void LocalAuthenticator::continueMakeCredentialAfterUserVerification(SecAccessControlRef accessControlRef, LocalConnection::UserVerification verification, LAContext *context)
@@ -476,6 +478,8 @@
     ASSERT(m_state == State::RequestReceived);
     m_state = State::ResponseSelected;
 
+    auto& requestOptions = WTF::get<PublicKeyCredentialRequestOptions>(requestData().options);
+
     auto accessControlRef = response->accessControl();
     auto callback = [
         weakThis = makeWeakPtr(*this),
@@ -487,7 +491,7 @@
 
         weakThis->continueGetAssertionAfterUserVerification(WTFMove(response), verification, context);
     };
-    m_connection->verifyUser(accessControlRef, WTFMove(callback));
+    m_connection->verifyUser(requestOptions.rpId, accessControlRef, WTFMove(callback));
 }
 
 void LocalAuthenticator::continueGetAssertionAfterUserVerification(Ref<WebCore::AuthenticatorAssertionResponse>&& response, LocalConnection::UserVerification verification, LAContext *context)

Modified: trunk/Source/WebKit/UIProcess/WebAuthentication/Cocoa/LocalConnection.h (258441 => 258442)


--- trunk/Source/WebKit/UIProcess/WebAuthentication/Cocoa/LocalConnection.h	2020-03-13 23:04:17 UTC (rev 258441)
+++ trunk/Source/WebKit/UIProcess/WebAuthentication/Cocoa/LocalConnection.h	2020-03-13 23:15:31 UTC (rev 258442)
@@ -62,7 +62,7 @@
     virtual ~LocalConnection() = default;
 
     // Overrided by MockLocalConnection.
-    virtual void verifyUser(SecAccessControlRef, UserVerificationCallback&&) const;
+    virtual void verifyUser(const String& rpId, SecAccessControlRef, UserVerificationCallback&&) const;
     virtual RetainPtr<SecKeyRef> createCredentialPrivateKey(LAContext *, SecAccessControlRef, const String& secAttrLabel, NSData *secAttrApplicationTag) const;
     virtual void getAttestation(SecKeyRef, NSData *authData, NSData *hash, AttestationCallback&&) const;
     virtual void filterResponses(HashSet<Ref<WebCore::AuthenticatorAssertionResponse>>&) const { };

Modified: trunk/Source/WebKit/UIProcess/WebAuthentication/Cocoa/LocalConnection.mm (258441 => 258442)


--- trunk/Source/WebKit/UIProcess/WebAuthentication/Cocoa/LocalConnection.mm	2020-03-13 23:04:17 UTC (rev 258441)
+++ trunk/Source/WebKit/UIProcess/WebAuthentication/Cocoa/LocalConnection.mm	2020-03-13 23:15:31 UTC (rev 258442)
@@ -40,14 +40,21 @@
 
 namespace WebKit {
 
-void LocalConnection::verifyUser(SecAccessControlRef accessControl, UserVerificationCallback&& completionHandler) const
+void LocalConnection::verifyUser(const String& rpId, SecAccessControlRef accessControl, UserVerificationCallback&& completionHandler) const
 {
     auto context = adoptNS([allocLAContextInstance() init]);
 
     auto options = adoptNS([[NSMutableDictionary alloc] init]);
-    if ([context biometryType] == LABiometryTypeTouchID)
-        [options setObject:WebCore::touchIDPromptTitle() forKey:@(LAOptionAuthenticationTitle)];
-#if PLATFORM(iOS)
+    if ([context biometryType] == LABiometryTypeTouchID) {
+#if PLATFORM(IOS)
+        [options setObject:WebCore::genericTouchIDPromptTitle() forKey:@(LAOptionAuthenticationTitle)];
+        ASSERT_UNUSED(rpId, rpId);
+#else
+        [options setObject:WebCore::makeCredentialTouchIDPromptTitle(rpId) forKey:@(LAOptionAuthenticationTitle)];
+#endif
+        [options setObject:@NO forKey:@(LAOptionFallbackVisible)];
+    }
+#if PLATFORM(IOS)
     [options setObject:WebCore::biometricFallbackPromptTitle() forKey:@(LAOptionPasscodeTitle)];
 #endif
 

Modified: trunk/Source/WebKit/UIProcess/WebAuthentication/Mock/MockLocalConnection.h (258441 => 258442)


--- trunk/Source/WebKit/UIProcess/WebAuthentication/Mock/MockLocalConnection.h	2020-03-13 23:04:17 UTC (rev 258441)
+++ trunk/Source/WebKit/UIProcess/WebAuthentication/Mock/MockLocalConnection.h	2020-03-13 23:15:31 UTC (rev 258442)
@@ -37,7 +37,7 @@
     explicit MockLocalConnection(const WebCore::MockWebAuthenticationConfiguration&);
 
 private:
-    void verifyUser(SecAccessControlRef, UserVerificationCallback&&) const final;
+    void verifyUser(const String&, SecAccessControlRef, UserVerificationCallback&&) const final;
     RetainPtr<SecKeyRef> createCredentialPrivateKey(LAContext *, SecAccessControlRef, const String& secAttrLabel, NSData *secAttrApplicationTag) const final;
     void getAttestation(SecKeyRef, NSData *authData, NSData *hash, AttestationCallback&&) const final;
     void filterResponses(HashSet<Ref<WebCore::AuthenticatorAssertionResponse>>&) const final;

Modified: trunk/Source/WebKit/UIProcess/WebAuthentication/Mock/MockLocalConnection.mm (258441 => 258442)


--- trunk/Source/WebKit/UIProcess/WebAuthentication/Mock/MockLocalConnection.mm	2020-03-13 23:04:17 UTC (rev 258441)
+++ trunk/Source/WebKit/UIProcess/WebAuthentication/Mock/MockLocalConnection.mm	2020-03-13 23:15:31 UTC (rev 258442)
@@ -44,7 +44,7 @@
 {
 }
 
-void MockLocalConnection::verifyUser(SecAccessControlRef, UserVerificationCallback&& callback) const
+void MockLocalConnection::verifyUser(const String&, SecAccessControlRef, UserVerificationCallback&& callback) const
 {
     // Mock async operations.
     RunLoop::main().dispatch([configuration = m_configuration, callback = WTFMove(callback)]() mutable {
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to