diff --git a/IdentityCore/IdentityCore.xcodeproj/project.pbxproj b/IdentityCore/IdentityCore.xcodeproj/project.pbxproj index 2e6fae0af..e3dd5ff20 100644 --- a/IdentityCore/IdentityCore.xcodeproj/project.pbxproj +++ b/IdentityCore/IdentityCore.xcodeproj/project.pbxproj @@ -134,7 +134,6 @@ 6035CD8D207EA67300369E69 /* MSIDTelemetryIntegrationTests.m in Sources */ = {isa = PBXBuildFile; fileRef = 6035CD8B207EA67300369E69 /* MSIDTelemetryIntegrationTests.m */; }; 6057EE9020B5FDF8007976EB /* MSIDAADOAuthEmbeddedWebviewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 6057EE8F20B5FDF8007976EB /* MSIDAADOAuthEmbeddedWebviewController.m */; }; 6057EE9120B5FDF8007976EB /* MSIDAADOAuthEmbeddedWebviewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 6057EE8F20B5FDF8007976EB /* MSIDAADOAuthEmbeddedWebviewController.m */; }; - 606830052098ACED00CCA6AB /* MSIDNegotiateHandler.m in Sources */ = {isa = PBXBuildFile; fileRef = 606830042098ACED00CCA6AB /* MSIDNegotiateHandler.m */; }; 606830062098ACED00CCA6AB /* MSIDNegotiateHandler.m in Sources */ = {isa = PBXBuildFile; fileRef = 606830042098ACED00CCA6AB /* MSIDNegotiateHandler.m */; }; 6068300A2098C9D300CCA6AB /* MSIDCredentialCollectionController.m in Sources */ = {isa = PBXBuildFile; fileRef = 606830092098C9D300CCA6AB /* MSIDCredentialCollectionController.m */; }; 606830102098E94100CCA6AB /* MSIDCertificateChooser.m in Sources */ = {isa = PBXBuildFile; fileRef = 6068300F2098E94100CCA6AB /* MSIDCertificateChooser.m */; }; @@ -149,7 +148,6 @@ 60BF06042051F9A200DE7C1C /* MSIDTelemetryTestDispatcher.m in Sources */ = {isa = PBXBuildFile; fileRef = 60BF06032051F9A200DE7C1C /* MSIDTelemetryTestDispatcher.m */; }; 60BF06052051F9A200DE7C1C /* MSIDTelemetryTestDispatcher.m in Sources */ = {isa = PBXBuildFile; fileRef = 60BF06032051F9A200DE7C1C /* MSIDTelemetryTestDispatcher.m */; }; 60D6ED0220D9BB02002FCBBB /* SecurityInterface.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 9623FF4220A396F700A989B7 /* SecurityInterface.framework */; }; - 60D6ED0420D9BB50002FCBBB /* GSS.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 60D6ED0320D9BB4F002FCBBB /* GSS.framework */; }; 60D6ED0620D9BB5A002FCBBB /* WebKit.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 60D6ED0520D9BB5A002FCBBB /* WebKit.framework */; }; 60D6ED0820D9BB6A002FCBBB /* UIKit.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 60D6ED0720D9BB6A002FCBBB /* UIKit.framework */; }; 60D6ED0A20D9BB79002FCBBB /* SafariServices.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 60D6ED0920D9BB79002FCBBB /* SafariServices.framework */; }; @@ -1175,7 +1173,6 @@ 60D6ED0A20D9BB79002FCBBB /* SafariServices.framework in Frameworks */, 60D6ED0820D9BB6A002FCBBB /* UIKit.framework in Frameworks */, 60D6ED0620D9BB5A002FCBBB /* WebKit.framework in Frameworks */, - 60D6ED0420D9BB50002FCBBB /* GSS.framework in Frameworks */, 96285D6320D872AA004CA4BD /* libIdentityCore.a in Frameworks */, 96285D6120D8721E004CA4BD /* libIdentityTest.a in Frameworks */, ); @@ -3037,7 +3034,6 @@ B29A36C020B1289D00427B63 /* MSIDAccountIdentifier.m in Sources */, 96A3E9B9208941D700BE5262 /* MSIDSystemWebviewController.m in Sources */, D61AFAB51FD8B6C600DABBE5 /* MSIDConstants.m in Sources */, - 606830052098ACED00CCA6AB /* MSIDNegotiateHandler.m in Sources */, 238E19CD2086FC87004DF483 /* MSIDUrlRequestSerializer.m in Sources */, 96F21B0520A4FB27002B87C3 /* MSIDAppExtensionUtil.m in Sources */, 238E19DE2086FE28004DF483 /* MSIDTokenRequest.m in Sources */, @@ -3584,6 +3580,10 @@ isa = XCBuildConfiguration; baseConfigurationReference = D6CF4E931FC3626A00CD70C5 /* identitycore__debug.xcconfig */; buildSettings = { + GCC_PREPROCESSOR_DEFINITIONS = ( + "$(inherited)", + "$(MSID_SYSTEMWV)", + ); }; name = Debug; }; @@ -3591,6 +3591,7 @@ isa = XCBuildConfiguration; baseConfigurationReference = D6CF4E9C1FC3626B00CD70C5 /* identitycore__release.xcconfig */; buildSettings = { + GCC_PREPROCESSOR_DEFINITIONS = "$(MSID_SYSTEMWV)"; }; name = Release; }; diff --git a/IdentityCore/IdentityCore.xcodeproj/xcshareddata/xcschemes/IdentityCore iOS.xcscheme b/IdentityCore/IdentityCore.xcodeproj/xcshareddata/xcschemes/IdentityCore iOS.xcscheme index 72fac8467..e28104822 100644 --- a/IdentityCore/IdentityCore.xcodeproj/xcshareddata/xcschemes/IdentityCore iOS.xcscheme +++ b/IdentityCore/IdentityCore.xcodeproj/xcshareddata/xcschemes/IdentityCore iOS.xcscheme @@ -26,9 +26,8 @@ buildConfiguration = "Debug" selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB" selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB" - language = "" - shouldUseLaunchSchemeArgsEnv = "YES" - codeCoverageEnabled = "YES"> + codeCoverageEnabled = "YES" + shouldUseLaunchSchemeArgsEnv = "YES"> @@ -57,7 +56,6 @@ buildConfiguration = "Debug" selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB" selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB" - language = "" launchStyle = "0" useCustomWorkingDirectory = "NO" ignoresPersistentStateOnLaunch = "NO" diff --git a/IdentityCore/src/MSIDError.h b/IdentityCore/src/MSIDError.h index b77d78f9e..8d42745da 100644 --- a/IdentityCore/src/MSIDError.h +++ b/IdentityCore/src/MSIDError.h @@ -41,81 +41,99 @@ extern NSString *MSIDKeychainErrorDomain; typedef NS_ENUM(NSInteger, MSIDErrorCode) { - MSIDErrorInternal = -51000, - MSIDErrorInvalidInternalParameter = -51001, - - MSIDErrorInvalidDeveloperParameter = -51002, - MSIDErrorAmbiguousAuthority = -51003, - MSIDErrorInteractionRequired = -51004, - - MSIDErrorCacheMultipleUsers = -51005, - /*! - MSID encounted an error when trying to store or retrieve items from - keychain. Inspect NSUnderlyingError from the userInfo dictionary for - more information about the specific error. Keychain error codes are - documented in Apple's header file + ==================================================== + General Errors (510xx, 511xx) - MSIDErrorDomain + ==================================================== */ - MSIDErrorTokenCacheItemFailure = -51006, - MSIDErrorWrapperCacheFailure = -51007, - MSIDErrorCacheBadFormat = -51008, - MSIDErrorCacheVersionMismatch = -51009, + // General internal errors that do not fall into one of the specific type + // of an error described below. + MSIDErrorInternal = -51100, - MSIDErrorServerInvalidResponse = -51010, - MSIDErrorDeveloperAuthorityValidation = -51011, - MSIDErrorServerRefreshTokenRejected = -51012, - MSIDErrorServerOauth = -51013, - MSIDErrorInvalidRequest = -51014, - MSIDErrorInvalidClient = -51015, - MSIDErrorInvalidGrant = -51016, - MSIDErrorInvalidScope = -51017, - MSIDErrorInvalidParameter = -51018, - MSIDErrorUserCancel = -51019, - /*! - The authentication request was cancelled programmatically. - */ - MSIDErrorSessionCanceled = -51020, + // Parameter errors + MSIDErrorInvalidInternalParameter = -51111, + MSIDErrorInvalidDeveloperParameter = -51112, + + // Unsupported functionality + MSIDErrorUnsupportedFunctionality = -51199, + /*! - An interactive authentication session is already running with the - SafariViewController visible. Another authentication session can not be - launched yet. + ========================================================= + Cache Errors (512xx) - MSIDErrorDomain + ========================================================= */ - MSIDErrorInteractiveSessionAlreadyRunning = -51021, + + // Multiple users found in cache when one was intended + MSIDErrorCacheMultipleUsers = -51201, + MSIDErrorCacheBadFormat = -51302, + /*! - An interactive authentication session failed to start. + ========================================================= + Server errors (514xx) - MSIDOAuthErrorDomain + ========================================================= */ - MSIDErrorInteractiveSessionStartFailure = -51022, + // Interaction Required + MSIDErrorInteractionRequired = -51411, - MSIDErrorNoMainViewController = -51023, - MSIDServerNonHttpsRedirect = -51024, + // Server returned a response indicating an OAuth error + MSIDErrorServerOauth = -51421, + // Server returned an invalid response + MSIDErrorServerInvalidResponse = -51422, + // Server returned a refresh token reject response + MSIDErrorServerRefreshTokenRejected = -51423, + // Other specific server response errors - MSIDErrorUnsupportedFunctionality = -51025, + MSIDErrorServerInvalidRequest = -51431, + MSIDErrorServerInvalidClient = -51432, + MSIDErrorServerInvalidGrant = -51433, + MSIDErrorServerInvalidScope = -51434, + + // State verification has failed + MSIDErrorServerInvalidState = -51441, + + // Redirect to non HTTPS detected + MSIDErrorServerNonHttpsRedirect = -51451, /*! - The user or application failed to authenticate in the interactive flow. - Inspect MSALOAuthErrorKey and MSALErrorDescriptionKey in the userInfo - dictionary for more detailed information about the specific error. + ========================================================= + Authority Validation (515xx) - MSIDErrorDomain + ========================================================= */ - MSIDErrorAuthorizationFailed = -52020, + // Authority validation response failure + MSIDErrorAuthorityValidation = -51500, /*! - Interaction required errors occur because of a wide variety of errors - returned by the authentication service. + ========================================================= + Interactive flow errors (516xx) - MSIDOAuthErrorDomain + ========================================================= */ - MSIDErrorMismatchedUser = -52101, - MSIDErrorNoAuthorizationResponse = -52102, - MSIDErrorBadAuthorizationResponse = -52103, + // The user or application failed to authenticate in the interactive flow. + // Inspect MSALOAuthErrorKey and MSALErrorDescriptionKey in the userInfo + // dictionary for more detailed information about the specific error. + MSIDErrorAuthorizationFailed = -51600, + + // User has cancelled the interactive flow. + MSIDErrorUserCancel = -51611, + + // The interactive flow was cancelled programmatically. + MSIDErrorSessionCanceledProgrammatically = -51612, + + // Interactive authentication session failed to start. + MSIDErrorInteractiveSessionStartFailure = -51621, /*! - The state returned by the server does not match the state that was sent to - the server at the beginning of the authorization attempt. + An interactive authentication session is already running. + Another authentication session can not be launched yet. */ - MSIDErrorInvalidState = -52501, + MSIDErrorInteractiveSessionAlreadyRunning = -51622, - MSIDErrorCodeFirst = MSIDErrorInternal, - MSIDErrorCodeLast = MSIDErrorInvalidState + // Embedded webview has failed to find a view controller to display web contents + MSIDErrorNoMainViewController = - 51631, }; extern NSError *MSIDCreateError(NSString *domain, NSInteger code, NSString *errorDescription, NSString *oauthError, NSString *subError, NSError *underlyingError, NSUUID *correlationId, NSDictionary *additionalUserInfo); extern MSIDErrorCode MSIDErrorCodeForOAuthError(NSString *oauthError, MSIDErrorCode defaultCode); + +extern NSDictionary *MSIDErrorDomainsAndCodes(void); + diff --git a/IdentityCore/src/MSIDError.m b/IdentityCore/src/MSIDError.m index 41c18a421..e3d6c4e84 100644 --- a/IdentityCore/src/MSIDError.m +++ b/IdentityCore/src/MSIDError.m @@ -52,20 +52,58 @@ MSIDErrorCode MSIDErrorCodeForOAuthError(NSString *oauthError, MSIDErrorCode def { if (oauthError && [oauthError caseInsensitiveCompare:@"invalid_request"] == NSOrderedSame) { - return MSIDErrorInvalidRequest; + return MSIDErrorServerInvalidRequest; } if (oauthError && [oauthError caseInsensitiveCompare:@"invalid_client"] == NSOrderedSame) { - return MSIDErrorInvalidClient; + return MSIDErrorServerInvalidClient; } if (oauthError && [oauthError caseInsensitiveCompare:@"invalid_scope"] == NSOrderedSame) { - return MSIDErrorInvalidScope; + return MSIDErrorServerInvalidScope; } if (oauthError && [oauthError caseInsensitiveCompare:@"invalid_grant"] == NSOrderedSame) { - return MSIDErrorInvalidGrant; + return MSIDErrorServerInvalidGrant; } return defaultCode; } + +NSDictionary* MSIDErrorDomainsAndCodes() +{ + return @{ MSIDErrorDomain : @[// General Errors + @(MSIDErrorInternal), + @(MSIDErrorInvalidInternalParameter), + @(MSIDErrorInvalidDeveloperParameter), + @(MSIDErrorUnsupportedFunctionality), + + // Cache Errors + @(MSIDErrorCacheMultipleUsers), + @(MSIDErrorCacheBadFormat), + + // Authority Validation Errors + @(MSIDErrorAuthorityValidation), + + // Interactive flow errors + @(MSIDErrorAuthorizationFailed), + @(MSIDErrorUserCancel), + @(MSIDErrorSessionCanceledProgrammatically), + @(MSIDErrorInteractiveSessionStartFailure), + @(MSIDErrorInteractiveSessionAlreadyRunning), + @(MSIDErrorNoMainViewController) + ], + MSIDOAuthErrorDomain : @[// Server Errors + @(MSIDErrorInteractionRequired), + @(MSIDErrorServerOauth), + @(MSIDErrorServerInvalidResponse), + @(MSIDErrorServerRefreshTokenRejected), + @(MSIDErrorServerInvalidRequest), + @(MSIDErrorServerInvalidClient), + @(MSIDErrorServerInvalidGrant), + @(MSIDErrorServerInvalidScope), + @(MSIDErrorServerInvalidState), + @(MSIDErrorServerNonHttpsRedirect) + ] + }; +} diff --git a/IdentityCore/src/oauth2/MSIDTokenResponse.m b/IdentityCore/src/oauth2/MSIDTokenResponse.m index 3df587baa..661b71eb1 100644 --- a/IdentityCore/src/oauth2/MSIDTokenResponse.m +++ b/IdentityCore/src/oauth2/MSIDTokenResponse.m @@ -101,7 +101,7 @@ - (MSIDAccountType)accountType - (MSIDErrorCode)oauthErrorCode { - return MSIDErrorCodeForOAuthError(self.error, MSIDErrorInteractionRequired); + return MSIDErrorCodeForOAuthError(self.error, MSIDErrorServerOauth); } - (NSDictionary *)additionalServerInfo diff --git a/IdentityCore/src/oauth2/MSIDWebviewFactory.h b/IdentityCore/src/oauth2/MSIDWebviewFactory.h index c652a90d7..677717e71 100644 --- a/IdentityCore/src/oauth2/MSIDWebviewFactory.h +++ b/IdentityCore/src/oauth2/MSIDWebviewFactory.h @@ -34,7 +34,7 @@ // Webviews creation - (MSIDWebviewSession *)embeddedWebviewSessionFromConfiguration:(MSIDWebviewConfiguration *)configuration customWebview:(WKWebView *)webview context:(id)context; -#if TARGET_OS_IPHONE +#if TARGET_OS_IPHONE && !MSID_EXCLUDE_SYSTEMWV - (MSIDWebviewSession *)systemWebviewSessionFromConfiguration:(MSIDWebviewConfiguration *)configuration context:(id)context; #endif diff --git a/IdentityCore/src/oauth2/MSIDWebviewFactory.m b/IdentityCore/src/oauth2/MSIDWebviewFactory.m index da63a164c..15f437f7d 100644 --- a/IdentityCore/src/oauth2/MSIDWebviewFactory.m +++ b/IdentityCore/src/oauth2/MSIDWebviewFactory.m @@ -55,7 +55,7 @@ - (MSIDWebviewSession *)embeddedWebviewSessionFromConfiguration:(MSIDWebviewConf return session; } -#if TARGET_OS_IPHONE +#if TARGET_OS_IPHONE && !MSID_EXCLUDE_SYSTEMWV - (MSIDWebviewSession *)systemWebviewSessionFromConfiguration:(MSIDWebviewConfiguration *)configuration context:(id)context { NSString *state = [self generateStateValue]; @@ -180,7 +180,7 @@ - (BOOL)verifyRequestState:(NSString *)requestState if (error) { *error = MSIDCreateError(MSIDOAuthErrorDomain, - MSIDErrorInvalidState, + MSIDErrorServerInvalidState, [NSString stringWithFormat:@"Missing or invalid state returned state: %@", stateReceived], nil, nil, nil, nil, nil); } diff --git a/IdentityCore/src/webview/MSIDWebviewAuthorization.h b/IdentityCore/src/webview/MSIDWebviewAuthorization.h index 95c5105da..34e7d3cd4 100644 --- a/IdentityCore/src/webview/MSIDWebviewAuthorization.h +++ b/IdentityCore/src/webview/MSIDWebviewAuthorization.h @@ -51,17 +51,18 @@ typedef void (^MSIDWebviewAuthCompletionHandler)(MSIDWebviewResponse *response, context:(id)context completionHandler:(MSIDWebviewAuthCompletionHandler)completionHandler; -#if TARGET_OS_IPHONE +#if TARGET_OS_IPHONE && !MSID_EXCLUDE_SYSTEMWV + (void)startSystemWebviewWebviewAuthWithConfiguration:(MSIDWebviewConfiguration *)configuration oauth2Factory:(MSIDOauth2Factory *)oauth2Factory context:(id)context completionHandler:(MSIDWebviewAuthCompletionHandler)completionHandler; #endif + + (BOOL)setCurrentSession:(MSIDWebviewSession *)session; + (void)cancelCurrentSession; -#if TARGET_OS_IPHONE +#if TARGET_OS_IPHONE && !MSID_EXCLUDE_SYSTEMWV // This is for system webview auth session on iOS 10 - Thus, a SafariViewController + (BOOL)handleURLResponseForSystemWebviewController:(NSURL *)url; #endif diff --git a/IdentityCore/src/webview/MSIDWebviewAuthorization.m b/IdentityCore/src/webview/MSIDWebviewAuthorization.m index e7065d2b0..1397faed6 100644 --- a/IdentityCore/src/webview/MSIDWebviewAuthorization.m +++ b/IdentityCore/src/webview/MSIDWebviewAuthorization.m @@ -63,7 +63,7 @@ + (void)startEmbeddedWebviewWebviewAuthWithConfiguration:(MSIDWebviewConfigurati [self startSession:session context:context completionHandler:completionHandler]; } -#if TARGET_OS_IPHONE +#if TARGET_OS_IPHONE && !MSID_EXCLUDE_SYSTEMWV + (void)startSystemWebviewWebviewAuthWithConfiguration:(MSIDWebviewConfiguration *)configuration oauth2Factory:(MSIDOauth2Factory *)oauth2Factory context:(id)context @@ -83,7 +83,7 @@ + (void)startSession:(MSIDWebviewSession *)session // check session nil if (!session) { - NSError *error = MSIDCreateError(MSIDErrorDomain, MSIDErrorInvalidRequest, @"Interactive session failed to create.", nil, nil, nil, context.correlationId, nil); + NSError *error = MSIDCreateError(MSIDErrorDomain, MSIDErrorInternal, @"Interactive session failed to create.", nil, nil, nil, context.correlationId, nil); completionHandler(nil, error); return; } @@ -169,9 +169,9 @@ + (void)cancelCurrentSession } } +#if TARGET_OS_IPHONE && !MSID_EXCLUDE_SYSTEMWV + (BOOL)handleURLResponseForSystemWebviewController:(NSURL *)url; { -#if TARGET_OS_IPHONE @synchronized([MSIDWebviewAuthorization class]) { if (s_currentSession && @@ -180,9 +180,8 @@ + (BOOL)handleURLResponseForSystemWebviewController:(NSURL *)url; return [((MSIDSystemWebviewController *)s_currentSession.webviewController) handleURLResponseForSafariViewController:url]; } } -#endif return NO; } - +#endif @end diff --git a/IdentityCore/src/webview/embeddedWebview/MSIDOAuth2EmbeddedWebviewController.m b/IdentityCore/src/webview/embeddedWebview/MSIDOAuth2EmbeddedWebviewController.m index 3581a9c60..4e46d1d6e 100644 --- a/IdentityCore/src/webview/embeddedWebview/MSIDOAuth2EmbeddedWebviewController.m +++ b/IdentityCore/src/webview/embeddedWebview/MSIDOAuth2EmbeddedWebviewController.m @@ -114,7 +114,16 @@ - (void)cancel MSID_LOG_INFO(self.context, @"Cancel Web Auth..."); // End web auth with error - NSError *error = MSIDCreateError(MSIDErrorDomain, MSIDErrorUserCancel, @"The user/application has cancelled the authorization.", nil, nil, nil, self.context.correlationId, nil); + NSError *error = MSIDCreateError(MSIDErrorDomain, MSIDErrorSessionCanceledProgrammatically, @"Authorization session was cancelled programatically.", nil, nil, nil, self.context.correlationId, nil); + [self endWebAuthWithURL:nil error:error]; +} + +- (void)userCancel +{ + MSID_LOG_INFO(self.context, @"Cancel Web Auth..."); + + // End web auth with error + NSError *error = MSIDCreateError(MSIDErrorDomain, MSIDErrorUserCancel, @"User cancelled the authorization session.", nil, nil, nil, self.context.correlationId, nil); [self endWebAuthWithURL:nil error:error]; } @@ -301,7 +310,7 @@ - (void)decidePolicyForNavigationAction:(WKNavigationAction *)navigationAction { MSID_LOG_INFO(self.context, @"Server is redirecting to a non-https url"); - NSError *error = MSIDCreateError(MSIDErrorDomain, MSIDServerNonHttpsRedirect, @"The server has redirected to a non-https url.", nil, nil, nil, self.context.correlationId, nil); + NSError *error = MSIDCreateError(MSIDErrorDomain, MSIDErrorServerNonHttpsRedirect, @"The server has redirected to a non-https url.", nil, nil, nil, self.context.correlationId, nil); [self endWebAuthWithURL:nil error:error]; decisionHandler(WKNavigationActionPolicyCancel); diff --git a/IdentityCore/src/webview/embeddedWebview/challangeHandlers/MSIDPKeyAuthHandler.m b/IdentityCore/src/webview/embeddedWebview/challangeHandlers/MSIDPKeyAuthHandler.m index 8fca3f2a7..30abc5a9b 100644 --- a/IdentityCore/src/webview/embeddedWebview/challangeHandlers/MSIDPKeyAuthHandler.m +++ b/IdentityCore/src/webview/embeddedWebview/challangeHandlers/MSIDPKeyAuthHandler.m @@ -47,7 +47,7 @@ + (BOOL)handleChallenge:(NSString *)challengeUrl NSError *error = nil; if (!queryParamsMap || !submitUrl) { - error = MSIDCreateError(MSIDErrorDomain, MSIDErrorServerOauth, @"Incomplete PKeyAuth challenge received.", nil, nil, nil, context.correlationId, nil); + error = MSIDCreateError(MSIDOAuthErrorDomain, MSIDErrorServerOauth, @"Incomplete PKeyAuth challenge received.", nil, nil, nil, context.correlationId, nil); completionHandler(nil, error); } diff --git a/IdentityCore/src/webview/embeddedWebview/ui/MSIDWebviewUIController.h b/IdentityCore/src/webview/embeddedWebview/ui/MSIDWebviewUIController.h index de78cc3ea..e9703a93c 100644 --- a/IdentityCore/src/webview/embeddedWebview/ui/MSIDWebviewUIController.h +++ b/IdentityCore/src/webview/embeddedWebview/ui/MSIDWebviewUIController.h @@ -48,5 +48,6 @@ NSWindowController - (void)showLoadingIndicator; - (void)dismissLoadingIndicator; - (void)cancel; +- (void)userCancel; @end diff --git a/IdentityCore/src/webview/embeddedWebview/ui/ios/MSIDWebviewUIController.m b/IdentityCore/src/webview/embeddedWebview/ui/ios/MSIDWebviewUIController.m index 721792363..aecbe4f68 100644 --- a/IdentityCore/src/webview/embeddedWebview/ui/ios/MSIDWebviewUIController.m +++ b/IdentityCore/src/webview/embeddedWebview/ui/ios/MSIDWebviewUIController.m @@ -158,16 +158,10 @@ - (void)setupCancelButton { UIBarButtonItem *cancelButton = [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemCancel target:self - action:@selector(onCancel:)]; + action:@selector(userCancel)]; self.navigationItem.leftBarButtonItem = cancelButton; } -// Authentication was cancelled by the user -- (IBAction)onCancel:(__unused id)sender -{ - [self cancel]; -} - - (UIActivityIndicatorView *)prepareLoadingIndicator:(UIView *)rootView { UIActivityIndicatorView *loadingIndicator = [[UIActivityIndicatorView alloc] initWithActivityIndicatorStyle:UIActivityIndicatorViewStyleWhiteLarge]; @@ -176,11 +170,17 @@ - (UIActivityIndicatorView *)prepareLoadingIndicator:(UIView *)rootView return loadingIndicator; } +// This is reserved for subclass to handle programatic cancellation. - (void)cancel { // Overridden in subclass with cancel logic } +- (void)userCancel +{ + // Overridden in subclass with userCancel logic +} + #pragma mark - Background task - (void)startTrackingBackroundAppTransition diff --git a/IdentityCore/src/webview/embeddedWebview/ui/mac/MSIDCredentialCollectionController.m b/IdentityCore/src/webview/embeddedWebview/ui/mac/MSIDCredentialCollectionController.m index eb1a1c3c6..d1c64a3e8 100644 --- a/IdentityCore/src/webview/embeddedWebview/ui/mac/MSIDCredentialCollectionController.m +++ b/IdentityCore/src/webview/embeddedWebview/ui/mac/MSIDCredentialCollectionController.m @@ -24,28 +24,28 @@ #import "MSIDCredentialCollectionController.h" // UI position values for the input dialog -const CGFloat USERNAME_LABEL_X = 7; -const CGFloat USERNAME_LABEL_Y = 36; -const CGFloat USERNAME_LABEL_WIDTH = 73; -const CGFloat USERNAME_LABEL_HEIGHT = 17; -const CGFloat USERNAME_FIELD_X = 85; -const CGFloat USERNAME_FIELD_Y = 36; -const CGFloat USERNAME_FIELD_WIDTH = 210; -const CGFloat USERNAME_FIELD_HEIGHT = 22; +const CGFloat MSID_USERNAME_LABEL_X = 7; +const CGFloat MSID_USERNAME_LABEL_Y = 36; +const CGFloat MSID_USERNAME_LABEL_WIDTH = 73; +const CGFloat MSID_USERNAME_LABEL_HEIGHT = 17; +const CGFloat MSID_USERNAME_FIELD_X = 85; +const CGFloat MSID_USERNAME_FIELD_Y = 36; +const CGFloat MSID_USERNAME_FIELD_WIDTH = 210; +const CGFloat MSID_USERNAME_FIELD_HEIGHT = 22; -const CGFloat PASSWORD_LABEL_X = 7; -const CGFloat PASSWORD_LABEL_Y = 6; -const CGFloat PASSWORD_LABEL_WIDTH = 72; -const CGFloat PASSWORD_LABEL_HEIGHT = 17; -const CGFloat PASSWORD_FIELD_X = 85; -const CGFloat PASSWORD_FIELD_Y = 6; -const CGFloat PASSWORD_FIELD_WIDTH = 210; -const CGFloat PASSWORD_FIELD_HEIGHT = 22; +const CGFloat MSID_PASSWORD_LABEL_X = 7; +const CGFloat MSID_PASSWORD_LABEL_Y = 6; +const CGFloat MSID_PASSWORD_LABEL_WIDTH = 72; +const CGFloat MSID_PASSWORD_LABEL_HEIGHT = 17; +const CGFloat MSID_PASSWORD_FIELD_X = 85; +const CGFloat MSID_PASSWORD_FIELD_Y = 6; +const CGFloat MSID_PASSWORD_FIELD_WIDTH = 210; +const CGFloat MSID_PASSWORD_FIELD_HEIGHT = 22; -const CGFloat CUSTOM_VIEW_X = 0; -const CGFloat CUSTOM_VIEW_Y = 0; -const CGFloat CUSTOM_VIEW_WIDTH = 306; -const CGFloat CUSTOM_VIEW_HEIGHT = 63; +const CGFloat MSID_CUSTOM_VIEW_X = 0; +const CGFloat MSID_CUSTOM_VIEW_Y = 0; +const CGFloat MSID_CUSTOM_VIEW_WIDTH = 306; +const CGFloat MSID_CUSTOM_VIEW_HEIGHT = 63; @implementation MSIDCredentialCollectionController @@ -70,27 +70,27 @@ - (id)init { //Generate the NTLM input dialog by code for Mac //usename field - _usernameLabel = [[NSTextField alloc] initWithFrame:NSMakeRect(USERNAME_LABEL_X, USERNAME_LABEL_Y, USERNAME_LABEL_WIDTH, USERNAME_LABEL_HEIGHT)]; + _usernameLabel = [[NSTextField alloc] initWithFrame:NSMakeRect(MSID_USERNAME_LABEL_X, MSID_USERNAME_LABEL_Y, MSID_USERNAME_LABEL_WIDTH, MSID_USERNAME_LABEL_HEIGHT)]; [_usernameLabel setStringValue:NSLocalizedString(@"Username", nil)]; [_usernameLabel setBezeled:NO]; [_usernameLabel setDrawsBackground:NO]; [_usernameLabel setEditable:NO]; [_usernameLabel setSelectable:NO]; - _usernameField = [[NSTextField alloc] initWithFrame:NSMakeRect(USERNAME_FIELD_X, USERNAME_FIELD_Y, USERNAME_FIELD_WIDTH, USERNAME_FIELD_HEIGHT)]; + _usernameField = [[NSTextField alloc] initWithFrame:NSMakeRect(MSID_USERNAME_FIELD_X, MSID_USERNAME_FIELD_Y, MSID_USERNAME_FIELD_WIDTH, MSID_USERNAME_FIELD_HEIGHT)]; //password field - _passwordLabel = [[NSTextField alloc] initWithFrame:NSMakeRect(PASSWORD_LABEL_X, PASSWORD_LABEL_Y, PASSWORD_LABEL_WIDTH, PASSWORD_LABEL_HEIGHT)]; + _passwordLabel = [[NSTextField alloc] initWithFrame:NSMakeRect(MSID_PASSWORD_LABEL_X, MSID_PASSWORD_LABEL_Y, MSID_PASSWORD_LABEL_WIDTH, MSID_PASSWORD_LABEL_HEIGHT)]; [_passwordLabel setStringValue:NSLocalizedString(@"Password", nil)]; [_passwordLabel setBezeled:NO]; [_passwordLabel setDrawsBackground:NO]; [_passwordLabel setEditable:NO]; [_passwordLabel setSelectable:NO]; - _passwordField = [[NSSecureTextField alloc] initWithFrame:NSMakeRect(PASSWORD_FIELD_X, PASSWORD_FIELD_Y, PASSWORD_FIELD_WIDTH, PASSWORD_FIELD_HEIGHT)]; + _passwordField = [[NSSecureTextField alloc] initWithFrame:NSMakeRect(MSID_PASSWORD_FIELD_X, MSID_PASSWORD_FIELD_Y, MSID_PASSWORD_FIELD_WIDTH, MSID_PASSWORD_FIELD_HEIGHT)]; //add labels and fileds to view - _customView = [[NSView alloc] initWithFrame:NSMakeRect(CUSTOM_VIEW_X, CUSTOM_VIEW_Y, CUSTOM_VIEW_WIDTH, CUSTOM_VIEW_HEIGHT)]; + _customView = [[NSView alloc] initWithFrame:NSMakeRect(MSID_CUSTOM_VIEW_X, MSID_CUSTOM_VIEW_Y, MSID_CUSTOM_VIEW_WIDTH, MSID_CUSTOM_VIEW_HEIGHT)]; [_customView addSubview:_usernameLabel]; [_customView addSubview:_usernameField]; [_customView addSubview:_passwordLabel]; diff --git a/IdentityCore/src/webview/embeddedWebview/ui/mac/MSIDWebviewUIController.m b/IdentityCore/src/webview/embeddedWebview/ui/mac/MSIDWebviewUIController.m index d37d7956b..61540de28 100644 --- a/IdentityCore/src/webview/embeddedWebview/ui/mac/MSIDWebviewUIController.m +++ b/IdentityCore/src/webview/embeddedWebview/ui/mac/MSIDWebviewUIController.m @@ -148,7 +148,7 @@ - (void)windowWillClose:(__unused NSNotification *)notification { return; } - [self cancel]; + [self userCancel]; } - (NSProgressIndicator *)prepareLoadingIndicator @@ -166,9 +166,16 @@ - (NSProgressIndicator *)prepareLoadingIndicator return loadingIndicator; } +// This is reserved for subclass to handle programatic cancellation. - (void)cancel { // Overridden in subclass with cancel logic } +- (void)userCancel +{ + // Overridden in subclass with userCancel logic +} + + @end diff --git a/IdentityCore/src/webview/response/MSIDWebOAuth2Response.m b/IdentityCore/src/webview/response/MSIDWebOAuth2Response.m index 7049c3474..de325c3dd 100644 --- a/IdentityCore/src/webview/response/MSIDWebOAuth2Response.m +++ b/IdentityCore/src/webview/response/MSIDWebOAuth2Response.m @@ -45,7 +45,10 @@ - (instancetype)initWithURL:(NSURL *)url { if (error) { - *error = MSIDCreateError(MSIDOAuthErrorDomain, MSIDErrorInvalidParameter, @"Unexpected error has occured. There is no auth code nor an error", nil, nil, nil, context.correlationId, nil); + *error = MSIDCreateError(MSIDOAuthErrorDomain, + MSIDErrorServerInvalidResponse, + @"Unexpected error has occured. There is no auth code nor an error", + nil, nil, nil, context.correlationId, nil); } return nil; } diff --git a/IdentityCore/src/webview/response/MSIDWebWPJAuthResponse.m b/IdentityCore/src/webview/response/MSIDWebWPJAuthResponse.m index e8fbce7e3..dc1b0dfb8 100644 --- a/IdentityCore/src/webview/response/MSIDWebWPJAuthResponse.m +++ b/IdentityCore/src/webview/response/MSIDWebWPJAuthResponse.m @@ -41,7 +41,10 @@ - (instancetype)initWithURL:(NSURL *)url { if (error) { - *error = MSIDCreateError(MSIDOAuthErrorDomain, MSIDErrorInvalidParameter, @"WPJ response should have msauth as a scheme and wpj/broker as a host", nil, nil, nil, context.correlationId, nil); + *error = MSIDCreateError(MSIDOAuthErrorDomain, + MSIDErrorServerInvalidResponse, + @"WPJ response should have msauth as a scheme and wpj/broker as a host", + nil, nil, nil, context.correlationId, nil); } return nil; } diff --git a/IdentityCore/src/webview/response/MSIDWebviewResponse.m b/IdentityCore/src/webview/response/MSIDWebviewResponse.m index f6304e52d..6dec925bb 100644 --- a/IdentityCore/src/webview/response/MSIDWebviewResponse.m +++ b/IdentityCore/src/webview/response/MSIDWebviewResponse.m @@ -37,7 +37,10 @@ - (instancetype)initWithURL:(NSURL *)url if (!url) { if (error){ - *error = MSIDCreateError(MSIDOAuthErrorDomain, MSIDErrorInvalidParameter, @"Trying to create a response with nil URL", nil, nil, nil, context.correlationId, nil); + *error = MSIDCreateError(MSIDOAuthErrorDomain, + MSIDErrorServerInvalidResponse, + @"Trying to create a response with nil URL", + nil, nil, nil, context.correlationId, nil); } return nil; } diff --git a/IdentityCore/src/webview/systemWebview/MSIDSFAuthenticationSession.h b/IdentityCore/src/webview/systemWebview/MSIDSFAuthenticationSession.h index cf8896803..d151fa2ed 100644 --- a/IdentityCore/src/webview/systemWebview/MSIDSFAuthenticationSession.h +++ b/IdentityCore/src/webview/systemWebview/MSIDSFAuthenticationSession.h @@ -24,6 +24,7 @@ // THE SOFTWARE. // //------------------------------------------------------------------------------ +#if !MSID_EXCLUDE_SYSTEMWV #import #import "MSIDSystemWebviewController.h" @@ -38,4 +39,4 @@ @property (readonly) NSString *callbackURLScheme; @end - +#endif diff --git a/IdentityCore/src/webview/systemWebview/MSIDSFAuthenticationSession.m b/IdentityCore/src/webview/systemWebview/MSIDSFAuthenticationSession.m index 10d899bbc..33ea717f2 100644 --- a/IdentityCore/src/webview/systemWebview/MSIDSFAuthenticationSession.m +++ b/IdentityCore/src/webview/systemWebview/MSIDSFAuthenticationSession.m @@ -25,14 +25,18 @@ // //------------------------------------------------------------------------------ +#if !MSID_EXCLUDE_SYSTEMWV + #import "MSIDSFAuthenticationSession.h" -#import + #import "MSIDWebviewAuthorization.h" #import "MSIDWebOAuth2Response.h" #import "MSIDTelemetry+Internal.h" #import "MSIDTelemetryUIEvent.h" #import "MSIDTelemetryEventStrings.h" +#import + @implementation MSIDSFAuthenticationSession { API_AVAILABLE(ios(11.0)) @@ -43,10 +47,13 @@ @implementation MSIDSFAuthenticationSession id _context; + MSIDWebUICompletionHandler _completionHandler; + NSString *_telemetryRequestId; MSIDTelemetryUIEvent *_telemetryEvent; } + - (instancetype)initWithURL:(NSURL *)url callbackURLScheme:(NSString *)callbackURLScheme context:(id)context @@ -69,6 +76,8 @@ - (void)startWithCompletionHandler:(MSIDWebUICompletionHandler)completionHandler _telemetryEvent = [[MSIDTelemetryUIEvent alloc] initWithName:MSID_TELEMETRY_EVENT_UI_EVENT context:_context]; + _completionHandler = [completionHandler copy]; + if (@available(iOS 11.0, *)) { _authSession = [[SFAuthenticationSession alloc] initWithURL:_startURL @@ -87,8 +96,7 @@ - (void)startWithCompletionHandler:(MSIDWebUICompletionHandler)completionHandler [[MSIDTelemetry sharedInstance] stopEvent:_telemetryRequestId event:_telemetryEvent]; completionHandler(callbackURL, error); }]; - [_authSession start]; - return; + if ([_authSession start]) return; } NSError *error = MSIDCreateError(MSIDErrorDomain, MSIDErrorInteractiveSessionStartFailure, @"Failed to start an interactive session", nil, nil, nil, _context.correlationId, nil); @@ -102,7 +110,13 @@ - (void)cancel [_telemetryEvent setIsCancelled:YES]; [[MSIDTelemetry sharedInstance] stopEvent:_telemetryRequestId event:_telemetryEvent]; [_authSession cancel]; + + NSError *error = MSIDCreateError(MSIDErrorDomain, + MSIDErrorSessionCanceledProgrammatically, + @"Authorization session was cancelled programatically.", nil, nil, nil, _context.correlationId, nil); + _completionHandler(nil, error); } -@end +@end +#endif diff --git a/IdentityCore/src/webview/systemWebview/MSIDSafariViewController.h b/IdentityCore/src/webview/systemWebview/MSIDSafariViewController.h index 200662281..af85c052b 100644 --- a/IdentityCore/src/webview/systemWebview/MSIDSafariViewController.h +++ b/IdentityCore/src/webview/systemWebview/MSIDSafariViewController.h @@ -25,6 +25,7 @@ // //------------------------------------------------------------------------------ +#if !MSID_EXCLUDE_SYSTEMWV #import #import "MSIDSystemWebviewController.h" @@ -38,3 +39,5 @@ @property (readonly) NSURL *startURL; @end +#endif + diff --git a/IdentityCore/src/webview/systemWebview/MSIDSafariViewController.m b/IdentityCore/src/webview/systemWebview/MSIDSafariViewController.m index 18e085d78..40e8be8dc 100644 --- a/IdentityCore/src/webview/systemWebview/MSIDSafariViewController.m +++ b/IdentityCore/src/webview/systemWebview/MSIDSafariViewController.m @@ -25,6 +25,8 @@ // //------------------------------------------------------------------------------ +#if !MSID_EXCLUDE_SYSTEMWV + #import "MSIDSafariViewController.h" #import "MSIDSystemWebviewController.h" #import @@ -70,7 +72,7 @@ - (instancetype)initWithURL:(NSURL *)url - (void)cancel { - NSError *error = MSIDCreateError(MSIDErrorDomain, MSIDErrorSessionCanceled, @"Authorization session was cancelled programatically", nil, nil, nil, _context.correlationId, nil); + NSError *error = MSIDCreateError(MSIDErrorDomain, MSIDErrorSessionCanceledProgrammatically, @"Authorization session was cancelled programatically", nil, nil, nil, _context.correlationId, nil); [self completeSessionWithResponse:nil context:_context error:error]; } @@ -143,3 +145,4 @@ - (void)safariViewControllerDidFinish:(SFSafariViewController *)controller } @end +#endif diff --git a/IdentityCore/src/webview/systemWebview/MSIDSystemWebviewController.h b/IdentityCore/src/webview/systemWebview/MSIDSystemWebviewController.h index 60016d502..eb97a4ca5 100644 --- a/IdentityCore/src/webview/systemWebview/MSIDSystemWebviewController.h +++ b/IdentityCore/src/webview/systemWebview/MSIDSystemWebviewController.h @@ -24,6 +24,7 @@ // THE SOFTWARE. // //------------------------------------------------------------------------------ +#if !MSID_EXCLUDE_SYSTEMWV #import #import "MSIDWebviewInteracting.h" @@ -42,3 +43,5 @@ @property (readonly) NSString *callbackURLScheme; @end +#endif + diff --git a/IdentityCore/src/webview/systemWebview/MSIDSystemWebviewController.m b/IdentityCore/src/webview/systemWebview/MSIDSystemWebviewController.m index 32a8731b9..6683ba8cb 100644 --- a/IdentityCore/src/webview/systemWebview/MSIDSystemWebviewController.m +++ b/IdentityCore/src/webview/systemWebview/MSIDSystemWebviewController.m @@ -24,6 +24,7 @@ // THE SOFTWARE. // //------------------------------------------------------------------------------ +#if !MSID_EXCLUDE_SYSTEMWV #import "MSIDSystemWebviewController.h" #import "MSIDSFAuthenticationSession.h" @@ -122,3 +123,4 @@ - (BOOL)handleURLResponseForSafariViewController:(NSURL *)url } @end +#endif diff --git a/IdentityCore/tests/MSIDAADV2Oauth2FactoryTests.m b/IdentityCore/tests/MSIDAADV2Oauth2FactoryTests.m index d041c1e78..0782f954d 100644 --- a/IdentityCore/tests/MSIDAADV2Oauth2FactoryTests.m +++ b/IdentityCore/tests/MSIDAADV2Oauth2FactoryTests.m @@ -152,7 +152,7 @@ - (void)testVerifyResponse_whenOAuthErrorViaAuthCode_shouldReturnError XCTAssertFalse(result); XCTAssertEqual(error.domain, MSIDOAuthErrorDomain); - XCTAssertEqual(error.code, MSIDErrorInvalidGrant); + XCTAssertEqual(error.code, MSIDErrorServerInvalidGrant); XCTAssertEqualObjects(error.userInfo[MSIDOAuthErrorKey], @"invalid_grant"); } diff --git a/IdentityCore/tests/MSIDOauth2FactoryTests.m b/IdentityCore/tests/MSIDOauth2FactoryTests.m index c88535ff0..35203c186 100644 --- a/IdentityCore/tests/MSIDOauth2FactoryTests.m +++ b/IdentityCore/tests/MSIDOauth2FactoryTests.m @@ -108,7 +108,7 @@ - (void)testVerifyResponse_whenOAuthError_shouldReturnError XCTAssertFalse(result); XCTAssertEqual(error.domain, MSIDOAuthErrorDomain); - XCTAssertEqual(error.code, MSIDErrorInvalidGrant); + XCTAssertEqual(error.code, MSIDErrorServerInvalidGrant); XCTAssertEqualObjects(error.userInfo[MSIDOAuthErrorKey], @"invalid_grant"); } diff --git a/IdentityCore/tests/MSIDSystemWebviewControllerTests.m b/IdentityCore/tests/MSIDSystemWebviewControllerTests.m index 94d1b01ed..b761f0373 100644 --- a/IdentityCore/tests/MSIDSystemWebviewControllerTests.m +++ b/IdentityCore/tests/MSIDSystemWebviewControllerTests.m @@ -21,6 +21,8 @@ // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN // THE SOFTWARE. +#if !MSID_EXCLUDE_SYSTEMWV + #import #import "MSIDSystemWebviewController.h" @@ -68,3 +70,6 @@ - (void)testInitWithStartURL_whenStartURLandCallbackURLSchemeValid_shouldSucceed } @end + +#endif + diff --git a/IdentityCore/tests/MSIDWebOAuth2ResponseTests.m b/IdentityCore/tests/MSIDWebOAuth2ResponseTests.m index 9e6d28e58..3ff958daf 100644 --- a/IdentityCore/tests/MSIDWebOAuth2ResponseTests.m +++ b/IdentityCore/tests/MSIDWebOAuth2ResponseTests.m @@ -40,7 +40,7 @@ - (void)testInitWithParameters_whenNoAuthCodeAndNoError_shouldReturnNilAndInvali NSError *error = nil; XCTAssertNil([[MSIDWebOAuth2Response alloc] initWithURL:[NSURL URLWithString:@"https://contoso.com"] context:nil error:&error]); - XCTAssertEqual(error.code, MSIDErrorInvalidParameter); + XCTAssertEqual(error.code, MSIDErrorServerInvalidResponse); } - (void)testInitWithParameters_whenAuthCode_shouldReturnAuthCode @@ -82,7 +82,7 @@ - (void)testInitWithParameters_whenOAuthServerError_shouldReturnAuthCode XCTAssertNotNil(response.oauthError); XCTAssertEqualObjects(response.oauthError.domain, MSIDOAuthErrorDomain); - XCTAssertEqual(response.oauthError.code, MSIDErrorInvalidGrant); + XCTAssertEqual(response.oauthError.code, MSIDErrorServerInvalidGrant); XCTAssertEqualObjects(response.oauthError.userInfo[MSIDErrorDescriptionKey], errorDescription); XCTAssertEqualObjects(response.oauthError.userInfo[MSIDOAuthErrorKey], errorString); diff --git a/IdentityCore/tests/MSIDWebWPJResponseTests.m b/IdentityCore/tests/MSIDWebWPJResponseTests.m index 96b8a9405..bea5f8f20 100644 --- a/IdentityCore/tests/MSIDWebWPJResponseTests.m +++ b/IdentityCore/tests/MSIDWebWPJResponseTests.m @@ -46,7 +46,7 @@ - (void)testInit_whenWrongScheme_shouldReturnNilWithError XCTAssertNotNil(error); XCTAssertEqualObjects(error.domain, MSIDOAuthErrorDomain); - XCTAssertEqual(error.code, MSIDErrorInvalidParameter); + XCTAssertEqual(error.code, MSIDErrorServerInvalidResponse); } diff --git a/IdentityCore/tests/MSIDWebviewAuthorizationTests.m b/IdentityCore/tests/MSIDWebviewAuthorizationTests.m index 7cd9ffc52..d021af3eb 100644 --- a/IdentityCore/tests/MSIDWebviewAuthorizationTests.m +++ b/IdentityCore/tests/MSIDWebviewAuthorizationTests.m @@ -79,7 +79,7 @@ - (void)testStartSession_whenSessionIsNil_shouldReturnErrorAtCompletionHandler completionHandler:^(MSIDWebviewResponse *response, NSError *error) { XCTAssertNil(response); XCTAssertNotNil(error); - XCTAssertEqual(error.code, MSIDErrorInvalidRequest); + XCTAssertEqual(error.code, MSIDErrorInternal); [expectation fulfill]; }]; @@ -192,7 +192,7 @@ - (void)testCancelCurrentSession_whenCurrentSession_shouldClearCurrentSession #pragma mark - Handle response -#if TARGET_OS_IPHONE +#if TARGET_OS_IPHONE && !MSID_EXCLUDE_SYSTEMWV - (void)testHandleURLResponseForSystemWebviewController_whenCurrentSessionIsSafari_shouldHandleURL { MSIDTestWebviewInteractingViewController *testWebviewController = [MSIDTestWebviewInteractingViewController new]; diff --git a/IdentityCore/tests/MSIDWebviewFactoryTests.m b/IdentityCore/tests/MSIDWebviewFactoryTests.m index 825c7b5ad..720046f43 100644 --- a/IdentityCore/tests/MSIDWebviewFactoryTests.m +++ b/IdentityCore/tests/MSIDWebviewFactoryTests.m @@ -185,7 +185,7 @@ - (void)testResponseWithURL_whenStateVerificationFailsAndVerifyStateIsYES_should XCTAssertNil(response); XCTAssertNotNil(error); - XCTAssertEqual(error.code, MSIDErrorInvalidState); + XCTAssertEqual(error.code, MSIDErrorServerInvalidState); } diff --git a/IdentityCore/tests/MSIDWebviewResponseTests.m b/IdentityCore/tests/MSIDWebviewResponseTests.m index f811c0264..194f7d5be 100644 --- a/IdentityCore/tests/MSIDWebviewResponseTests.m +++ b/IdentityCore/tests/MSIDWebviewResponseTests.m @@ -47,7 +47,7 @@ - (void)testInitWithURL_whenNilURL_shouldReturnNilAndError XCTAssertNil(response); XCTAssertNotNil(error); - XCTAssertEqual(error.code, MSIDErrorInvalidParameter); + XCTAssertEqual(error.code, MSIDErrorServerInvalidResponse); } - (void)testInitWithURL_whenURLWithParams_shouldReturnInstanceWithParams diff --git a/IdentityCore/tests/util/MSIDTestWebviewInteractingViewController.m b/IdentityCore/tests/util/MSIDTestWebviewInteractingViewController.m index fc30cfa9c..8add431bb 100644 --- a/IdentityCore/tests/util/MSIDTestWebviewInteractingViewController.m +++ b/IdentityCore/tests/util/MSIDTestWebviewInteractingViewController.m @@ -55,7 +55,7 @@ - (void)cancel - (BOOL)isKindOfClass:(Class)aClass { -#if TARGET_OS_IPHONE +#if TARGET_OS_IPHONE && !MSID_EXCLUDE_SYSTEMWV if (self.actAsSafariViewController) { return (aClass == MSIDSystemWebviewController.class); diff --git a/IdentityCore/xcconfig/identitycore__common.xcconfig b/IdentityCore/xcconfig/identitycore__common.xcconfig index ff222a724..e5468c5c9 100644 --- a/IdentityCore/xcconfig/identitycore__common.xcconfig +++ b/IdentityCore/xcconfig/identitycore__common.xcconfig @@ -40,3 +40,8 @@ OTHER_LDFLAGS = -ObjC SKIP_INSTALL = YES OTHER_CFLAGS=$(inherited) -fstack-protector-strong + +// This is a conditional inclusion. It searches parent projects +// /xcconfig folder. +#include? "../../../xcconfig/adal__additional_settings.xcconfig" +