Skip to content

Commit c611d34

Browse files
authored
Merge branch 'dev' into ameyapat/generate-jwe-crypto-from-stk
2 parents 1ad453a + 0d7969e commit c611d34

39 files changed

+1243
-172
lines changed

IdentityCore/IdentityCore.xcodeproj/project.pbxproj

Lines changed: 38 additions & 8 deletions
Large diffs are not rendered by default.

IdentityCore/src/MSIDConstants.h

Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -95,10 +95,10 @@ typedef NS_ENUM(NSInteger, MSIDHeaderType)
9595

9696
typedef NS_ENUM(NSUInteger, MSIDXpcMode)
9797
{
98-
MSIDXpcModeDisable = 0, // Broker Xpc service call is disabled
99-
MSIDXpcModeBackup,// Broker Xpc service call is only used as a backup service when SsoExtension service failed. If SsoExtenion is not available on the device (canPerformRequest returns false), Broker Xpc service call will be disabled
100-
MSIDXpcModeFull, // Broker Xpc service call is used as a backup call when SsoExtension service failed. If SsoExtenion is not available on the device, Xpc service call will be the primary auth service
101-
MSIDXpcModeOverride // Development only: Broker Xpc service is used as main Sso service, and ignored SsoExtension service completely. This option will be ignored in production and will be treated same as MSIDXpcModeDisable
98+
MSIDXpcModeDisabled = 0, // Broker Xpc service call is disabled
99+
MSIDXpcModeSSOExtCompanion,// Broker Xpc service call is only used as a backup service when SsoExtension service failed. If SsoExtension is not available on the device (canPerformRequest returns false), Broker Xpc service call will be disabled
100+
MSIDXpcModeSSOExtBackup, // Broker Xpc service call is used as a backup call when SsoExtension service failed. If SsoExtension is not available on the device, Xpc service call will be the primary auth service
101+
MSIDXpcModePrimary // Development only: Broker Xpc service is used as main Sso service, and ignored SsoExtension service completely. This option will be ignored in production and will be treated same as MSIDXpcModeDisable
102102
};
103103

104104
typedef void (^MSIDRequestCompletionBlock)(MSIDTokenResult * _Nullable result, NSError * _Nullable error);
@@ -215,4 +215,15 @@ extern NSString * _Nonnull const MSID_FLIGHT_USE_V2_WEB_RESPONSE_FACTORY;
215215
extern NSString * _Nonnull const MSID_FLIGHT_SUPPORT_DUNA_CBA;
216216
extern NSString * _Nonnull const MSID_FLIGHT_CLIENT_SFRT_STATUS;
217217

218+
/**
219+
* Flight to indicate if remove account artifacts should be disabled
220+
* Owner: Antonio
221+
* Link: N/A - No ECS flag created as this is a disable flight to be created on demand
222+
* Created Date: N/A
223+
* Status: Not started
224+
* Fully Allocated: Not Started
225+
* WorkItem: 3168316
226+
*/
227+
extern NSString * _Nonnull const MSID_FLIGHT_DISABLE_REMOVE_ACCOUNT_ARTIFACTS;
228+
218229
#define METHODANDLINE [NSString stringWithFormat:@"%s [Line %d]", __PRETTY_FUNCTION__, __LINE__]

IdentityCore/src/MSIDConstants.m

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,10 @@
8585

8686
NSString *const MSID_FLIGHT_USE_V2_WEB_RESPONSE_FACTORY = @"use_v2_web_response_factory";
8787
NSString *const MSID_FLIGHT_SUPPORT_DUNA_CBA = @"support_duna_cba_v2";
88-
NSString *const MSID_FLIGHT_CLIENT_SFRT_STATUS = @"sfrt_status";
88+
NSString *const MSID_FLIGHT_CLIENT_SFRT_STATUS = @"sfrt_v2";
89+
90+
// Making the flight string short to avoid legacy broker url size limit
91+
NSString *const MSID_FLIGHT_DISABLE_REMOVE_ACCOUNT_ARTIFACTS = @"disable_rm_metadata";
8992

9093

9194
#define METHODANDLINE [NSString stringWithFormat:@"%s [Line %d]", __PRETTY_FUNCTION__, __LINE__]

IdentityCore/src/MSIDError.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -364,6 +364,9 @@ typedef NS_ENUM(NSInteger, MSIDErrorCode)
364364
// App state while failed to open broker error
365365
MSIDErrorBrokerAppIsInactive = -51902,
366366
MSIDErrorBrokerAppIsInBackground = -51903,
367+
368+
// Broker Xpc internal error
369+
MSIDErrorBrokerXpcUnexpectedError = -52001,
367370

368371
};
369372

IdentityCore/src/MSIDError.m

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -447,6 +447,9 @@ void MSIDFillAndLogError(NSError **error, MSIDErrorCode errorCode, NSString *err
447447
return @"MSIDErrorBrokerAppIsInactive";
448448
case MSIDErrorBrokerAppIsInBackground:
449449
return @"MSIDErrorBrokerAppIsInBackground";
450+
// Broker Xpc internal error
451+
case MSIDErrorBrokerXpcUnexpectedError:
452+
return @"MSIDErrorBrokerXpcUnexpectedError";
450453
}
451454

452455
return [NSString stringWithFormat:@"Unknown: %@", @(errorCode)];

IdentityCore/src/MSIDOAuth2Constants.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -170,6 +170,7 @@ extern NSString *const MSID_PREFERRED_USERNAME_MISSING;
170170

171171
extern NSString *const MSIDServerErrorClientMismatch;
172172
extern NSString *const MSIDServerErrorBadToken;
173+
extern NSString *const MSIDServerErrorUserAccountDeleted;
173174

174175
extern NSString *const MSID_CCS_REQUEST_ID_KEY;
175176
extern NSString *const MSID_CCS_REQUEST_ID_RESPONSE;

IdentityCore/src/MSIDOAuth2Constants.m

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -170,6 +170,7 @@
170170

171171
NSString *const MSIDServerErrorClientMismatch = @"client_mismatch";
172172
NSString *const MSIDServerErrorBadToken = @"bad_token";
173+
NSString *const MSIDServerErrorUserAccountDeleted = @"user_account_deleted";
173174

174175
NSString *const MSID_CCS_REQUEST_ID_KEY = @"x-ms-ccs-requestid";
175176
NSString *const MSID_CCS_REQUEST_ID_RESPONSE = @"ccs-requestid";

IdentityCore/src/cache/metadata/MSIDAccountMetadataCacheAccessor.h

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -77,4 +77,9 @@
7777
- (MSIDAccountMetadataCacheItem *)retrieveAccountMetadataCacheItemForClientId:(NSString *)clientId
7878
context:(id<MSIDRequestContext>)context
7979
error:(NSError *__autoreleasing*)error;
80+
81+
- (BOOL)removeAccountMetadataForHomeAccountId:(NSString *)homeAccountId
82+
context:(id<MSIDRequestContext>)context
83+
error:(NSError *__autoreleasing*)error;
84+
8085
@end

IdentityCore/src/controllers/MSIDRequestControllerFactory.m

Lines changed: 58 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@
3737
#import "MSIDSignoutController.h"
3838
#if TARGET_OS_OSX
3939
#import "MSIDXpcSilentTokenRequestController.h"
40+
#import "MSIDXpcInteractiveTokenRequestController.h"
4041
#endif
4142

4243
@implementation MSIDRequestControllerFactory
@@ -47,7 +48,7 @@ @implementation MSIDRequestControllerFactory
4748
tokenRequestProvider:(id<MSIDTokenRequestProviding>)tokenRequestProvider
4849
error:(NSError *__autoreleasing*)error
4950
{
50-
if (parameters.xpcMode == MSIDXpcModeDisable)
51+
if (parameters.xpcMode == MSIDXpcModeDisabled)
5152
{
5253
return [self SilentControllerWithoutXpcForParameters:parameters
5354
forceRefresh:forceRefresh
@@ -164,14 +165,14 @@ @implementation MSIDRequestControllerFactory
164165

165166
MSIDSilentController *xpcController = nil;
166167
#if TARGET_OS_OSX
167-
if (parameters.xpcMode != MSIDXpcModeDisable && [MSIDXpcSilentTokenRequestController canPerformRequest])
168+
if (parameters.xpcMode != MSIDXpcModeDisabled && [MSIDXpcSilentTokenRequestController canPerformRequest])
168169
{
169170
xpcController = [[MSIDXpcSilentTokenRequestController alloc] initWithRequestParameters:parameters
170171
forceRefresh:forceRefresh
171172
tokenRequestProvider:tokenRequestProvider
172173
fallbackInteractiveController:fallbackController
173174
error:error];
174-
if (parameters.xpcMode == MSIDXpcModeFull || parameters.xpcMode == MSIDXpcModeOverride)
175+
if (parameters.xpcMode == MSIDXpcModeSSOExtBackup || parameters.xpcMode == MSIDXpcModePrimary)
175176
{
176177
// If in Xpc full mode, the XPCController will work as a isolated controller when SsoExtension cannotPerformRequest
177178
fallbackController = xpcController;
@@ -180,7 +181,7 @@ @implementation MSIDRequestControllerFactory
180181
}
181182
#endif
182183

183-
BOOL shouldSkipSsoExtension = parameters.xpcMode == MSIDXpcModeOverride;
184+
BOOL shouldSkipSsoExtension = parameters.xpcMode == MSIDXpcModePrimary;
184185

185186
if (!shouldSkipSsoExtension && [MSIDSSOExtensionSilentTokenRequestController canPerformRequest])
186187
{
@@ -328,15 +329,47 @@ @implementation MSIDRequestControllerFactory
328329
return nil;
329330
}
330331
#else
332+
331333
+ (nullable id<MSIDRequestControlling>)brokerController:(nonnull MSIDInteractiveTokenRequestParameters *)parameters
332334
tokenRequestProvider:(nonnull id<MSIDTokenRequestProviding>)tokenRequestProvider
333335
fallbackController:(nullable id<MSIDRequestControlling>)fallbackController
334336
error:(NSError * _Nullable __autoreleasing * _Nullable)error
335337
{
336-
return [self ssoExtensionInteractiveController:parameters
337-
tokenRequestProvider:tokenRequestProvider
338-
fallbackController:fallbackController
339-
error:error];
338+
id<MSIDRequestControlling> xpcController = nil;
339+
340+
// By default the xpc flow is disable, and should fallback to previous flow in else condition
341+
if (parameters.xpcMode != MSIDXpcModeDisabled)
342+
{
343+
xpcController = [self xpcInteractiveController:parameters
344+
tokenRequestProvider:tokenRequestProvider
345+
fallbackController:fallbackController
346+
error:error];
347+
if (parameters.xpcMode == MSIDXpcModeSSOExtCompanion || parameters.xpcMode == MSIDXpcModeSSOExtBackup)
348+
{
349+
id<MSIDRequestControlling> ssoExtensionController = [self ssoExtensionInteractiveController:parameters
350+
tokenRequestProvider:tokenRequestProvider
351+
fallbackController:xpcController?:fallbackController
352+
error:error];
353+
if (parameters.xpcMode == MSIDXpcModeSSOExtBackup && !ssoExtensionController)
354+
{
355+
return xpcController;
356+
}
357+
358+
return ssoExtensionController;
359+
}
360+
else
361+
{
362+
// Development only: MSIDXpcModePrimary
363+
return xpcController;
364+
}
365+
}
366+
else
367+
{
368+
return [self ssoExtensionInteractiveController:parameters
369+
tokenRequestProvider:tokenRequestProvider
370+
fallbackController:fallbackController
371+
error:error];
372+
}
340373
}
341374
#endif
342375

@@ -356,6 +389,23 @@ @implementation MSIDRequestControllerFactory
356389
return nil;
357390
}
358391

392+
#if TARGET_OS_OSX
393+
+ (nullable id<MSIDRequestControlling>)xpcInteractiveController:(nonnull MSIDInteractiveTokenRequestParameters *)parameters
394+
tokenRequestProvider:(nonnull id<MSIDTokenRequestProviding>)tokenRequestProvider
395+
fallbackController:(nullable id<MSIDRequestControlling>)fallbackController
396+
error:(NSError * _Nullable __autoreleasing * _Nullable)error
397+
{
398+
if ([MSIDXpcInteractiveTokenRequestController canPerformRequest])
399+
{
400+
return [[MSIDXpcInteractiveTokenRequestController alloc] initWithInteractiveRequestParameters:parameters
401+
tokenRequestProvider:tokenRequestProvider
402+
fallbackController:fallbackController
403+
error:error];
404+
}
405+
406+
return nil;
407+
}
408+
#endif
359409

360410
+ (nullable id<MSIDRequestControlling>)localInteractiveController:(nonnull MSIDInteractiveTokenRequestParameters *)parameters
361411
tokenRequestProvider:(nonnull id<MSIDTokenRequestProviding>)tokenRequestProvider

IdentityCore/src/controllers/MSIDSilentController.m

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -143,8 +143,8 @@ - (void)acquireTokenWithRequest:(MSIDSilentTokenRequest *)request
143143
self.currentRequest = nil;
144144
MSIDRequestCompletionBlock completionBlockWrapper = ^(MSIDTokenResult *fallResult, NSError *fallError)
145145
{
146-
// We don't have any meaningful information from fallback controller (edge case of SSO error) so we use the local controller result earlier
147-
if (!fallResult && (fallError.code == MSIDErrorSSOExtensionUnexpectedError))
146+
// We don't have any meaningful information from fallback controller (edge case of SSO/Xpc error) so we use the local controller result earlier
147+
if (!fallResult && (fallError.code == MSIDErrorSSOExtensionUnexpectedError || fallError.code == MSIDErrorBrokerXpcUnexpectedError))
148148
{
149149
completionBlock(result, error);
150150
}

0 commit comments

Comments
 (0)