gpt4 book ai didi

ios - ADAL 身份验证需要设备管理

转载 作者:塔克拉玛干 更新时间:2023-11-02 20:28:59 25 4
gpt4 key购买 nike

我已经为 ADAL 身份验证设置了一个演示应用程序。我公司要求安装InTune应用程序:https://itunes.apple.com/us/app/intune-company-portal/id719171358?mt=8

安装并设置 InTune 后,我使用我开发的 ADAL 安装了演示:

  1. 添加 ADAL 作为 Pod 库

  2. 在我的 Azure 门户 ( https://portal.azure.com/#blade/Microsoft_AAD_IAM/ActiveDirectoryMenuBlade/RegisteredApps ) 中添加了重定向 URI(一个带有 schema://bundle_id,另一个带有 msauth://code/schema%3A%2F%2Fbundle_id)

  3. 添加到应用程序的 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>
  • 添加了 [_authContext setCredentialsType:AD_CREDENTIALS_AUTO]; 以使用 inTune App Portal 进行代理身份验证。

  • 创建身份验证:

    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 身份验证,即在公司页面上的 microsofth 身份验证上重定向,但身份验证后,结果如下:

    enter image description here

    最佳答案

    要让 Azure AD 确定设备已受管理以满足条件访问要求,您必须使用代理身份验证。这是通过指定 AD_CREDENTIALS_AUTO (您已完成)、将 msauth 添加到 LSApplicationQueriesSchemes (您已完成)并配置适当的回调 URI 来启用的您的应用程序的方案(您也已完成)。

    将使用的代理是 Microsoft Authenticator应用程序。如果您没有安装此程序(ADALios 框架通过检查是否有响应 msauth url 方案的应用来确定),则 ADAL 库将默认显示登录表单应用程序中的 WebView 。

    由于您的应用无法确定设备是否受管理,因此您会收到“身份验证成功,但您的设备未注册”结果。

    安装 Microsoft Authenticator 应用程序后,您将看到它已打开以响应身份验证请求。此应用程序可以确定您设备的注册状态,然后您应该会返回到您的应用程序并获得成功的 token 。

    安装验证器应用程序的要求可以在库文档中更明确地指出,但提到了:

    Brokered Authentication

    If your app requires conditional access or certificate authentication (currently in preview) support, you must set up your AuthenticationContext and redirectURI to be able to talk to the Azure Authenticator app.

    关于ios - ADAL 身份验证需要设备管理,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/52273913/

    25 4 0
    Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
    广告合作:1813099741@qq.com 6ren.com