在 Edge 上启用 SAML 或 LDAP 后,您可以停用基本身份验证。不过, 在停用基本身份验证之前:
- 确保您已将所有 Edge 用户(包括系统管理员)添加到您的 IDP。
- 确保您已在 Edge 界面和 Edge 上全面测试了您的 IDP 身份验证 Management API。
- 如果您使用的是 Apigee Developer Services 门户(简称门户),请在该门户上配置和测试您的外部 IDP 以确保该门户可以连接到 Edge。请参阅 为外部 IDP 配置门户。
查看当前的安全配置文件
您可以查看 Edge 安全配置文件以确定当前配置,从而确定 目前已启用基本身份验证和外部 IDP。使用以下 Edge 管理服务 进行 API 调用,以查看 Edge 当前使用的安全配置文件:
curl -H "accept:application/xml" http://localhost:8080/v1/securityprofile -u sysAdminEmail:pWord
如果您尚未配置外部 IDP,则响应如下所示,即“基本” 身份验证:
<SecurityProfile enabled="true" name="securityprofile">
    <UserAccessControl enabled="true">
    </UserAccessControl>
</SecurityProfile>如果您已启用外部 IDP,则 <ssoserver> 元素应
  出现在响应中:
<SecurityProfile enabled="true" name="securityprofile">
    <UserAccessControl enabled="true">
        <SSOServer>
            <BasicAuthEnabled>true</BasicAuthEnabled>
            <PublicKeyEndPoint>/token_key</PublicKeyEndPoint>
            <ServerUrl>http://35.197.37.220:9099</ServerUrl>
        </SSOServer>
    </UserAccessControl>
</SecurityProfile>请注意,启用了外部 IDP 的版本还会显示 <BasicAuthEnabled>true</BasicAuthEnabled> 表示 身份验证。
停用基本身份验证
在边缘管理服务器上使用以下 Edge Management API 调用来停用基本版
  身份验证。请将上一部分中返回的 XML 对象作为载荷传递。唯一
  不同之处在于您将 <BasicAuthEnabled> 设置为 false,因为
  如下例所示:
curl -H "Content-Type: application/xml"
http://localhost:8080/v1/securityprofile  -u sysAdminEmail:pWord -d
 '<SecurityProfile enabled="true" name="securityprofile">
  <UserAccessControl enabled="true">
    <SSOServer>
      <BasicAuthEnabled>false</BasicAuthEnabled>
      <PublicKeyEndPoint>/token_key</PublicKeyEndPoint>
      <ServerUrl>http://35.197.37.220:9099</ServerUrl>
  </SSOServer>
 </UserAccessControl>
</SecurityProfile>'停用基本身份验证后,任何通过基本身份验证的 Edge Management API 调用 身份验证凭据会返回以下错误:
<Error>
    <Code>security.SecurityProfileBasicAuthDisabled</Code>
    <Message>Basic Authentication scheme not allowed</Message>
    <Contexts/>
</Error>重新启用基本身份验证
如果您因任何原因需要重新启用基本身份验证,则必须执行以下操作 步骤:
- 登录任意 Edge ZooKeeper 节点。
- 运行以下 bash 脚本以关闭所有安全设置:
      
      #! /bin/bash /opt/apigee/apigee-zookeeper/bin/zkCli.sh -server localhost:2181 <<EOF set /system/securityprofile <SecurityProfile></SecurityProfile> quit EOF 您将看到以下格式的输出: Connecting to localhost:2181 Welcome to ZooKeeper! JLine support is enabled WATCHER:: WatchedEvent state:SyncConnected type:None path:null [zk: localhost:2181(CONNECTED) 0] set /system/securityprofile <SecurityProfile></SecurityProfile> cZxid = 0x89 ... [zk: localhost:2181(CONNECTED) 1] quit Quitting... 
- 重新启用基本身份验证和外部 IDP 身份验证:
      curl -H "Content-Type: application/xml" http://localhost:8080/v1/securityprofile -u sysAdminEmail:pWord -d '<SecurityProfile enabled="true" name="securityprofile"> <UserAccessControl enabled="true"> <SSOServer> <BasicAuthEnabled>true</BasicAuthEnabled> <PublicKeyEndPoint>/token_key</PublicKeyEndPoint> <ServerUrl>http://35.197.37.220:9099</ServerUrl> </SSOServer> </UserAccessControl> </SecurityProfile>' 
您现在可以再次使用基本身份验证了。请注意,基本身份验证不起作用 。