Skip to content

Commit 4e1f4bc

Browse files
author
kai
committed
Add shouldFallBack to requestController protocol
1 parent 1de9567 commit 4e1f4bc

File tree

4 files changed

+39
-0
lines changed

4 files changed

+39
-0
lines changed

IdentityCore/src/controllers/MSIDLocalInteractiveController.m

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -242,4 +242,9 @@ - (void)acquireTokenWithRequest:(MSIDInteractiveTokenRequest *)request
242242
}];
243243
}
244244

245+
- (BOOL)shouldFallback:(NSError *)error
246+
{
247+
return YES;
248+
}
249+
245250
@end

IdentityCore/src/controllers/MSIDRequestControlling.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ NS_ASSUME_NONNULL_BEGIN
3131
@protocol MSIDRequestControlling <NSObject>
3232

3333
- (void)acquireToken:(nonnull MSIDRequestCompletionBlock)completionBlock;
34+
- (BOOL)shouldFallback:(nonnull NSError *)error;
3435

3536
@end
3637

IdentityCore/src/controllers/MSIDSilentController.m

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -158,4 +158,9 @@ - (void)acquireTokenWithRequest:(MSIDSilentTokenRequest *)request
158158
}];
159159
}
160160

161+
- (BOOL)shouldFallback:(NSError *)error
162+
{
163+
return YES;
164+
}
165+
161166
@end

IdentityCore/src/controllers/broker/MSIDSSOExtensionSilentTokenRequestController.m

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,5 +49,33 @@ + (BOOL)canPerformRequest
4949
return [[ASAuthorizationSingleSignOnProvider msidSharedProvider] canPerformAuthorization];
5050
}
5151

52+
- (BOOL)shouldFallback:(NSError *)error
53+
{
54+
MSID_LOG_WITH_CTX(MSIDLogLevelInfo, self.requestParameters, @"Looking if we should fallback to fallback controller, error: %ld error domain: %@.", (long)error.code, error.domain);
55+
56+
if (!self.fallbackController)
57+
{
58+
MSID_LOG_WITH_CTX(MSIDLogLevelInfo, self.requestParameters, @"fallback controller is nil, SSO extension controller should fallback: NO");
59+
return NO;
60+
}
61+
62+
// If it is MSIDErrorDomain and Sso Extension returns unexpected error, we should fall back to local controler and unblock user
63+
if (![error.domain isEqualToString:ASAuthorizationErrorDomain] && ![error.domain isEqualToString:MSIDErrorDomain]) return NO;
64+
65+
BOOL shouldFallback = NO;
66+
switch (error.code)
67+
{
68+
case ASAuthorizationErrorNotHandled:
69+
case ASAuthorizationErrorUnknown:
70+
case ASAuthorizationErrorFailed:
71+
case MSIDErrorSSOExtensionUnexpectedError:
72+
shouldFallback = YES;
73+
}
74+
75+
MSID_LOG_WITH_CTX(MSIDLogLevelInfo, self.requestParameters, @"SSO extension controller should fallback: %@", shouldFallback ? @"YES" : @"NO");
76+
77+
return shouldFallback;
78+
}
79+
5280
@end
5381
#endif

0 commit comments

Comments
 (0)