ADAL身份验证需要设备管理

3

我已经为 ADAL 认证设置了一个演示应用程序。我们公司要求安装 InTune 应用:

https://itunes.apple.com/us/app/intune-company-portal/id719171358?mt=8

在安装和设置 InTune 后,我安装了我开发的 ADAL 演示应用程序:

  1. added ADAL as Pod Library

  2. added redirect URI inside my Azure Portal (https://portal.azure.com/#blade/Microsoft_AAD_IAM/ActiveDirectoryMenuBlade/RegisteredApps) (one with schema://bundle_id and one with msauth://code/schema%3A%2F%2Fbundle_id)

  3. added to app's info.plist:

    <key>LSApplicationQueriesSchemes</key>
    <array>
        <string>msauth</string>
    </array>
    

4.加入到应用程序的info.plist文件中

<key>CFBundleURLTypes</key>
<array>
    <dict>
        <key>CFBundleTypeRole</key>
        <string>Editor</string>
        <key>CFBundleURLName</key>
        <string>bundle_id</string>
        <key>CFBundleURLSchemes</key>
        <array>
            <string>schema</string>
        </array>
    </dict>
</array>
  1. added [_authContext setCredentialsType:AD_CREDENTIALS_AUTO]; to use inTune App Portal for broker auth.

  2. create the authentication with:

    ADAuthenticationError *error = nil;
     _authContext = [ADAuthenticationContext authenticationContextWithAuthority:@"https://login.microsoftonline.com/common" error:&error];  
    [_authContext setCredentialsType:AD_CREDENTIALS_AUTO];
    
    [_authContext acquireTokenWithResource:@"https://graph.microsoft.com"
                              clientId:@"my_client_id"                          // Comes from App Portal
                           redirectUri:[NSURL URLWithString:@"schema://bundle_id"] // Comes from App Portal
                       completionBlock:^(ADAuthenticationResult *result)
    {
       NSLog(result.accessToken);
     }];
    
应用程序将正确提示用户进行 Microsoft 认证,然后将其重定向到公司页面上的 Microsoft 认证。但是,在认证之后,会出现以下结果:

enter image description here


你的设备是否已被管理?即是否显示在Comp Portal应用程序的“设备”下? - Paulw11
是的,它已经显示了。 - Alessio Crestani
设备显示为“符合要求”?如果您点击“立即注册”,会发生什么?您是否会收到设备已注册的错误?这是一种条件访问失败。您应该让您的 AD 管理员查看已应用于图形终结点和应用程序 ID 的条件访问策略。 - Paulw11
如果我按下按钮,将会出现一个带有该按钮的 HTML 页面,可以打开 Intune 上的 AppStore。 - Alessio Crestani
让我们在聊天中继续这个讨论 - Paulw11
显示剩余2条评论
1个回答

3
为了满足条件访问要求,Azure AD需要确定设备是否受管理,您必须使用“经纪人身份验证”。这是通过指定“AD_CREDENTIALS_AUTO”(已完成)、将“msauth”添加到“LSApplicationQueriesSchemes”(已完成)以及为应用程序配置适当的回调URI方案来实现的(也已完成)。
将使用的代理是Microsoft Authenticator应用程序。如果您没有安装此应用程序(ADALios框架通过检查是否有一个响应于“msauth”URL方案的应用程序来确定),则ADAL库将默认在您的应用程序中显示登录表单中的Web视图。
由于您的应用程序无法确定设备是否受管理,因此您会得到“身份验证成功,但您的设备未注册”的结果。
安装Microsoft Authenticator应用程序后,您将看到它响应身份验证请求而打开。该应用程序可以确定您的设备的注册状态,然后您应该返回到您的应用程序并获得成功的令牌。
在库文档中更明确地提到了需要安装验证器应用的要求,但是它被提及了:
引用: 如果您的应用程序需要条件访问或证书身份验证(目前处于预览状态)支持,则必须设置AuthenticationContext和redirectURI以便能够与Azure Authenticator应用程序通信。经纪人身份验证

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接