Changeset 270724 in webkit
- Timestamp:
- Dec 11, 2020 6:03:32 PM (3 years ago)
- Location:
- trunk/Source/WebKit
- Files:
-
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/WebKit/ChangeLog
r270723 r270724 1 2020-12-11 Jiewen Tan <jiewen_tan@apple.com> 2 3 [WebAuthn] Adopt new UI for the Security Key getAssertion flow 4 https://bugs.webkit.org/show_bug.cgi?id=219711 5 <rdar://problem/72154840> 6 7 Reviewed by Brent Fulgham. 8 9 This patch adopts the new UI for the security key getAssertion flow which contains two part: 10 1. showing a informative UI to ask the user to connect their security keys, 11 2. showing an account picker for users to select a credential to use. 12 13 Covered by manual tests. 14 15 * Platform/spi/Cocoa/AuthenticationServicesCoreSPI.h: 16 Paperwork. 17 18 * UIProcess/WebAuthentication/Cocoa/AuthenticatorPresenterCoordinator.h: 19 * UIProcess/WebAuthentication/Cocoa/AuthenticatorPresenterCoordinator.mm: 20 (WebKit::AuthenticatorPresenterCoordinator::AuthenticatorPresenterCoordinator): 21 (WebKit::AuthenticatorPresenterCoordinator::selectAssertionResponse): 22 (WebKit::AuthenticatorPresenterCoordinator::didSelectAssertionResponse): 23 * UIProcess/WebAuthentication/Cocoa/WKASCAuthorizationPresenterDelegate.mm: 24 (-[WKASCAuthorizationPresenterDelegate authorizationPresenter:credentialRequestedForLoginChoice:authenticatedContext:completionHandler:]): 25 Implements the two flows. 26 1 27 2020-12-11 John Wilander <wilander@apple.com> 2 28 -
trunk/Source/WebKit/Platform/spi/Cocoa/AuthenticationServicesCoreSPI.h
r270694 r270724 70 70 71 71 - (void)presentAuthorizationWithContext:(ASCAuthorizationPresentationContext *)context completionHandler:(void (^)(id<ASCCredentialProtocol> _Nullable, NSError * _Nullable))completionHandler; 72 - (void)updateInterfaceWithLoginChoices:(NSArray<id <ASCLoginChoiceProtocol>> *)loginChoices; 72 73 73 74 @property (nonatomic, weak) id <ASCAuthorizationPresenterDelegate> delegate; … … 90 91 @property (nonatomic, readonly, copy) NSString *appIdentifier; 91 92 @property (nonatomic, readonly, copy) NSArray<id<ASCLoginChoiceProtocol>> *loginChoices; 92 @property (nonatomic, nullable, copy) NSString * relyingPartyIdentifier;93 @property (nonatomic, nullable, copy) NSString *serviceName; 93 94 94 95 @property (nonatomic, copy) NSString *proxiedAppName; … … 103 104 @end 104 105 106 typedef NS_ENUM(NSInteger, ASCSecurityKeyPublicKeyCredentialLoginChoiceKind) { 107 ASCSecurityKeyPublicKeyCredentialLoginChoiceKindRegistration, 108 ASCSecurityKeyPublicKeyCredentialLoginChoiceKindAssertion, 109 ASCSecurityKeyPublicKeyCredentialLoginChoiceKindAssertionPlaceholder, 110 }; 111 105 112 @interface ASCSecurityKeyPublicKeyCredentialLoginChoice : NSObject <ASCLoginChoiceProtocol> 106 113 107 114 - (instancetype)initRegistrationChoice; 108 115 - (instancetype)initWithName:(NSString *)name displayName:(NSString *)displayName userHandle:(NSData *)userHandle; 116 - (instancetype)initAssertionPlaceholderChoice; 109 117 110 @property (nonatomic, readonly, copy) NSString *name;111 @property (nonatomic, readonly, copy) NSString *displayName;112 @property (nonatomic, readonly, copy) NSData *userHandle;113 @property (nonatomic, readonly) BOOL isRegistrationRequest;118 @property (nonatomic, nullable, readonly, copy) NSString *name; 119 @property (nonatomic, nullable, readonly, copy) NSString *displayName; 120 @property (nonatomic, nullable, readonly, copy) NSData *userHandle; 121 @property (nonatomic, readonly) ASCSecurityKeyPublicKeyCredentialLoginChoiceKind loginChoiceKind; 114 122 115 123 + (instancetype)new NS_UNAVAILABLE; -
trunk/Source/WebKit/UIProcess/WebAuthentication/Cocoa/AuthenticatorPresenterCoordinator.h
r270694 r270724 29 29 30 30 #include "WebAuthenticationFlags.h" 31 #include <WebCore/AuthenticatorAssertionResponse.h> 31 32 #include <WebCore/AuthenticatorTransport.h> 32 33 #include <WebCore/WebAuthenticationConstants.h> … … 36 37 37 38 OBJC_CLASS ASCAuthorizationPresenter; 39 OBJC_CLASS ASCLoginChoiceProtocol; 38 40 OBJC_CLASS LAContext; 39 41 OBJC_CLASS WKASCAuthorizationPresenterDelegate; … … 65 67 void setLAContext(LAContext *); 66 68 69 void didSelectAssertionResponse(ASCLoginChoiceProtocol *); 70 67 71 private: 68 72 WeakPtr<AuthenticatorManager> m_manager; … … 74 78 CompletionHandler<void(LAContext *)> m_laContextHandler; 75 79 RetainPtr<LAContext> m_laContext; 80 81 CompletionHandler<void(WebCore::AuthenticatorAssertionResponse*)> m_responseHandler; 82 HashMap<ASCLoginChoiceProtocol *, RefPtr<WebCore::AuthenticatorAssertionResponse>> m_credentials; 76 83 }; 77 84 -
trunk/Source/WebKit/UIProcess/WebAuthentication/Cocoa/AuthenticatorPresenterCoordinator.mm
r270721 r270724 31 31 #import "AuthenticatorManager.h" 32 32 #import "WKASCAuthorizationPresenterDelegate.h" 33 #import <WebCore/NotImplemented.h>34 33 #import <wtf/BlockPtr.h> 35 34 … … 55 54 break; 56 55 case ClientDataType::Get: 57 // FIXME(219710): Adopt new UI for the Platform Authenticator getAssertion flow.58 // FIXME(219711): Adopt new UI for the Security Key getAssertion flow.56 if (transports.contains(AuthenticatorTransport::Usb) || transports.contains(AuthenticatorTransport::Nfc)) 57 [presentationContext addLoginChoice:adoptNS([allocASCSecurityKeyPublicKeyCredentialLoginChoiceInstance() initAssertionPlaceholderChoice]).get()]; 59 58 break; 60 59 default: … … 92 91 } 93 92 94 void AuthenticatorPresenterCoordinator::selectAssertionResponse(Vector<Ref<AuthenticatorAssertionResponse>>&& , WebAuthenticationSource, CompletionHandler<void(AuthenticatorAssertionResponse*)>&&)93 void AuthenticatorPresenterCoordinator::selectAssertionResponse(Vector<Ref<AuthenticatorAssertionResponse>>&& responses, WebAuthenticationSource source, CompletionHandler<void(AuthenticatorAssertionResponse*)>&& completionHandler) 95 94 { 95 #if HAVE(ASC_AUTH_UI) 96 if (m_responseHandler) 97 m_responseHandler(nullptr); 98 m_responseHandler = WTFMove(completionHandler); 99 100 if (source == WebAuthenticationSource::External) { 101 auto loginChoices = adoptNS([[NSMutableArray alloc] init]); 102 103 for (auto& response : responses) { 104 RetainPtr<NSData> userHandle; 105 if (response->userHandle()) 106 userHandle = adoptNS([[NSData alloc] initWithBytes:response->userHandle()->data() length:response->userHandle()->byteLength()]); 107 108 auto loginChoice = adoptNS([allocASCSecurityKeyPublicKeyCredentialLoginChoiceInstance() initWithName:response->name() displayName:response->displayName() userHandle:userHandle.get()]); 109 [loginChoices addObject:loginChoice.get()]; 110 111 m_credentials.add((ASCLoginChoiceProtocol *)loginChoice.get(), WTFMove(response)); 112 } 113 114 [m_presenter updateInterfaceWithLoginChoices:loginChoices.get()]; 115 return; 116 } 96 117 // FIXME(219710): Adopt new UI for the Platform Authenticator getAssertion flow. 97 // FIXME(219711): Adopt new UI for the Security Key getAssertion flow. 118 #endif // HAVE(ASC_AUTH_UI) 98 119 } 99 120 … … 127 148 } 128 149 150 void AuthenticatorPresenterCoordinator::didSelectAssertionResponse(ASCLoginChoiceProtocol *loginChoice) 151 { 152 auto response = m_credentials.take(loginChoice); 153 if (!response) 154 return; 155 156 m_responseHandler(response.get()); 157 } 158 129 159 } // namespace WebKit 130 160 -
trunk/Source/WebKit/UIProcess/WebAuthentication/Cocoa/WKASCAuthorizationPresenterDelegate.mm
r270694 r270724 66 66 } 67 67 } 68 69 if ([loginChoice isKindOfClass:WebKit::getASCSecurityKeyPublicKeyCredentialLoginChoiceClass()]) { 70 if ([(ASCSecurityKeyPublicKeyCredentialLoginChoice *)loginChoice loginChoiceKind] == ASCSecurityKeyPublicKeyCredentialLoginChoiceKindAssertion) { 71 [self dispatchCoordinatorCallback:[loginChoice] (WebKit::AuthenticatorPresenterCoordinator& coordinator) mutable { 72 coordinator.didSelectAssertionResponse((ASCLoginChoiceProtocol *)loginChoice); 73 }]; 74 75 return; 76 } 77 } 68 78 } 69 79
Note: See TracChangeset
for help on using the changeset viewer.