停用 Edge 的基本驗證功能

在 Edge 上啟用 SAML 或 LDAP 後,即可停用基本驗證。不過,停用基本驗證前,請先完成下列事項:

  • 請確認您已將所有 Edge 使用者 (包括系統管理員) 新增至 IDP。
  • 請務必在新版 Edge UI 和 Edge Management API 上,徹底測試 IDP 驗證。

查看目前的安全性設定檔

您可以查看 Edge 安全性設定檔,判斷目前的設定是否已啟用基本驗證和外部 IDP。在 Edge Management Server 上使用下列 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 管理伺服器上使用下列 Edge 管理 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>

重新啟用基本驗證

如果基於任何原因必須重新啟用基本驗證,請按照下列步驟操作:

  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 UI 從單一登入 (SSO) 切換回基本驗證,請在新版 Edge UI 設定檔中設定 AUTH_MODE=basic 和 MANAGEMENT_UI_SSO_ENABLED=n,然後依序執行 /opt/apigee/apigee-service/bin/apigee-service edge-management-ui configure-sso -f configFile 和 /opt/apigee/apigee-service/bin/apigee-service edge-management-ui restart (或執行 /opt/apigee/apigee-setup/bin/setup.sh -p ue -f configFile)。