diff --git a/IdentityCore/src/oauth2/aad_v2/MSIDAADV2Oauth2Factory.m b/IdentityCore/src/oauth2/aad_v2/MSIDAADV2Oauth2Factory.m index c8f0056fc..4b08f59cd 100644 --- a/IdentityCore/src/oauth2/aad_v2/MSIDAADV2Oauth2Factory.m +++ b/IdentityCore/src/oauth2/aad_v2/MSIDAADV2Oauth2Factory.m @@ -88,7 +88,7 @@ - (BOOL)verifyResponse:(MSIDAADV2TokenResponse *)response if (!result) { - if (response.error) + if (response.error && error) { *error = MSIDCreateError(MSIDOAuthErrorDomain, response.oauthErrorCode, diff --git a/IdentityCore/src/util/NSString+MSIDExtensions.m b/IdentityCore/src/util/NSString+MSIDExtensions.m index 4331ec6aa..6614c39d4 100644 --- a/IdentityCore/src/util/NSString+MSIDExtensions.m +++ b/IdentityCore/src/util/NSString+MSIDExtensions.m @@ -162,7 +162,7 @@ + (NSString *)msidHexStringFromData:(NSData *)data if (!charBytes) return nil; NSUInteger dataLength = data.length; - NSMutableString *result = [NSMutableString stringWithCapacity:dataLength]; + NSMutableString *result = [NSMutableString stringWithCapacity:dataLength*2]; for (int i = 0; i < dataLength; i++) { diff --git a/IdentityCore/src/webview/embeddedWebview/MSIDOAuth2EmbeddedWebviewController.m b/IdentityCore/src/webview/embeddedWebview/MSIDOAuth2EmbeddedWebviewController.m index 66166d1d9..539765bc9 100644 --- a/IdentityCore/src/webview/embeddedWebview/MSIDOAuth2EmbeddedWebviewController.m +++ b/IdentityCore/src/webview/embeddedWebview/MSIDOAuth2EmbeddedWebviewController.m @@ -272,6 +272,11 @@ - (void)webView:(WKWebView *)webView didFailNavigation:(null_unspecified WKNavig [self webAuthFailWithError:error]; } +- (void)webView:(WKWebView *)webView didFailProvisionalNavigation:(WKNavigation *)navigation withError:(NSError *)error +{ + [self webAuthFailWithError:error]; +} + - (void)webView:(WKWebView *)webView didReceiveAuthenticationChallenge:(NSURLAuthenticationChallenge *)challenge completionHandler:(ChallengeCompletionHandler)completionHandler { NSString *authMethod = [challenge.protectionSpace.authenticationMethod lowercaseString]; diff --git a/IdentityCore/src/webview/embeddedWebview/ui/ios/MSIDWebviewUIController.m b/IdentityCore/src/webview/embeddedWebview/ui/ios/MSIDWebviewUIController.m index a2ba9fd91..b0aa1503f 100644 --- a/IdentityCore/src/webview/embeddedWebview/ui/ios/MSIDWebviewUIController.m +++ b/IdentityCore/src/webview/embeddedWebview/ui/ios/MSIDWebviewUIController.m @@ -27,6 +27,8 @@ #import "UIApplication+MSIDExtensions.h" #import "MSIDAppExtensionUtil.h" +static WKWebViewConfiguration *s_webConfig; + @interface MSIDWebviewUIController ( ) { UIActivityIndicatorView *_loadingIndicator; @@ -40,6 +42,14 @@ @interface MSIDWebviewUIController ( ) @implementation MSIDWebviewUIController ++ (void)initialize +{ + static dispatch_once_t onceToken; + dispatch_once(&onceToken, ^{ + s_webConfig = [WKWebViewConfiguration new]; + }); +} + - (id)initWithContext:(id)context { self = [super init]; @@ -86,8 +96,7 @@ - (BOOL)loadView:(NSError **)error; [rootView setAutoresizingMask:UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight]; // Prepare the WKWebView - WKWebViewConfiguration *webConfiguration = [WKWebViewConfiguration new]; - WKWebView *webView = [[WKWebView alloc] initWithFrame:rootView.frame configuration:webConfiguration]; + WKWebView *webView = [[WKWebView alloc] initWithFrame:rootView.frame configuration:s_webConfig]; [webView setAccessibilityIdentifier:@"MSID_SIGN_IN_WEBVIEW"]; // Customize the UI diff --git a/IdentityCore/src/webview/embeddedWebview/ui/mac/MSIDCertificateChooser.m b/IdentityCore/src/webview/embeddedWebview/ui/mac/MSIDCertificateChooser.m index 6b737fc2c..d0f6f2d91 100644 --- a/IdentityCore/src/webview/embeddedWebview/ui/mac/MSIDCertificateChooser.m +++ b/IdentityCore/src/webview/embeddedWebview/ui/mac/MSIDCertificateChooser.m @@ -23,6 +23,7 @@ #import #import "MSIDCertificateChooser.h" +#import @implementation MSIDCertificateChooserHelper { @@ -61,7 +62,7 @@ - (void)beginSheet:(NSArray *)identities identities:identities message:message]; - //[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(webAuthDidFail:) name:ADWebAuthDidFailNotification object:nil]; + [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(webAuthDidFail:) name:MSIDNotifications.webAuthDidFailNotificationName object:nil]; } - (void)showCertSelectionSheet:(NSArray *)identities @@ -87,10 +88,9 @@ - (void)sheetDidEnd:(__unused NSWindow *)window } SecIdentityRef identity = _panel.identity; - _panel = nil; _completionHandler(identity); _completionHandler = nil; - //[[NSNotificationCenter defaultCenter] removeObserver:self name:ADWebAuthDidFailNotification object:nil]; + [[NSNotificationCenter defaultCenter] removeObserver:self name:MSIDNotifications.webAuthDidFailNotificationName object:nil]; } - (void)webAuthDidFail:(__unused NSNotification *)aNotification diff --git a/IdentityCore/src/webview/embeddedWebview/ui/mac/MSIDWebviewUIController.m b/IdentityCore/src/webview/embeddedWebview/ui/mac/MSIDWebviewUIController.m index e1520dc32..2f703fc7e 100644 --- a/IdentityCore/src/webview/embeddedWebview/ui/mac/MSIDWebviewUIController.m +++ b/IdentityCore/src/webview/embeddedWebview/ui/mac/MSIDWebviewUIController.m @@ -28,6 +28,8 @@ #define DEFAULT_WINDOW_WIDTH 420 #define DEFAULT_WINDOW_HEIGHT 650 +static WKWebViewConfiguration *s_webConfig; + @interface MSIDWebviewUIController ( ) { NSProgressIndicator *_loadingIndicator; @@ -37,6 +39,14 @@ @interface MSIDWebviewUIController ( ) @implementation MSIDWebviewUIController ++ (void)initialize +{ + static dispatch_once_t onceToken; + dispatch_once(&onceToken, ^{ + s_webConfig = [WKWebViewConfiguration new]; + }); +} + - (id)initWithContext:(id)context { self = [super init]; @@ -60,8 +70,7 @@ - (BOOL)loadView:(NSError **)error NSView *rootView = window.contentView; // Prepare the WKWebView - WKWebViewConfiguration *webConfiguration = [WKWebViewConfiguration new]; - WKWebView *webView = [[WKWebView alloc] initWithFrame:rootView.frame configuration:webConfiguration]; + WKWebView *webView = [[WKWebView alloc] initWithFrame:rootView.frame configuration:s_webConfig]; [webView setAccessibilityIdentifier:@"MSID_SIGN_IN_WEBVIEW"]; // Customize the UI diff --git a/IdentityCore/src/webview/systemWebview/ios/MSIDAuthenticationSession.m b/IdentityCore/src/webview/systemWebview/ios/MSIDAuthenticationSession.m index dcd6e7ef0..2913dab7b 100644 --- a/IdentityCore/src/webview/systemWebview/ios/MSIDAuthenticationSession.m +++ b/IdentityCore/src/webview/systemWebview/ios/MSIDAuthenticationSession.m @@ -67,6 +67,7 @@ - (instancetype)initWithURL:(NSURL *)url { _startURL = url; _context = context; + _callbackURLScheme = callbackURLScheme; } return self; diff --git a/IdentityCore/src/workplacejoin/mac/MSIDWorkPlaceJoinUtil.m b/IdentityCore/src/workplacejoin/mac/MSIDWorkPlaceJoinUtil.m index 7fbf70fe1..0b98b752f 100644 --- a/IdentityCore/src/workplacejoin/mac/MSIDWorkPlaceJoinUtil.m +++ b/IdentityCore/src/workplacejoin/mac/MSIDWorkPlaceJoinUtil.m @@ -135,7 +135,7 @@ + (MSIDRegistrationInformation *)getRegistrationInformation:(id)context @@ -170,7 +170,7 @@ + (void)copyCertificate:(SecCertificateRef __nullable * __nonnull)certificate // If there's no certificate in the keychain, adError won't be set since this isn't an error condition. if (!*certificate) { - return; + return NO; } // In OS X the shared access group cannot be set, so the search needs to be more @@ -199,7 +199,7 @@ + (void)copyCertificate:(SecCertificateRef __nullable * __nonnull)certificate CFRelease(result); - return; + return YES; _error: @@ -216,6 +216,8 @@ + (void)copyCertificate:(SecCertificateRef __nullable * __nonnull)certificate *certificate = nil; *issuer = nil; + + return NO; }