问题描述
我的项目包括Web应用程序,守护程序应用程序和这两个应用程序的Common API。 这是“通用API应用程序注册清单”中应用程序角色的定义:
"appRoles": [
{
"allowedMemberTypes": [
"Application","User"
],"description": "Access the Synchronizator as an application","displayName": "access_as_sync_application","id": "XXX","isEnabled": true,"lang": null,"origin": "Application","value": "access_as_sync_application"
},{
"allowedMemberTypes": [
"User"
],"description": "Access to everybody timeentries","displayName": "TimeEntries.Administrator","value": "TimeEntries.Administrator"
},"description": "Access to own timeentries","displayName": "TimeEntries.User","value": "TimeEntries.User"
}
],
如您所见。我已经为MemberType“应用程序”以及用于守护程序应用程序的“用户”定义了角色“ access_as_sync_application”。
这两个应用程序之间的关系在企业应用程序\ API应用程序\用户和组中定义:
但是,一旦我尝试从Daemon应用程序调用API,就会收到403禁止响应。这是我保护端点的方式:
[HttpPost]
[Authorize(Roles = "access_as_sync_application")]
public async Task<ActionResult<LogSyncResult>> LogSync([FromBody] LogSyncCommand command)
{
LogSyncResult result = await Mediator.Send(command);
return Ok(result);
}
一切正常,直到我使用AuthorizeAttribute。我检查了访问令牌的内容,它包含必需的角色:
解决方法
暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!
如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。
小编邮箱:dio#foxmail.com (将#修改为@)