Changeset 251645 in webkit
- Timestamp:
- Oct 27, 2019, 3:53:33 PM (7 years ago)
- Location:
- trunk
- Files:
-
- 1 added
- 24 edited
-
LayoutTests/ChangeLog (modified) (1 diff)
-
LayoutTests/http/wpt/webauthn/public-key-credential-create-success-nfc.https-expected.txt (modified) (1 diff)
-
LayoutTests/http/wpt/webauthn/public-key-credential-create-success-nfc.https.html (modified) (5 diffs)
-
Source/WebCore/ChangeLog (modified) (1 diff)
-
Source/WebCore/testing/MockWebAuthenticationConfiguration.h (modified) (3 diffs)
-
Source/WebCore/testing/MockWebAuthenticationConfiguration.idl (modified) (1 diff)
-
Source/WebKit/ChangeLog (modified) (1 diff)
-
Source/WebKit/Platform/spi/Cocoa/NearFieldSPI.h (modified) (1 diff)
-
Source/WebKit/UIProcess/WebAuthentication/AuthenticatorManager.cpp (modified) (3 diffs)
-
Source/WebKit/UIProcess/WebAuthentication/AuthenticatorManager.h (modified) (2 diffs)
-
Source/WebKit/UIProcess/WebAuthentication/AuthenticatorTransportService.cpp (modified) (2 diffs)
-
Source/WebKit/UIProcess/WebAuthentication/AuthenticatorTransportService.h (modified) (4 diffs)
-
Source/WebKit/UIProcess/WebAuthentication/Cocoa/NfcConnection.h (modified) (2 diffs)
-
Source/WebKit/UIProcess/WebAuthentication/Cocoa/NfcConnection.mm (modified) (3 diffs)
-
Source/WebKit/UIProcess/WebAuthentication/Cocoa/NfcService.h (modified) (4 diffs)
-
Source/WebKit/UIProcess/WebAuthentication/Cocoa/NfcService.mm (modified) (4 diffs)
-
Source/WebKit/UIProcess/WebAuthentication/Mock/MockNfcService.h (modified) (1 diff)
-
Source/WebKit/UIProcess/WebAuthentication/Mock/MockNfcService.mm (modified) (10 diffs)
-
Source/WebKit/UIProcess/WebAuthentication/fido/CtapNfcDriver.cpp (modified) (1 diff)
-
Source/WebKit/UIProcess/WebAuthentication/fido/CtapNfcDriver.h (modified) (2 diffs)
-
Source/WebKit/UIProcess/WebAuthentication/fido/U2fAuthenticator.cpp (modified) (1 diff)
-
Tools/ChangeLog (modified) (1 diff)
-
Tools/TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj (modified) (4 diffs)
-
Tools/TestWebKitAPI/Tests/WebKitCocoa/_WKWebAuthenticationPanel.mm (modified) (3 diffs)
-
Tools/TestWebKitAPI/Tests/WebKitCocoa/web-authentication-get-assertion-nfc-multiple-tags.html (added)
Legend:
- Unmodified
- Added
- Removed
-
trunk/LayoutTests/ChangeLog
r251641 r251645 1 2019-10-21 Jiewen Tan <jiewen_tan@apple.com> 2 3 [WebAuthn] Warn users when multiple NFC tags present 4 https://bugs.webkit.org/show_bug.cgi?id=200932 5 <rdar://problem/54890736> 6 7 Reviewed by Brent Fulgham. 8 9 * http/wpt/webauthn/public-key-credential-create-success-nfc.https-expected.txt: 10 * http/wpt/webauthn/public-key-credential-create-success-nfc.https.html: 11 Adds new tests for multiple physical tags and service restart. 12 1 13 2019-10-27 Simon Fraser <simon.fraser@apple.com> 2 14 -
trunk/LayoutTests/http/wpt/webauthn/public-key-credential-create-success-nfc.https-expected.txt
r251602 r251645 4 4 PASS PublicKeyCredential's [[create]] with multiple tags in a mock nfc authenticator. 5 5 PASS PublicKeyCredential's [[create]] with U2F in a mock nfc authenticator. 6 PASS PublicKeyCredential's [[create]] with multiple physical tags in a mock nfc authenticator. 7 PASS PublicKeyCredential's [[create]] with service restart in a mock nfc authenticator. 6 8 -
trunk/LayoutTests/http/wpt/webauthn/public-key-credential-create-success-nfc.https.html
r251602 r251645 22 22 }, 23 23 challenge: Base64URL.parse("MTIzNDU2"), 24 pubKeyCredParams: [{ type: "public-key", alg: -7 }], 25 timeout: 100 24 pubKeyCredParams: [{ type: "public-key", alg: -7 }] 26 25 } 27 26 }; … … 45 44 challenge: Base64URL.parse("MTIzNDU2"), 46 45 pubKeyCredParams: [{ type: "public-key", alg: -7 }], 47 authenticatorSelection: { authenticatorAttachment: "cross-platform" }, 48 timeout: 100 46 authenticatorSelection: { authenticatorAttachment: "cross-platform" } 49 47 } 50 48 }; … … 67 65 }, 68 66 challenge: Base64URL.parse("MTIzNDU2"), 69 pubKeyCredParams: [{ type: "public-key", alg: -7 }], 70 timeout: 100 67 pubKeyCredParams: [{ type: "public-key", alg: -7 }] 71 68 } 72 69 }; … … 91 88 }, 92 89 challenge: Base64URL.parse("MTIzNDU2"), 93 pubKeyCredParams: [{ type: "public-key", alg: -7 }], 94 timeout: 100 90 pubKeyCredParams: [{ type: "public-key", alg: -7 }] 95 91 } 96 92 }; … … 102 98 }); 103 99 }, "PublicKeyCredential's [[create]] with U2F in a mock nfc authenticator."); 100 101 promise_test(t => { 102 const options = { 103 publicKey: { 104 rp: { 105 name: "localhost", 106 }, 107 user: { 108 name: "John Appleseed", 109 id: Base64URL.parse(testUserhandleBase64), 110 displayName: "Appleseed", 111 }, 112 challenge: Base64URL.parse("MTIzNDU2"), 113 pubKeyCredParams: [{ type: "public-key", alg: -7 }] 114 } 115 }; 116 117 if (window.internals) 118 internals.setMockWebAuthenticationConfiguration({ nfc: { error: "success", payloadBase64: [testNfcCtapVersionBase64, testGetInfoResponseApduBase64, testCreationMessageApduBase64], multiplePhysicalTags: true } }); 119 return navigator.credentials.create(options).then(credential => { 120 checkCtapMakeCredentialResult(credential); 121 }); 122 }, "PublicKeyCredential's [[create]] with multiple physical tags in a mock nfc authenticator."); 123 124 promise_test(t => { 125 const options = { 126 publicKey: { 127 rp: { 128 name: "localhost", 129 }, 130 user: { 131 name: "John Appleseed", 132 id: Base64URL.parse(testUserhandleBase64), 133 displayName: "Appleseed", 134 }, 135 challenge: Base64URL.parse("MTIzNDU2"), 136 pubKeyCredParams: [{ type: "public-key", alg: -7 }] 137 } 138 }; 139 140 if (window.internals) 141 internals.setMockWebAuthenticationConfiguration({ silentFailure: true, nfc: { error: "malicious-payload", payloadBase64: [testDummyMessagePayloadBase64, testNfcCtapVersionBase64, testGetInfoResponseApduBase64, testCreationMessageApduBase64] } }); 142 return navigator.credentials.create(options).then(credential => { 143 checkCtapMakeCredentialResult(credential); 144 }); 145 }, "PublicKeyCredential's [[create]] with service restart in a mock nfc authenticator."); 104 146 </script> -
trunk/Source/WebCore/ChangeLog
r251644 r251645 1 2019-10-21 Jiewen Tan <jiewen_tan@apple.com> 2 3 [WebAuthn] Warn users when multiple NFC tags present 4 https://bugs.webkit.org/show_bug.cgi?id=200932 5 <rdar://problem/54890736> 6 7 Reviewed by Brent Fulgham. 8 9 Covered by new tests in existing test file. 10 11 * testing/MockWebAuthenticationConfiguration.h: 12 (WebCore::MockWebAuthenticationConfiguration::NfcConfiguration::encode const): 13 (WebCore::MockWebAuthenticationConfiguration::NfcConfiguration::decode): 14 * testing/MockWebAuthenticationConfiguration.idl: 15 Adds a new test option. 16 1 17 2019-10-27 Antti Koivisto <antti@apple.com> 2 18 -
trunk/Source/WebCore/testing/MockWebAuthenticationConfiguration.h
r251602 r251645 94 94 Vector<String> payloadBase64; 95 95 bool multipleTags { false }; 96 bool multiplePhysicalTags { false }; 96 97 97 98 template<class Encoder> void encode(Encoder&) const; … … 194 195 void MockWebAuthenticationConfiguration::NfcConfiguration::encode(Encoder& encoder) const 195 196 { 196 encoder << error << payloadBase64 << multipleTags ;197 encoder << error << payloadBase64 << multipleTags << multiplePhysicalTags; 197 198 } 198 199 … … 206 207 return WTF::nullopt; 207 208 if (!decoder.decode(result.multipleTags)) 209 return WTF::nullopt; 210 if (!decoder.decode(result.multiplePhysicalTags)) 208 211 return WTF::nullopt; 209 212 return result; -
trunk/Source/WebCore/testing/MockWebAuthenticationConfiguration.idl
r251602 r251645 101 101 sequence<DOMString> payloadBase64; 102 102 boolean multipleTags = false; 103 boolean multiplePhysicalTags = false; 103 104 }; -
trunk/Source/WebKit/ChangeLog
r251639 r251645 1 2019-10-21 Jiewen Tan <jiewen_tan@apple.com> 2 3 [WebAuthn] Warn users when multiple NFC tags present 4 https://bugs.webkit.org/show_bug.cgi?id=200932 5 <rdar://problem/54890736> 6 7 Reviewed by Brent Fulgham. 8 9 This patch utilizes -[_WKWebAuthenticationPanelDelegate panel:updateWebAuthenticationPanel:] to 10 inform clients about multiple physical tags are presenting such that clients can instruct users 11 to select only one of them physically. Given a physical tag could have multiple different 12 interfaces, which NearField will treat them into different NFTags, the tagID is then used to 13 identify if there are actually multiple physical tags. 14 15 This patch also adds the ability to restart polling of a partiuclar NFReaderSession to NfcConnection 16 and the ability to restart the whole session to NfcService. The former is used to recover from errors 17 in the discovery stages, and the latter is used to recover from errors returned from authenticators 18 in the request stages. For the latter, given NfcConnection is not awared of the syntax of FIDO2/U2F 19 protocol, and CtapAuthenticator/U2fAuthenticator are not awared the transport of the underneath driver. 20 A generic restartDiscovery process is added to each service and it is up to the actual service to 21 implement the actual process such that AuthenticatorManager can arbitrarily call it after exceptions 22 are returned to restart the whole NFC session. To achieve restartDiscovery, NfcConnection is made 23 RefCounted as well such that both the NfcService and the CtapNfcDriver could hold it at the same time. 24 CtapNfcDriver uses the connection to complete requests as before while NfcService has the new capability 25 to use it to stop the current session when restartDiscovery kicks off. 26 27 * Platform/spi/Cocoa/NearFieldSPI.h: 28 * UIProcess/WebAuthentication/AuthenticatorManager.cpp: 29 (WebKit::AuthenticatorManager::serviceStatusUpdated): 30 (WebKit::AuthenticatorManager::respondReceived): 31 (WebKit::AuthenticatorManager::restartDiscovery): 32 * UIProcess/WebAuthentication/AuthenticatorManager.h: 33 * UIProcess/WebAuthentication/AuthenticatorTransportService.cpp: 34 (WebKit::AuthenticatorTransportService::startDiscovery): 35 (WebKit::AuthenticatorTransportService::restartDiscovery): 36 * UIProcess/WebAuthentication/AuthenticatorTransportService.h: 37 (WebKit::AuthenticatorTransportService::restartDiscoveryInternal): 38 * UIProcess/WebAuthentication/Cocoa/NfcConnection.h: 39 * UIProcess/WebAuthentication/Cocoa/NfcConnection.mm: 40 (WebKit::NfcConnection::create): 41 (WebKit::NfcConnection::NfcConnection): 42 (WebKit::NfcConnection::~NfcConnection): 43 (WebKit::NfcConnection::stop const): 44 (WebKit::NfcConnection::didDetectTags): 45 (WebKit::NfcConnection::restartPolling): 46 (WebKit::NfcConnection::startPolling): 47 (WebKit::NfcConnection::didDetectTags const): Deleted. 48 * UIProcess/WebAuthentication/Cocoa/NfcService.h: 49 * UIProcess/WebAuthentication/Cocoa/NfcService.mm: 50 (WebKit::NfcService::NfcService): 51 (WebKit::NfcService::didConnectTag): 52 (WebKit::NfcService::didDetectMultipleTags const): 53 (WebKit::NfcService::setConnection): 54 (WebKit::NfcService::restartDiscoveryInternal): 55 (WebKit::NfcService::platformStartDiscovery): 56 (WebKit::NfcService::setDriver): Deleted. 57 * UIProcess/WebAuthentication/Mock/MockNfcService.h: 58 * UIProcess/WebAuthentication/Mock/MockNfcService.mm: 59 (-[WKMockNFTag tagID]): 60 (-[WKMockNFTag initWithNFTag:]): 61 (-[WKMockNFTag dealloc]): 62 (-[WKMockNFTag initWithType:]): 63 (-[WKMockNFTag initWithType:tagID:]): 64 (WebKit::MockNfcService::receiveStopPolling): 65 (WebKit::MockNfcService::receiveStartPolling): 66 (WebKit::MockNfcService::platformStartDiscovery): 67 (WebKit::MockNfcService::detectTags): 68 (WebKit::MockNfcService::detectTags const): Deleted. 69 * UIProcess/WebAuthentication/fido/CtapNfcDriver.cpp: 70 (WebKit::CtapNfcDriver::CtapNfcDriver): 71 * UIProcess/WebAuthentication/fido/CtapNfcDriver.h: 72 * UIProcess/WebAuthentication/fido/U2fAuthenticator.cpp: 73 1 74 2019-10-26 youenn fablet <youenn@apple.com> 2 75 -
trunk/Source/WebKit/Platform/spi/Cocoa/NearFieldSPI.h
r251602 r251645 94 94 @property (assign) id<NFReaderSessionDelegate> delegate; 95 95 96 - (BOOL)startPolling ;96 - (BOOL)startPollingWithError:(NSError **)outError; 97 97 - (BOOL)stopPolling; 98 98 - (BOOL)connectTag:(NFTag*)tag; 99 99 - (BOOL)disconnectTag; 100 100 - (NSData*)transceive:(NSData*)capdu; 101 - (NSError *)updateUIAlertMessage:(NSString *)message;102 101 @end 103 102 -
trunk/Source/WebKit/UIProcess/WebAuthentication/AuthenticatorManager.cpp
r251602 r251645 214 214 } 215 215 216 void AuthenticatorManager::serviceStatusUpdated(WebAuthenticationStatus status) 217 { 218 if (auto *panel = m_pendingRequestData.panel.get()) 219 panel->client().updatePanel(status); 220 } 221 216 222 void AuthenticatorManager::respondReceived(Respond&& respond) 217 223 { … … 231 237 } 232 238 respondReceivedInternal(WTFMove(respond)); 239 restartDiscovery(); 233 240 } 234 241 … … 346 353 } 347 354 355 void AuthenticatorManager::restartDiscovery() 356 { 357 for (auto& service : m_services) 358 service->restartDiscovery(); 359 } 360 348 361 } // namespace WebKit 349 362 -
trunk/Source/WebKit/UIProcess/WebAuthentication/AuthenticatorManager.h
r251602 r251645 74 74 // AuthenticatorTransportService::Observer 75 75 void authenticatorAdded(Ref<Authenticator>&&) final; 76 void serviceStatusUpdated(WebAuthenticationStatus) final; 76 77 77 78 // Authenticator::Observer … … 91 92 void startRequest(); 92 93 void resetState(); 94 void restartDiscovery(); 93 95 94 96 // Request: We only allow one request per time. A new request will cancel any pending ones. -
trunk/Source/WebKit/UIProcess/WebAuthentication/AuthenticatorTransportService.cpp
r251602 r251645 76 76 void AuthenticatorTransportService::startDiscovery() 77 77 { 78 // Enforce asynchronous execution of makeCredential.79 78 RunLoop::main().dispatch([weakThis = makeWeakPtr(*this)] { 80 79 if (!weakThis) … … 84 83 } 85 84 85 void AuthenticatorTransportService::restartDiscovery() 86 { 87 RunLoop::main().dispatch([weakThis = makeWeakPtr(*this)] { 88 if (!weakThis) 89 return; 90 weakThis->restartDiscoveryInternal(); 91 }); 92 } 93 86 94 } // namespace WebKit 87 95 -
trunk/Source/WebKit/UIProcess/WebAuthentication/AuthenticatorTransportService.h
r251602 r251645 28 28 #if ENABLE(WEB_AUTHN) 29 29 30 #include "WebAuthenticationFlags.h" 30 31 #include <WebCore/AuthenticatorTransport.h> 31 32 #include <wtf/UniqueRef.h> … … 49 50 50 51 virtual void authenticatorAdded(Ref<Authenticator>&&) = 0; 52 virtual void serviceStatusUpdated(WebAuthenticationStatus) = 0; 51 53 }; 52 54 … … 56 58 virtual ~AuthenticatorTransportService() = default; 57 59 58 // Th is operation isguaranteed to execute asynchronously.60 // These operations are guaranteed to execute asynchronously. 59 61 void startDiscovery(); 62 void restartDiscovery(); 60 63 61 64 protected: … … 66 69 private: 67 70 virtual void startDiscoveryInternal() = 0; 71 // NFC service's polling is one shot. It halts after the first tags are detected. 72 // Therefore, a restart process is needed to resume polling after exceptions. 73 virtual void restartDiscoveryInternal() { }; 68 74 69 75 WeakPtr<Observer> m_observer; -
trunk/Source/WebKit/UIProcess/WebAuthentication/Cocoa/NfcConnection.h
r251602 r251645 28 28 #if ENABLE(WEB_AUTHN) && HAVE(NEAR_FIELD) 29 29 30 #include <wtf/FastMalloc.h> 31 #include <wtf/Noncopyable.h> 30 #include <wtf/RefCounted.h> 32 31 #include <wtf/RetainPtr.h> 32 #include <wtf/RunLoop.h> 33 33 #include <wtf/WeakPtr.h> 34 34 … … 41 41 class NfcService; 42 42 43 class NfcConnection : public CanMakeWeakPtr<NfcConnection> { 44 WTF_MAKE_FAST_ALLOCATED; 45 WTF_MAKE_NONCOPYABLE(NfcConnection); 43 class NfcConnection : public RefCounted<NfcConnection>, public CanMakeWeakPtr<NfcConnection> { 46 44 public: 47 NfcConnection(RetainPtr<NFReaderSession>&&, NfcService&);45 static Ref<NfcConnection> create(RetainPtr<NFReaderSession>&&, NfcService&); 48 46 ~NfcConnection(); 49 47 50 48 Vector<uint8_t> transact(Vector<uint8_t>&& data) const; 49 void stop() const; 51 50 52 51 // For WKNFReaderSessionDelegate 53 void didDetectTags(NSArray *) const;52 void didDetectTags(NSArray *); 54 53 55 54 private: 55 NfcConnection(RetainPtr<NFReaderSession>&&, NfcService&); 56 57 void restartPolling(); 58 void startPolling(); 59 56 60 RetainPtr<NFReaderSession> m_session; 57 61 RetainPtr<WKNFReaderSessionDelegate> m_delegate; 58 62 WeakPtr<NfcService> m_service; 63 RunLoop::Timer<NfcConnection> m_retryTimer; 59 64 }; 60 65 -
trunk/Source/WebKit/UIProcess/WebAuthentication/Cocoa/NfcConnection.mm
r251602 r251645 46 46 } // namespace 47 47 48 Ref<NfcConnection> NfcConnection::create(RetainPtr<NFReaderSession>&& session, NfcService& service) 49 { 50 return adoptRef(*new NfcConnection(WTFMove(session), service)); 51 } 52 48 53 NfcConnection::NfcConnection(RetainPtr<NFReaderSession>&& session, NfcService& service) 49 54 : m_session(WTFMove(session)) 50 55 , m_delegate(adoptNS([[WKNFReaderSessionDelegate alloc] initWithConnection:*this])) 51 56 , m_service(makeWeakPtr(service)) 57 , m_retryTimer(RunLoop::main(), this, &NfcConnection::startPolling) 52 58 { 53 59 [m_session setDelegate:m_delegate.get()]; 54 [m_session startPolling];60 startPolling(); 55 61 } 56 62 57 63 NfcConnection::~NfcConnection() 58 64 { 59 [m_session disconnectTag]; 60 [m_session stopPolling]; 61 [m_session endSession]; 65 stop(); 62 66 } 63 67 … … 72 76 } 73 77 74 void NfcConnection:: didDetectTags(NSArray *tags) const78 void NfcConnection::stop() const 75 79 { 76 if (!m_service) 80 [m_session disconnectTag]; 81 [m_session stopPolling]; 82 [m_session endSession]; 83 } 84 85 void NfcConnection::didDetectTags(NSArray *tags) 86 { 87 if (!m_service || !tags.count) 77 88 return; 78 89 79 // FIXME(200932): Warn users when multiple NFC tags present 80 for (NFTag *tag in tags) { 81 if (tag.type != NFTagTypeGeneric4A) 90 // A physical NFC tag could have multiple interfaces. 91 // Therefore, we use tagID to detect if there are multiple physical tags. 92 NSData *tagID = ((NFTag *)tags[0]).tagID; 93 for (NFTag *tag : tags) { 94 if ([tagID isEqualToData:tag.tagID]) 82 95 continue; 83 if (![m_session connectTag:tag]) 96 m_service->didDetectMultipleTags(); 97 restartPolling(); 98 return; 99 } 100 101 // FIXME(203234): Tell users to switch to a different tag if the tag is not of type NFTagTypeGeneric4A 102 // or can't speak U2F/FIDO2. 103 for (NFTag *tag : tags) { 104 if (tag.type != NFTagTypeGeneric4A || ![m_session connectTag:tag]) 84 105 continue; 85 106 … … 95 116 96 117 m_service->didConnectTag(); 97 break;118 return; 98 119 } 120 restartPolling(); 121 } 122 123 // NearField polling is a one shot polling. It halts after tags are detected. 124 // Therefore, a restart process is needed to resume polling after error. 125 void NfcConnection::restartPolling() 126 { 127 [m_session stopPolling]; 128 m_retryTimer.startOneShot(1_s); // Magic number to give users enough time for reactions. 129 } 130 131 void NfcConnection::startPolling() 132 { 133 NSError *error = nil; 134 [m_session startPollingWithError:&error]; 135 if (error) 136 LOG_ERROR("Couldn't start NFC reader polling: %@", error); 99 137 } 100 138 -
trunk/Source/WebKit/UIProcess/WebAuthentication/Cocoa/NfcService.h
r251602 r251645 29 29 30 30 #include "FidoService.h" 31 #include <wtf/RunLoop.h> 31 32 32 33 OBJC_CLASS NFReaderSession; … … 34 35 namespace WebKit { 35 36 36 class CtapNfcDriver;37 class NfcConnection; 37 38 38 39 class NfcService : public FidoService { … … 43 44 // For NfcConnection. 44 45 void didConnectTag(); 46 void didDetectMultipleTags() const; 45 47 46 48 #if HAVE(NEAR_FIELD) 47 49 protected: 48 void set Driver(std::unique_ptr<CtapNfcDriver>&&);50 void setConnection(Ref<NfcConnection>&&); // For MockNfcConnection 49 51 #endif 50 52 51 53 private: 52 54 void startDiscoveryInternal() final; 53 void continueAddDeviceAfterGetInfo(Vector<uint8_t>&& response);55 void restartDiscoveryInternal() final; 54 56 55 57 // Overrided by MockNfcService. … … 59 61 // Only one reader session is allowed per time. 60 62 // Keep the reader session alive here when it tries to connect to a tag. 61 std::unique_ptr<CtapNfcDriver> m_driver;63 RefPtr<NfcConnection> m_connection; 62 64 #endif 65 RunLoop::Timer<NfcService> m_restartTimer; 63 66 }; 64 67 -
trunk/Source/WebKit/UIProcess/WebAuthentication/Cocoa/NfcService.mm
r251602 r251645 42 42 NfcService::NfcService(Observer& observer) 43 43 : FidoService(observer) 44 , m_restartTimer(RunLoop::main(), this, &NfcService::platformStartDiscovery) 44 45 { 45 46 } … … 52 53 { 53 54 #if HAVE(NEAR_FIELD) 54 getInfo(WTFMove(m_driver)); 55 auto connection = m_connection; 56 ASSERT(connection); 57 getInfo(WTF::makeUnique<CtapNfcDriver>(connection.releaseNonNull())); 55 58 #endif 56 59 } 57 60 61 void NfcService::didDetectMultipleTags() const 62 { 63 if (auto* observer = this->observer()) 64 observer->serviceStatusUpdated(WebAuthenticationStatus::MultipleNFCTagsPresent); 65 } 66 58 67 #if HAVE(NEAR_FIELD) 59 void NfcService::set Driver(std::unique_ptr<CtapNfcDriver>&& driver)68 void NfcService::setConnection(Ref<NfcConnection>&& connection) 60 69 { 61 m_ driver = WTFMove(driver);70 m_connection = WTFMove(connection); 62 71 } 63 72 #endif … … 66 75 { 67 76 platformStartDiscovery(); 77 } 78 79 void NfcService::restartDiscoveryInternal() 80 { 81 #if HAVE(NEAR_FIELD) 82 if (m_connection) 83 m_connection->stop(); 84 #endif 85 m_restartTimer.startOneShot(1_s); // Magic number to give users enough time for reactions. 68 86 } 69 87 … … 88 106 } 89 107 90 // CtapNfcDriver andNfcConnection will take care of polling tags and connecting to them.91 m_ driver = WTF::makeUnique<CtapNfcDriver>(makeUniqueRef<NfcConnection>(WTFMove(session), *this));108 // NfcConnection will take care of polling tags and connecting to them. 109 m_connection = NfcConnection::create(WTFMove(session), *this); 92 110 }); 93 111 }); -
trunk/Source/WebKit/UIProcess/WebAuthentication/Mock/MockNfcService.h
r251602 r251645 40 40 41 41 NSData* transceive(); 42 void receiveStopPolling(); 43 void receiveStartPolling(); 42 44 43 45 private: -
trunk/Source/WebKit/UIProcess/WebAuthentication/Mock/MockNfcService.mm
r251602 r251645 39 39 #import "NearFieldSoftLink.h" 40 40 41 namespace { 42 uint8_t tagID1[] = { 0x01 }; 43 uint8_t tagID2[] = { 0x02 }; 44 } 45 41 46 #if HAVE(NEAR_FIELD) 42 47 … … 44 49 45 50 - (instancetype)initWithType:(NFTagType)type; 51 - (instancetype)initWithType:(NFTagType)type tagID:(NSData *)tagID; 46 52 47 53 @end … … 49 55 @implementation WKMockNFTag { 50 56 NFTagType _type; 57 RetainPtr<NSData> _tagID; 51 58 } 52 59 53 60 @synthesize technology=_technology; 54 @synthesize tagID=_tagID;55 61 @synthesize AppData=_AppData; 56 62 @synthesize UID=_UID; … … 67 73 } 68 74 75 - (NSData *)tagID 76 { 77 return _tagID.get(); 78 } 79 69 80 - (instancetype)initWithNFTag:(id<NFTag>)tag 70 81 { 71 if ((self = [super init])) 82 if ((self = [super init])) { 72 83 _type = tag.type; 84 _tagID = tag.tagID; 85 } 73 86 return self; 74 87 } … … 76 89 - (void)dealloc 77 90 { 78 [_tagID release];79 _tagID = nil;80 91 [_AppData release]; 81 92 _AppData = nil; … … 98 109 - (instancetype)initWithType:(NFTagType)type 99 110 { 100 if ((self = [super init])) 111 return [self initWithType:type tagID:adoptNS([[NSData alloc] initWithBytes:tagID1 length:sizeof(tagID1)]).get()]; 112 } 113 114 - (instancetype)initWithType:(NFTagType)type tagID:(NSData *)tagID 115 { 116 if ((self = [super init])) { 101 117 _type = type; 118 _tagID = tagID; 119 } 102 120 return self; 103 121 } … … 133 151 } 134 152 153 static BOOL NFReaderSessionStopPolling(id, SEL) 154 { 155 if (!globalNfcService) 156 return NO; 157 globalNfcService->receiveStopPolling(); 158 return YES; 159 } 160 161 static BOOL NFReaderSessionStartPollingWithError(id, SEL, NSError **) 162 { 163 if (!globalNfcService) 164 return NO; 165 globalNfcService->receiveStartPolling(); 166 return YES; 167 } 168 135 169 static NSData* NFReaderSessionTransceive(id, SEL, NSData *) 136 170 { … … 158 192 m_configuration.nfc->payloadBase64.remove(0); 159 193 return [result autorelease]; 194 } 195 196 void MockNfcService::receiveStopPolling() 197 { 198 // For purpose of restart polling. 199 m_configuration.nfc->multiplePhysicalTags = false; 200 } 201 202 void MockNfcService::receiveStartPolling() 203 { 204 RunLoop::main().dispatch([weakThis = makeWeakPtr(*this)] { 205 if (!weakThis) 206 return; 207 weakThis->detectTags(); 208 }); 160 209 } 161 210 … … 178 227 method_setImplementation(methodToSwizzle3, (IMP)NFReaderSessionTransceive); 179 228 229 Method methodToSwizzle4 = class_getInstanceMethod(getNFReaderSessionClass(), @selector(stopPolling)); 230 method_setImplementation(methodToSwizzle4, (IMP)NFReaderSessionStopPolling); 231 232 Method methodToSwizzle5 = class_getInstanceMethod(getNFReaderSessionClass(), @selector(startPollingWithError:)); 233 method_setImplementation(methodToSwizzle5, (IMP)NFReaderSessionStartPollingWithError); 234 180 235 auto readerSession = adoptNS([allocNFReaderSessionInstance() init]); 181 setDriver(WTF::makeUnique<CtapNfcDriver>(makeUniqueRef<NfcConnection>(readerSession.get(), *this))); 182 183 RunLoop::main().dispatch([weakThis = makeWeakPtr(*this)] { 184 if (!weakThis) 185 return; 186 weakThis->detectTags(); 187 }); 188 return; 236 setConnection(NfcConnection::create(readerSession.get(), *this)); 189 237 } 190 238 LOG_ERROR("No nfc authenticators is available."); … … 208 256 [tags addObject:adoptNS([[WKMockNFTag alloc] initWithType:NFTagTypeGeneric4A]).get()]; 209 257 258 if (configuration.nfc->multiplePhysicalTags) 259 [tags addObject:adoptNS([[WKMockNFTag alloc] initWithType:NFTagTypeGeneric4A tagID:adoptNS([[NSData alloc] initWithBytes:tagID2 length:sizeof(tagID2)]).get()]).get()]; 260 210 261 [globalNFReaderSessionDelegate readerSession:nil didDetectTags:tags.get()]; 211 262 }); -
trunk/Source/WebKit/UIProcess/WebAuthentication/fido/CtapNfcDriver.cpp
r251602 r251645 37 37 using namespace fido; 38 38 39 CtapNfcDriver::CtapNfcDriver( UniqueRef<NfcConnection>&& connection)39 CtapNfcDriver::CtapNfcDriver(Ref<NfcConnection>&& connection) 40 40 : m_connection(WTFMove(connection)) 41 41 { -
trunk/Source/WebKit/UIProcess/WebAuthentication/fido/CtapNfcDriver.h
r251602 r251645 38 38 class CtapNfcDriver : public CtapDriver { 39 39 public: 40 explicit CtapNfcDriver( UniqueRef<NfcConnection>&&);40 explicit CtapNfcDriver(Ref<NfcConnection>&&); 41 41 42 42 void transact(Vector<uint8_t>&& data, ResponseCallback&&) final; … … 45 45 void respondAsync(ResponseCallback&&, Vector<uint8_t>&& response) const; 46 46 47 UniqueRef<NfcConnection> m_connection;47 Ref<NfcConnection> m_connection; 48 48 }; 49 49 -
trunk/Source/WebKit/UIProcess/WebAuthentication/fido/U2fAuthenticator.cpp
r251602 r251645 34 34 #include <WebCore/U2fCommandConstructor.h> 35 35 #include <WebCore/U2fResponseConverter.h> 36 #include <wtf/RunLoop.h>37 36 #include <wtf/text/StringConcatenateNumbers.h> 38 37 -
trunk/Tools/ChangeLog
r251643 r251645 1 2019-10-21 Jiewen Tan <jiewen_tan@apple.com> 2 3 [WebAuthn] Warn users when multiple NFC tags present 4 https://bugs.webkit.org/show_bug.cgi?id=200932 5 <rdar://problem/54890736> 6 7 Reviewed by Brent Fulgham. 8 9 * TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj: 10 * TestWebKitAPI/Tests/WebKitCocoa/_WKWebAuthenticationPanel.mm: 11 (-[TestWebAuthenticationPanelDelegate panel:updateWebAuthenticationPanel:]): 12 (TestWebKitAPI::TEST): 13 Adds a new test for -[_WKWebAuthenticationPanelDelegate panel:updateWebAuthenticationPanel:]. 14 * TestWebKitAPI/Tests/WebKitCocoa/web-authentication-get-assertion-nfc-multiple-tags.html: Added. 15 1 16 2019-10-27 Claudio Saavedra <csaavedra@igalia.com> 2 17 -
trunk/Tools/TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj
r251602 r251645 351 351 5797FE311EB15A6800B2F4A0 /* NavigationClientDefaultCrypto.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 5797FE2F1EB15A5F00B2F4A0 /* NavigationClientDefaultCrypto.cpp */; }; 352 352 5797FE331EB15AB100B2F4A0 /* navigation-client-default-crypto.html in Copy Resources */ = {isa = PBXBuildFile; fileRef = 5797FE321EB15A8900B2F4A0 /* navigation-client-default-crypto.html */; }; 353 5798337C235EB689008E5547 /* web-authentication-get-assertion-nfc-multiple-tags.html in Copy Resources */ = {isa = PBXBuildFile; fileRef = 5798337B235EB65C008E5547 /* web-authentication-get-assertion-nfc-multiple-tags.html */; }; 353 354 57A79857224AB34E00A7F6F1 /* WebCryptoMasterKey.mm in Sources */ = {isa = PBXBuildFile; fileRef = 57A79856224AB34E00A7F6F1 /* WebCryptoMasterKey.mm */; }; 354 355 57C3FA661F7C248F009D4B80 /* WeakPtr.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1CB9BC371A67482300FE5678 /* WeakPtr.cpp */; }; … … 1454 1455 577454D02359B378008E1ED7 /* web-authentication-get-assertion-hid-no-credentials.html in Copy Resources */, 1455 1456 57663DEC234F1F9300E85E09 /* web-authentication-get-assertion-hid.html in Copy Resources */, 1457 5798337C235EB689008E5547 /* web-authentication-get-assertion-nfc-multiple-tags.html in Copy Resources */, 1456 1458 57663DEA234EA66D00E85E09 /* web-authentication-get-assertion-nfc.html in Copy Resources */, 1457 1459 577454D22359BB01008E1ED7 /* web-authentication-get-assertion-u2f-no-credentials.html in Copy Resources */, … … 1890 1892 5797FE2F1EB15A5F00B2F4A0 /* NavigationClientDefaultCrypto.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = NavigationClientDefaultCrypto.cpp; sourceTree = "<group>"; }; 1891 1893 5797FE321EB15A8900B2F4A0 /* navigation-client-default-crypto.html */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.html; path = "navigation-client-default-crypto.html"; sourceTree = "<group>"; }; 1894 5798337B235EB65C008E5547 /* web-authentication-get-assertion-nfc-multiple-tags.html */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.html; path = "web-authentication-get-assertion-nfc-multiple-tags.html"; sourceTree = "<group>"; }; 1892 1895 5798E2AF1CAF5C2800C5CBA0 /* ProvisionalURLNotChange.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = ProvisionalURLNotChange.mm; sourceTree = "<group>"; }; 1893 1896 57A79856224AB34E00A7F6F1 /* WebCryptoMasterKey.mm */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.objcpp; path = WebCryptoMasterKey.mm; sourceTree = "<group>"; }; … … 3413 3416 577454CF2359B338008E1ED7 /* web-authentication-get-assertion-hid-no-credentials.html */, 3414 3417 57663DEB234F1F8000E85E09 /* web-authentication-get-assertion-hid.html */, 3418 5798337B235EB65C008E5547 /* web-authentication-get-assertion-nfc-multiple-tags.html */, 3415 3419 57663DE9234EA60B00E85E09 /* web-authentication-get-assertion-nfc.html */, 3416 3420 577454D12359BAD5008E1ED7 /* web-authentication-get-assertion-u2f-no-credentials.html */, -
trunk/Tools/TestWebKitAPI/Tests/WebKitCocoa/_WKWebAuthenticationPanel.mm
r251602 r251645 43 43 static bool webAuthenticationPanelFailed = false; 44 44 static bool webAuthenticationPanelSucceded = false; 45 static bool webAuthenticationPanelUpdateMultipleNFCTagsPresent = false; 45 46 static bool webAuthenticationPanelUpdateNoCredentialsFound = false; 46 47 static RetainPtr<_WKWebAuthenticationPanel> gPanel; … … 54 55 { 55 56 ASSERT_NE(panel, nil); 56 if (update == _WKWebAuthenticationPanelUpdateNoCredentialsFound) 57 if (update == _WKWebAuthenticationPanelUpdateMultipleNFCTagsPresent) { 58 webAuthenticationPanelUpdateMultipleNFCTagsPresent = true; 59 return; 60 } 61 if (update == _WKWebAuthenticationPanelUpdateNoCredentialsFound) { 57 62 webAuthenticationPanelUpdateNoCredentialsFound = true; 63 return; 64 } 58 65 } 59 66 … … 607 614 } 608 615 616 #if HAVE(NEAR_FIELD) 617 TEST(WebAuthenticationPanel, PanelMultipleNFCTagsPresent) 618 { 619 reset(); 620 RetainPtr<NSURL> testURL = [[NSBundle mainBundle] URLForResource:@"web-authentication-get-assertion-nfc-multiple-tags" withExtension:@"html" subdirectory:@"TestWebKitAPI.resources"]; 621 622 auto *configuration = [WKWebViewConfiguration _test_configurationWithTestPlugInClassName:@"WebProcessPlugInWithInternals" configureJSCForTesting:YES]; 623 [[configuration preferences] _setEnabled:YES forExperimentalFeature:webAuthenticationExperimentalFeature()]; 624 625 auto webView = adoptNS([[TestWKWebView alloc] initWithFrame:NSZeroRect configuration:configuration]); 626 auto delegate = adoptNS([[TestWebAuthenticationPanelUIDelegate alloc] init]); 627 [webView setUIDelegate:delegate.get()]; 628 629 [webView loadRequest:[NSURLRequest requestWithURL:testURL.get()]]; 630 Util::run(&webAuthenticationPanelRan); 631 Util::run(&webAuthenticationPanelUpdateMultipleNFCTagsPresent); 632 } 633 #endif 634 609 635 } // namespace TestWebKitAPI 610 636
Note:
See TracChangeset
for help on using the changeset viewer.