在 Edge 上停用基本身份验证

在 Edge 上启用 SAML 或 LDAP 后,您可以停用基本身份验证。不过,在停用基本身份验证之前:

  • 确保您已将所有 Edge 用户(包括系统管理员)添加到 IDP。
  • 请确保您已在 Edge 界面和 Edge Management API 上全面测试了 IDP 身份验证。
  • 如果您使用的是 Apigee 开发者服务门户(或简称为门户),请在门户上配置和测试外部 IDP,以确保门户可以连接到 Edge。请参阅为外部 IDP 配置门户。

查看当前安全配置文件

您可以查看 Edge 安全配置文件,以确定当前配置,从而确定当前是否已启用基本身份验证和外部 IDP。在 Edge 管理服务器上使用以下 Edge Management 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 管理服务器上使用以下 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 管理 API 调用都会返回以下错误:

<Error>
    <Code>security.SecurityProfileBasicAuthDisabled</Code>
    <Message>Basic Authentication scheme not allowed</Message>
    <Contexts/>
</Error>

重新启用基本身份验证

如果由于某种原因,您必须重新启用基本身份验证,则必须执行以下步骤:

  1. 登录任何 Edge ZooKeeper 节点。
  2. 运行以下 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...
  3. 重新启用基本身份验证和外部 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>'

您现在可以再次使用基本身份验证。请注意,启用新版 Edge 体验后,基本身份验证将无法正常运行。