Khắc phục sự cố lỗi triển khai chính sách BasicXác thực

Bạn đang xem tài liệu về Apigee Edge.
Truy cập vào tài liệu Apigee X.
thông tin

UserNameRequired

Thông báo lỗi

Việc triển khai proxy API thông qua giao diện người dùng Edge hoặc API quản lý Edge không thành công và xuất hiện thông báo lỗi sau:

Error Deploying Revision revision_number to env_name
BasicAuthenticationPolicy: Username element must be present for operation operation.

Ví dụ về thông báo lỗi

Error Deploying Revision 2 to test
BasicAuthenticationPolicy: Username element must be present for Encode operation.

Ảnh chụp màn hình ví dụ

Nguyên nhân

Việc triển khai API Proxy sẽ không thành công nếu bạn không xác định phần tử <User> trong chính sách BasicAuthentication. Phần tử <User> là bắt buộc đối với cả hoạt động Mã hoá và Giải mã.

Chẩn đoán

  1. Kiểm tra tất cả các chính sách BasicAuthentication được dùng trong proxy API. Nếu có chính sách nào mà bạn không chỉ định phần tử <User>, thì đó là nguyên nhân gây ra lỗi. Phần tử <User> là bắt buộc trong chính sách BasicAuthentication cho các thao tác Mã hoá hoặc Giải mã.

    Chính sách BasicAuthentication mẫu xuất hiện bên dưới được dùng cho thao tác Encode (Mã hoá), nhưng không có phần tử <User> được xác định:

    <?xml version="1.0" encoding="UTF-8" standalone="yes"?>
    <BasicAuthentication name="ApplyBasicAuthHeader">
      <DisplayName>ApplyBasicAuthHeader</DisplayName>
      <Operation>Encode</Operation>
      <IgnoreUnresolvedVariables>false</IgnoreUnresolvedVariables>
      <Password ref="BasicAuth.credentials.password"/>
      <AssignTo createNew="false">request.header.Authorization</AssignTo>
    </BasicAuthentication>
    

    Quá trình triển khai không thành công do lỗi dưới đây:

    BasicAuthenticationPolicy: Username element must be present for Encode operation.
    

Độ phân giải

Đảm bảo rằng phần tử <User> được xác định trong chính sách BasicAuthentication cho thao tác Mã hoá hoặc Giải mã.

Để sửa ví dụ minh hoạ ở trên, hãy đưa phần tử <User> vào trong chính sách như minh hoạ dưới đây:

<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<BasicAuthentication name="ApplyBasicAuthHeader">
    <DisplayName>ApplyBasicAuthHeader</DisplayName>
    <Operation>Encode</Operation>
    <IgnoreUnresolvedVariables>false</IgnoreUnresolvedVariables>
    <User ref="BasicAuth.credentials.username"/>
    <Password ref="BasicAuth.credentials.password"/>
    <AssignTo createNew="false">request.header.Authorization</AssignTo>
</BasicAuthentication>

PasswordRequired

Thông báo lỗi

Việc triển khai proxy API thông qua giao diện người dùng Edge hoặc API quản lý Edge không thành công và xuất hiện thông báo lỗi sau:

Error Deploying Revision revision_number to env_name
BasicAuthenticationPolicy: Password element must be present for operation operation.

Ví dụ về thông báo lỗi

Error Deploying Revision 2 to test
BasicAuthenticationPolicy: Password element must be present for Encode operation.

Ảnh chụp màn hình ví dụ

Nguyên nhân

Việc triển khai API Proxy sẽ không thành công nếu bạn không xác định phần tử <Password> trong chính sách BasicAuthentication. Phần tử <Password> là bắt buộc đối với cả hoạt động Mã hoá và Giải mã.

Chẩn đoán

  1. Kiểm tra tất cả các chính sách BasicAuthentication được dùng trong proxy API. Nếu có chính sách nào mà phần tử <Password> không được xác định, thì đó là nguyên nhân gây ra lỗi. Phần tử <Password> là bắt buộc trong chính sách BasicAuthentication cho thao tác Mã hoá hoặc Giải mã.

    Chính sách BasicAuthentication mẫu xuất hiện bên dưới được dùng cho thao tác Encode (Mã hoá), nhưng không có phần tử <Password> được xác định:

    <?xml version="1.0" encoding="UTF-8" standalone="yes"?>
    <BasicAuthentication name="ApplyBasicAuthHeader">
      <DisplayName>ApplyBasicAuthHeader</DisplayName>
      <Operation>Encode</Operation>
      <IgnoreUnresolvedVariables>false</IgnoreUnresolvedVariables>
      <User ref="BasicAuth.credentials.username"/>
      <AssignTo createNew="false">request.header.Authorization</AssignTo>
    </BasicAuthentication>
    

    Quá trình triển khai không thành công do lỗi dưới đây:

    BasicAuthenticationPolicy: Password element must be present for Encode operation.
    

Độ phân giải

Đảm bảo rằng phần tử <Password> được xác định trong chính sách BasicAuthentication cho hoạt động Mã hoá hoặc Giải mã.

Để sửa ví dụ minh hoạ ở trên, hãy đưa phần tử <Password> vào trong chính sách như minh hoạ dưới đây:

<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<BasicAuthentication name="ApplyBasicAuthHeader">
    <DisplayName>ApplyBasicAuthHeader</DisplayName>
    <Operation>Encode</Operation>
    <IgnoreUnresolvedVariables>false</IgnoreUnresolvedVariables>
    <User ref="BasicAuth.credentials.username"/>
    <Password ref="BasicAuth.credentials.password"/>
    <AssignTo createNew="false">request.header.Authorization</AssignTo>
</BasicAuthentication>

AssignToRequired

Thông báo lỗi

Việc triển khai proxy API thông qua giao diện người dùng Edge hoặc API quản lý Edge không thành công và xuất hiện thông báo lỗi sau:

Error Deploying Revision revision_number to env_name
BasicAuthenticationPolicy: AssignTo element must be present for operation operation.

Ví dụ về thông báo lỗi

Error Deploying Revision 2 to test
BasicAuthenticationPolicy: AssignTo element must be present for Encode operation.

Ảnh chụp màn hình ví dụ

Nguyên nhân

Việc triển khai API Proxy sẽ không thành công nếu bạn không xác định phần tử <AssignTo> trong chính sách BasicAuthentication. Phần tử <AssignTo> là bắt buộc đối với cả hoạt động Mã hoá và Giải mã.

Chẩn đoán

  1. Kiểm tra tất cả các chính sách BasicAuthentication được dùng trong proxy API. Nếu có chính sách nào mà phần tử <AssignTo> không được xác định, thì đó là nguyên nhân gây ra lỗi. Bạn bắt buộc phải xác định phần tử <AssignTo> trong chính sách BasicAuthentication cho cả hoạt động Mã hoá và Giải mã.

    Chính sách BasicAuthentication mẫu xuất hiện bên dưới được dùng cho thao tác Encode (Mã hoá), nhưng không có phần tử <AssignTo> được xác định:

    <?xml version="1.0" encoding="UTF-8" standalone="yes"?>
    <BasicAuthentication name="ApplyBasicAuthHeader">
      <DisplayName>ApplyBasicAuthHeader</DisplayName>
      <Operation>Encode</Operation>
      <IgnoreUnresolvedVariables>false</IgnoreUnresolvedVariables>
      <User ref="BasicAuth.credentials.username"/>
      <Password ref="BasicAuth.credentials.password"/>
    </BasicAuthentication>
    

    Quá trình triển khai không thành công do lỗi dưới đây:

    BasicAuthenticationPolicy: AssignTo element must be present for Encode operation.
    

Độ phân giải

Đảm bảo rằng phần tử <AssignTo> được xác định trong chính sách BasicAuthentication cho thao tác Mã hoá hoặc Giải mã.

Để sửa ví dụ minh hoạ ở trên, hãy đưa phần tử <AssignTo> vào trong chính sách như minh hoạ dưới đây:

<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<BasicAuthentication name="ApplyBasicAuthHeader">
    <DisplayName>ApplyBasicAuthHeader</DisplayName>
    <Operation>Encode</Operation>
    <IgnoreUnresolvedVariables>false</IgnoreUnresolvedVariables>
    <User ref="BasicAuth.credentials.username"/>
    <Password ref="BasicAuth.credentials.password"/>
    <AssignTo createNew="false">request.header.Authorization</AssignTo>
</BasicAuthentication>

SourceRequired

Thông báo lỗi

Việc triển khai proxy API thông qua giao diện người dùng Edge hoặc API quản lý Edge không thành công và xuất hiện thông báo lỗi sau:

Error Deploying Revision revision_number to env_name
BasicAuthenticationPolicy: Source element must be present for Decode operation.

Ví dụ về thông báo lỗi

Error Deploying Revision 2 to test
BasicAuthenticationPolicy: Source element must be present for Decode operation.

Ảnh chụp màn hình ví dụ

Nguyên nhân

Việc triển khai API Proxy sẽ thất bại nếu phần tử <Source> không được xác định trong chính sách BasicAuthentication dùng cho thao tác giải mã. Phần tử <Source> là bắt buộc nếu bạn chỉ định <Operation> là Decode trong chính sách BasicAuthentication.

Chẩn đoán

  1. Kiểm tra tất cả các chính sách BasicAuthentication được dùng trong proxy API. Nếu có chính sách mà phần tử <Source> không được xác định và phần tử <Operation> được xác định là Decode, thì đó là nguyên nhân gây ra lỗi. Phần tử <Source> là bắt buộc nếu bạn chỉ định <Operation> là Decode trong chính sách BasicAuthentication.

    Chính sách BasicAuthentication mẫu bên dưới được dùng cho thao tác Decode, nhưng không có phần tử <Source> được xác định:

    <?xml version="1.0" encoding="UTF-8" standalone="yes"?>
    <BasicAuthentication name="ApplyBasicAuthHeader">
      <DisplayName>ApplyBasicAuthHeader</DisplayName>
      <Operation>Decode</Operation>
      <IgnoreUnresolvedVariables>false</IgnoreUnresolvedVariables>
      <User ref="BasicAuth.credentials.username"/>
      <Password ref="BasicAuth.credentials.password"/>
      <AssignTo createNew="false">request.header.Authorization</AssignTo>
    </BasicAuthentication>
    

    Quá trình triển khai không thành công do lỗi dưới đây:

    BasicAuthenticationPolicy: Source element must be present for Decode operation.
    

Độ phân giải

Đảm bảo rằng phần tử <Source> được xác định trong chính sách BasicAuthentication khi được dùng cho thao tác Decode.

Để sửa ví dụ minh hoạ ở trên, hãy đưa phần tử <Source> vào trong chính sách như minh hoạ dưới đây:

<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<BasicAuthentication name="ApplyBasicAuthHeader">
    <DisplayName>ApplyBasicAuthHeader</DisplayName>
    <Operation>Decode</Operation>
    <IgnoreUnresolvedVariables>false</IgnoreUnresolvedVariables>
    <User ref="BasicAuth.credentials.username"/>
    <Password ref="BasicAuth.credentials.password"/>
    <AssignTo createNew="false">request.header.Authorization</AssignTo>
    <Source>request.header.Authorization</Source>
</BasicAuthentication>