未经身份验证的ejabberd rest API,403 Forbidden(错误代码32)

时间:2017-05-31 00:14:23

标签: rest ejabberd ejabberd-api

我试图在没有身份验证的情况下访问ejabberd rest api,但总是得到403 Forbidden对此机构的回复:

{
    "status": "error",
    "code": 32,
    "message": "AccessRules: Account does not have the right to perform the operation."
}

我无法在/api/status端点上得到一个OK响应,这是一个来自127.0.0.1的所有用户都应该能够使用的命令(请参阅"公共命令" api_permissions下的部分在ejabberd.yml)。

这里是请求详细信息(通过Insomnia REST客户端):

> POST /api/status HTTP/1.1
> User-Agent: insomnia/5.1.0
> Host: localhost:5280
> Accept: */*
> Accept-Encoding: deflate, gzip
> Content-Type: application/json
> Content-Length: 2
| {}

Ejabberd版本是17.04,从下载的deb软件包安装并在Debian 8.8(jessie)x86_64上以ejabberd用户身份运行。 安装后,我只是添加了主机" localhost",注册了一个新用户" admin"对于localhost并将其添加到ACL中。

我对ejabberd.yml所做的唯一更改:

hosts:
  - "localhost"
acl:
  admin:
    user:
      - "admin": "localhost"

否则,我可以访问工作正常的webadmin界面...
我能做些什么来获得200 OK响应?

1 个答案:

答案 0 :(得分:1)

好的,我找到了解决方案。就像消息所说这是一个许可问题 这是默认配置:

api_permissions:
## ...
  "public commands":
    who:
      - ip: "127.0.0.1/8"
    what:
      - "status"
      - "connected_users_number"

允许访问statusconnected_users_number命令,无论是否有身份验证(我已经过三次检查)。

对于无身份验证用法,请使用-all

  "public commands":
    who:
## This allows to use both commands without having to authenticate
      - all
    what:
      - "status"
      - "connected_users_number"

如果您想要有效用户(使用基本身份验证),请将- all替换为- access: local

  "public commands":
    who:
## This allows to use both commands with basic authentication for local users
      - access: local
    what:
      - "status"
      - "connected_users_number"
相关问题