对本地运行的Moqui的Rest调用有一个问题...下面是示例html代码,错误是"REST访问被禁止(no authz):用户null未被授权查看REST路径/moqui/users“。在web控制台上,错误是403 (禁止)。
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>AJAX Test</title>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.1.0/jquery.min.js"></script>
</head>
<body>
<script>
$(document).ready(function() {
$.ajax({
type: "GET",
url: "http://localhost:8080/rest/s1/moqui/users",
headers: {
Accept: "application/json",
Authorization : "Basic am9obi5kb2U6bW9xdWk="
},
contentType: "application/json"
}).then(function(data) {
console.log(data);
});
});
</script>
</body>
</html>

发布于 2017-01-25 04:14:45
所有工件操作(实体、服务、屏幕、REST API等)都需要在Moqui中进行授权。有一些方法可以批量配置(即继承身份验证),但每次操作都会检查授权。
下面是一些示例XML,用于为ADMIN组中的所有用户授权整个mantle REST API。这也可以在系统应用程序中完成,该应用程序具有针对用户、用户组、授权等的屏幕。
<!-- Artifact group for all of the Mantle REST API via the mantle resource (the root resource) -->
<artifactGroups artifactGroupId="MANTLE_API" description="Mantle REST API (via root resource)">
<artifacts artifactTypeEnumId="AT_REST_PATH" artifactName="/mantle" inheritAuthz="Y"/>
<authz artifactAuthzId="MANTLE_API_ADMIN" userGroupId="ADMIN" authzTypeEnumId="AUTHZT_ALWAYS" authzActionEnumId="AUTHZA_ALL"/>
</artifactGroups>在用Moqui制作应用程序一书中有更多关于工件授权功能的通用文档(您可以在moqui.org上下载PDF )。尽管REST API功能比本书更新,因此还没有在书中介绍,但与屏幕授权相同的模式也适用于REST API。
https://stackoverflow.com/questions/41827345
复制相似问题