[英]ejabberd rest API without authentication, 403 Forbidden (error code 32)
我正在尝试不进行身份验证就访问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中的所有用户都应该可以使用的命令(请参阅ejabberd.yml中api_permissions
下的“公共命令”部分)。
这是请求的详细信息(通过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软件包安装,并以ejabberd
用户身份在Debian 8.8(jessie)x86_64上运行。 安装后,我仅添加了主机“ localhost”,为localhost注册了新用户“ admin”并将其添加到ACL中。
我对ejabberd.yml所做的唯一更改:
hosts:
- "localhost"
acl:
admin:
user:
- "admin": "localhost"
否则,我可以访问工作正常的webadmin界面...
要获得200 OK响应,我该怎么办?
好的,我找到了解决方案。 就像消息说的那样,这是一个权限问题。
这是默认配置:
api_permissions:
## ...
"public commands":
who:
- ip: "127.0.0.1/8"
what:
- "status"
- "connected_users_number"
这不允许进入status
或connected_users_number
有或无认证指令(我三重检查)。
对于无身份验证的用法,请使用-all
:
"public commands":
who:
## This allows to use both commands without having to authenticate
- all
what:
- "status"
- "connected_users_number"
如果您想要一个有效的用户(具有基本身份验证),请替换- all
by - access: local
。
"public commands":
who:
## This allows to use both commands with basic authentication for local users
- access: local
what:
- "status"
- "connected_users_number"
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.