ejabberd rest API 未经身份验证,403 禁止访问(错误代码 32)
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 的所有用户都应该能够使用的命令(请参阅 api_permissions
下的 "public commands" 部分 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
用户。
Post 安装,我只是添加了主机 "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
替换为 - access: local
。
"public commands":
who:
## This allows to use both commands with basic authentication for local users
- access: local
what:
- "status"
- "connected_users_number"
我试图在没有身份验证的情况下访问 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
下的 "public commands" 部分 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
用户。
Post 安装,我只是添加了主机 "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
替换为 - access: local
。
"public commands":
who:
## This allows to use both commands with basic authentication for local users
- access: local
what:
- "status"
- "connected_users_number"