weixin_33694620 2017-01-24 11:41 采纳率: 0%
浏览 47

Moqui AJAX通话问题

There is an issue with the Rest call to Moqui running locally... Below is the sample html code and the error is "REST Access Forbidden (no authz): User null is not authorized for View on REST Path /moqui/users". And on the web console the error is 403 (Forbidden).

<!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>

Api call works fine when tried with a Chrome Rest Client, but not with AJAX call

  • 写回答

1条回答 默认 最新

  • weixin_33734785 2017-01-24 20:14
    关注

    All artifact operations (for entities, services, screens, REST API, etc) require authorization in Moqui. There are ways to configure this in bulk (ie inherited authz) but authorization is always checked for every operation.

    Here is some example XML for authorization to the entire mantle REST API for all users in the ADMIN group. This can also be done in the System application which has screens for users, user groups, authz, etc.

    <!-- 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>
    

    There is more general documentation on the Artifact Authorization functionality in the Making Apps with Moqui book (you can download the PDF on moqui.org). Even though the REST API functionality is more recent than the book and so not yet covered in it, the same pattern as for screen authorization applies to the REST API.

    评论

报告相同问题?

悬赏问题

  • ¥15 素材场景中光线烘焙后灯光失效
  • ¥15 请教一下各位,为什么我这个没有实现模拟点击
  • ¥15 执行 virtuoso 命令后,界面没有,cadence 启动不起来
  • ¥50 comfyui下连接animatediff节点生成视频质量非常差的原因
  • ¥20 有关区间dp的问题求解
  • ¥15 多电路系统共用电源的串扰问题
  • ¥15 slam rangenet++配置
  • ¥15 有没有研究水声通信方面的帮我改俩matlab代码
  • ¥15 ubuntu子系统密码忘记
  • ¥15 保护模式-系统加载-段寄存器