错误基本身份验证失败:WSO2 API Manager 4.1.0 中用户的租户域不匹配:[email protected]

问题描述 投票:0回答:1

我正在 WSO2 API Manager 4.1.0 GA 版本中尝试

BasicAuth
的安全 API。

  • 有受基本身份验证机制保护的后端服务(用户名:

    [email protected]
    ,密码:
    apimtestpwd
    ),按照以下步骤在 WSO2 APIM 中托管此后端。

  • BasicAuth 在

    API Configurations section
    下启用 -->
    Runtime
    在 Publisher 中

  • BasicAuth 凭证在

    API Configurations section
    -->
    Endpoints

    下提供

  • 发布相同,现在它在
    Devportal
    中可见。没有添加订阅,因为这是受基本身份验证保护

  • 当我通过
    Try Out
    postman
    进行测试时,得到
    403 Forbidden
    错误作为响应

{ "code": "900908", "message": "Resource forbidden ", "description": "Resource forbidden " }

注意到下面错误登录

wso2carbon.log

[2023-03-30 20:01:49,291] ERROR - BasicAuthAuthenticator Basic Authentication failure: tenant domain mismatch for user :[email protected]
[2023-03-30 20:01:49,291]  WARN - APIAuthenticationHandler API authentication failure due to Resource forbidden

PS:在

Users and Roles
部分下的wso2碳门户中添加了用户。

@Lakshitha 建议在

deployment.toml
文件中添加以下行

[super_admin]
username = "admin"
password = "admin"
create_admin_account = true
[tenant_mgt]
enable_email_domain= true

[apim.throttling]
#username = "$ref{super_admin.username}@carbon.super"
username = "[email protected]@[email protected]"

[apim.throttling.policy_deploy]
username = "$ref{super_admin.username}@carbon.super"

[apim.throttling.jms]
#username="admin!wso2.com!carbon.super"
username="admin!wso2.com!testdomain.com!carbon.super"
password = "$ref{super_admin.password}"

API 请求未到达后端 URL 服务器。如何解决这个问题?

wso2 basic-authentication wso2-api-manager wso2-enterprise-integrator
1个回答
1
投票

我认为问题出在您调用 API 的用户身上。如果您使用电子邮件地址作为用户名(例如:[email protected]),则必须明确启用此功能(检查此doc)。如果不是,服务器将

@
之后的部分视为租户域,并查看关联的租户域。

我认为这应该是后端出现此错误的原因。

在您的场景中,您有两层基本身份验证,

  1. 后端端点安全
  2. API 安全性

您需要为 2.API 安全部分提供正确的用户名密码凭据。这些用户名、密码对必须包含在 wso2 用户存储中,这就是 APIM 验证请求的方式。

1 的凭据。后端安全性没有此要求,因为验证是从后端完成的。不是来自 APIM 服务器。

编辑: 您不能使用 [email protected] 来调用通过 API 管理器公开的 API。该用户与后端相关联,对于 APIM 层的基本身份验证,您需要使用已包含在 WSO2 用户存储中的用户进行调用。

一旦服务器验证了用户的真实性,它就会将请求传递给后端,对于此调用,服务器会使用您在端点安全部分中设置的配置([email protected] 和密码)生成一个新的基本身份验证标头.在此后端调用中,API Manager 充当客户端并使用基本身份验证凭据将请求发送到后端服务器。

© www.soinside.com 2019 - 2024. All rights reserved.