【发布时间】:2017-04-13 02:32:45
【问题描述】:
我正在尝试在 Xamarin Forms(iOS 和 Android)中使用适用于 .NET 的 ADAL 库来实现 POC 应用程序,以针对我公司的 Azure AD 进行身份验证。我已经设法在两个平台上使用用户名/密码进行身份验证,并使用 Microsoft Authenticator 作为 Android 上的代理(Workplace Join)。
但我正在努力在 iOS 上使用 Authenticator 进行身份验证。我使用 ADAL iOS 的 SSO 指南作为参考 (https://docs.microsoft.com/en-us/azure/active-directory/active-directory-sso-ios)。
当我单击我的测试登录按钮时,Authenticator 应用程序会打开,但它只是保持打开状态,并显示一个白屏和一个取消按钮。 我已经尝试过 iOS 9.3 和 iOS 10。我在设备日志中收到这些错误消息。
Warning (325) / Authenticator: ADALiOS [2016-11-28 11:04:35 - 9966AB28-6265-400D-91B4-F3B145D12FB9] VERBOSE: ADAL API call [Version - 2.0.2]. Additional Information: In function: +[ADBrokerContext getAllAccounts:], file line #632. ErrorCode: 0.
Warning (325) / Authenticator: ADALiOS [2016-11-28 11:04:35 - 9966AB28-6265-400D-91B4-F3B145D12FB9] VERBOSE: ADAL API call [Version - 2.0.2]. Additional Information: In function: -[ADKeychainTokenCacheStore allItemsWithError:], file line #419. ErrorCode: 0.
Warning (325) / Authenticator: ADALiOS [2016-11-28 11:04:35 - 9966AB28-6265-400D-91B4-F3B145D12FB9] VERBOSE: Keychain token cache store. Additional Information: (null). ErrorCode: 0.
Warning (325) / Authenticator: ADALiOS [2016-11-28 11:04:35 - 9966AB28-6265-400D-91B4-F3B145D12FB9] VERBOSE: ADAL API call [Version - 2.0.2]. Additional Information: In function: +[ADBrokerContext isBrokerRequest:returnUpn:], file line #157. ErrorCode: 0.
Warning (325) / Authenticator: ADALiOS [2016-11-28 11:04:35 - 9966AB28-6265-400D-91B4-F3B145D12FB9] VERBOSE: ADAL API call [Version - 2.0.2]. Additional Information: In function: +[ADBrokerContext isBrokerRequest:returnUpn:], file line #157. ErrorCode: 0.
Warning (325) / Authenticator: ADALiOS [2016-11-28 11:04:35 - 9966AB28-6265-400D-91B4-F3B145D12FB9] INFORMATION: Broker invoked from my.company.xamarinadaltest. Additional Information: (null). ErrorCode: 0.
Warning (325) / Authenticator: ADALiOS [2016-11-28 11:04:35 - 9966AB28-6265-400D-91B4-F3B145D12FB9] VERBOSE: ADAL API call [Version - 2.0.2]. Additional Information: In function: +[ADBrokerContext invokeBrokerImpl:sourceApplication:upn:webView:], file line #432. ErrorCode: 0.
Warning (325) / Authenticator: ADALiOS [2016-11-28 11:04:35 - 9966AB28-6265-400D-91B4-F3B145D12FB9] ERROR: Error raised: 2. Additional Information: Domain: ADAuthenticationErrorDomain Details: source application bundle identifier should be same as the redirect URI domain. ErrorCode: 2.
Warning (325) / Authenticator: ADALiOS [2016-11-28 11:04:35 - 9966AB28-6265-400D-91B4-F3B145D12FB9] ERROR: source application does not match redirect uri host. Additional Information: (null). ErrorCode: 0.
代码中的重定向 URI:msauth://code/x-msauth-adaltest%3A%2F%2Fmy.company.xamarinadaltest
在 Entitlements.plist 中(我在 Entitlements 中尝试过使用和不使用 - 结果相同):
<dict>
<key>keychain-access-groups</key>
<array>
<string>$(AppIdentifierPrefix)my.company.xamarinadaltest</string>
<string>$(AppIdentifierPrefix)com.microsoft.workplacejoin</string>
<string>$(AppIdentifierPrefix)com.microsoft.adalcache</string>
</array>
</dict>
在 Info.plist 中:
<key>CFBundleIdentifier</key>
<string>my.company.xamarinadaltest</string>
<key>CFBundleURLTypes</key>
<array>
<dict>
<key>CFBundleTypeRole</key>
<string>Editor</string>
<key>CFBundleURLName</key>
<string>my.company.xamarinadaltest</string>
<key>CFBundleURLSchemes</key>
<array>
<string>x-msauth-adaltest</string>
</array>
<key>CFBundleURLTypes</key>
<string>Editor</string>
</dict>
</array>
<key>LSApplicationQueriesSchemes</key>
<array>
<string>msauth</string>
</array>
Azure 门户中的重定向 URI:
msauth://code/x-msauth-adaltest://my.company.xamarinadaltest
x-msauth-adaltest://my.company.xamarinadaltest
msauth://code/x-msauth-adaltest%3A%2F%2Fmy.company.xamarinadaltest
根据指南(https://docs.microsoft.com/en-us/azure/active-directory/active-directory-sso-ios):
您的重定向 URI 必须采用以下正确格式:
<app-scheme>://<your.bundle.id>
所以我不明白错误“源应用程序包标识符应该与重定向 URI 域相同”。
有没有人设法让这个工作?好像 Authenticator 使用的是旧版本的 ADALiOS,这可能是个问题吗?
【问题讨论】:
标签: azure authentication xamarin azure-active-directory adal