Skip to content

Commit dfe40b0

Browse files
committed
framework poc
1 parent 54cc097 commit dfe40b0

File tree

1 file changed

+22
-1
lines changed

1 file changed

+22
-1
lines changed

IdentityCore/src/webview/embeddedWebview/MSIDAADOAuthEmbeddedWebviewController.m

Lines changed: 22 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -264,8 +264,28 @@ - (void)executeViewNavigationAction:(MSIDWebviewNavigationAction *)action
264264
MSID_LOG_WITH_CTX(MSIDLogLevelError, self.context, @"OpenASWebAuthSession action has nil URL");
265265
[self completeWebAuthWithURL:requestURL];
266266
}
267-
break;
268267
// alternatively replace above action with the delegate method to handoff to ASWebAuthSession
268+
id<MSIDWebviewSpecialNavigationDelegate> strongSpecialNavigationDelegate = self.specialNavigationDelegate;
269+
if (strongSpecialNavigationDelegate)
270+
{
271+
if ([strongSpecialNavigationDelegate respondsToSelector:@selector(webviewController:handleSpecialRedirect:completion:)])
272+
{
273+
MSID_LOG_WITH_CTX(MSIDLogLevelInfo, self.context,
274+
@"Detected special redirect scheme: %@. Delegating to navigationDelegate.", requestURL.scheme);
275+
276+
// Call delegate on main thread
277+
__weak typeof(self) weakSelf = self;
278+
dispatch_async(dispatch_get_main_queue(), ^{
279+
__strong typeof(self) strongSelf = weakSelf;
280+
if (!strongSelf) return;
281+
282+
[strongSpecialNavigationDelegate handleASWebAuthenticationTransitionWithUrl:action.url embeddedWebview:strongSelf additionalHeaders:action.additionalHeaders MSIDSystemWebviewPurpose:action.purpose completion:^(MSIDWebviewNavigationAction * _Nonnull navigationAction, NSError * _Nonnull aswebAuthError) {
283+
[strongSelf executeViewNavigationAction:navigationAction requestURL:requestURL error:aswebAuthError]; //need to test if this recursion could cause any issue
284+
}];
285+
});
286+
}
287+
}
288+
break;
269289
}
270290

271291
case MSIDWebviewNavigationActionTypeCompleteWebAuthWithURL:
@@ -292,6 +312,7 @@ - (void)executeViewNavigationAction:(MSIDWebviewNavigationAction *)action
292312
}
293313
}
294314

315+
295316
@end
296317

297318
#endif

0 commit comments

Comments
 (0)