Skip to content

Commit

Permalink
Cherry-pick 6c90d82. rdar://122985287
Browse files Browse the repository at this point in the history
    REGRESSION(273918@main): WebAuthn cancel completion handler is never called
    https://bugs.webkit.org/show_bug.cgi?id=270473
    rdar://122985287

    Reviewed by Pascoe.

    A completion handler from the web process is stored in `m_cancelHandler` to be called by the delegate.
    However, the delegate is immediately cleared, so the completion handler will never be called. We
    shouldn’t clear the delegate and controller until `m_cancelHandler` is called.

    * Source/WebKit/UIProcess/WebAuthentication/Cocoa/WebAuthenticatorCoordinatorProxy.mm:

    Canonical link: https://commits.webkit.org/275673@main
  • Loading branch information
charliewolfe authored and Mohsin Qureshi committed Mar 7, 2024
1 parent be42b60 commit b7c2679
Showing 1 changed file with 13 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -458,14 +458,14 @@ static inline ASAuthorizationPublicKeyCredentialLargeBlobSupportRequirement toAS
if (weakThis) {
if (activeConditionalMediationProxy() == weakThis)
activeConditionalMediationProxy() = nullptr;
if (auto cancelHandler = WTFMove(weakThis->m_cancelHandler))
cancelHandler();
if (!weakThis->m_paused) {
weakThis->m_completionHandler(response, attachment, exceptionData);
weakThis->m_delegate.clear();
weakThis->m_controller.clear();
weakThis->m_isConditionalMediation = false;
}
if (auto cancelHandler = WTFMove(weakThis->m_cancelHandler))
cancelHandler();
}
});
}).get()]);
Expand Down Expand Up @@ -1044,7 +1044,16 @@ static inline void getArePasskeysDisallowedForRelyingParty(const WebCore::Securi
#else
if (m_proxy) {
#endif
m_cancelHandler = WTFMove(handler);
m_cancelHandler = [weakThis = WeakPtr { *this }, handler = WTFMove(handler)]() mutable {
#if HAVE(WEB_AUTHN_AS_MODERN)
if (weakThis) {
weakThis->m_controller.clear();
weakThis->m_delegate.clear();
weakThis->m_completionHandler = nullptr;
}
#endif
handler();
};
} else
handler();

Expand All @@ -1053,12 +1062,8 @@ static inline void getArePasskeysDisallowedForRelyingParty(const WebCore::Securi
m_proxy.clear();
}
#if HAVE(WEB_AUTHN_AS_MODERN)
if (m_controller) {
if (m_controller)
[m_controller cancel];
m_controller.clear();
m_delegate.clear();
m_completionHandler = nullptr;
}
#endif
}

Expand Down

0 comments on commit b7c2679

Please sign in to comment.