AzureAD / azure-activedirectory-library-for-objc

The ADAL SDK for Objective C gives you the ability to add support for Work Accounts to your iOS and macOS applications with just a few lines of additional code. This SDK gives your application the full functionality of Microsoft Azure AD, including industry standard protocol support for OAuth2, Web API integration with user level consent, and two factor authentication support.
MIT License
178 stars 113 forks source link

Crash in MSIDWebviewUIController on iOS 14 before showing the auth webview #1558

Closed mdivkovic-speech closed 4 years ago

mdivkovic-speech commented 4 years ago

ADAL version: 4.0.10 iOS version: 14.x.x Expected behavior: Shows auth webview Actual behavior: Crashes

We're creating an ADAuthenticationContext with an authority URL, then calling acquireTokenWithResource, which should show the auth webview if no valid token is available.

It works fine on iOS 13 but crashes on iOS 14, regardless if 14.0.0 or 14.1.0 or 14.2.0 beta 5. Screenshot 2020-10-23 at 15 40 37

mipetriu commented 4 years ago

@mdivkovic-speech We will take a look at this issue and update you once we've done some investigation. In the meantime, do you mind capturing the output from XCode to help understand the issue?

mdivkovic-speech commented 4 years ago

@mipetriu Thank you very much for the response. That's the thing, there is no difference in output between the working iOS 13 run and the crashing iOS 14 run. The last few lines printed to console are the following:

2020-10-28 10:22:08.940129+0100 redacted[502:33372] AuthContext Authority:https://login.microsoftonline.com/4aac6235-0750-42c9-8628-181450e008cb 2020-10-28 10:22:08.940405+0100 redacted[502:33372] authority_URL:https://login.microsoftonline.com/4aac6235-0750-42c9-8628-181450e008cb 2020-10-28 10:22:09.242540+0100 redacted[502:33372] -canOpenURL: failed for URL: "msauth://broker" - error: "The operation couldn’t be completed. (OSStatus error -10814.)"

mdivkovic-speech commented 4 years ago

Update: This does not happen when using the MS Authenticator app, so we at least have a workaround for now.

kaisong1990 commented 4 years ago

@mdivkovic-speech Thanks for the information. We are not able to reproduce this issue by using our sample app

One thing I noticed from the screenshot that the code structure in MSIDWebviewUIController is not the same with our latest 4.0.10. Could you try to use our latest ADAL SDK? Also, the latest code in ADAL SDK will guarantee the call in embeddedWebviewSessionFromConfiguration happening on the main thread, which is not aligned with your screenshot.

mdivkovic-speech commented 4 years ago

@kaisong1990 Thanks for being so responsive guys! We did update to 4.0.10 as the very first step to try and fix the issue, so it's strange that this wouldn't be correct. That's the version that produced the screenshot to the best of my knowledge, but I will double check and get back to you on that tomorrow. If it's a main thread issue, the error message produced by xcode is really weird.

kaisong1990 commented 4 years ago

@mdivkovic-speech I am not sure if it is related to main thread or not. Just an assumption based on the screenshot you provided. Also, this is the screenshot for the same class in latest ADAL SDK Screen Shot 2020-10-28 at 11 58 44 AM

mdivkovic-speech commented 4 years ago

@kaisong1990 wow, that's a big help honestly! Made me dig deeper and realize that despite the version being set correctly in the Pod file, the project was still bundling the old version at build time somehow. I'm looking into resolving that and will let you know if that fixes the issue!

kaisong1990 commented 4 years ago

@mdivkovic-speech Is there any update regarding the crash?

mdivkovic-speech commented 4 years ago

@kaisong1990 sorry for the late reply, I've unfortunately had to move to another project and didn't get a chance to investigate this issue further, since the workaround of using the MS Authenticator was good enough.

As you and I have been able to confirm previously, there's something wrong with the dependency setup in the project causing it to bundle an older version of the library than the one declared in the pod file.

I would say we can close this issue with the info we have for now, it seems it's not a problem with the library.

Thank you again for the help, I really appreciate it!