我使用CURL是为了使这个例子尽可能简单。我没有用CURL实现最终版本,但我能够将curl示例转换成最终形式。
我使用的是api的jsonrpc版本。实际凭据和URL被假信息替换
我可以这样登录:
curl 'http://kiwi.example.com/json-rpc/' \
-H 'Content-Type: application/json' \
--data-binary '{"jsonrpc":"2.0","method":"Auth.login", "params":{"username":"me@example.com", "password" : "PASSWORD"}, "id":"jsonrpc"}';这将返回一个会话id,为了这些目的,它被假定为“123456789abc”,在下面使用。
然后,我可以使用该会话id执行如下操作:(只是一个任意的API调用)
curl 'http://kiwi.example.com/json-rpc/' \
-H 'Content-Type: application/json' \
-H 'Cookie: sessionid=123456789abcdefghijklmnopqrstyvw' \
--data-binary '{"jsonrpc":"2.0","method":"TestPlan.filter", "params":[{"is_active":true}],"id":"jsonrpc"}';那为什么这个不起作用?或者,如果你愿意,我应该做什么不同的注销?
curl 'http://kiwi.example.com/json-rpc/' \
-H 'Content-Type: application/json' \
-H 'Cookie: sessionid=123456789abcdefghijklmnopqrstyvw' \
--data-binary '{"jsonrpc":"2.0","method":"Auth.logout", "id":"jsonrpc"}';我希望在我退出后,会话id将不再工作,但我仍然可以使用它来访问Kiwi-tcms中的数据。
发布于 2021-02-10 08:57:54
Auth.logout()调用django.contrib.auth.logout(request),而后者又调用request.session.flush()
我希望在我注销后,会话id将不再工作,但是我仍然可以使用它来访问Kiwi中的数据。
事实上,这就是我所发生的事情:
$ curl 'http://127.0.0.1:8000/json-rpc/' \
-H 'Content-Type: application/json' \
-H 'Cookie: sessionid=xyz' \
--data-binary '{"jsonrpc":"2.0","method":"TestPlan.filter", "params":{"is_active":true}],"id":"jsonrpc"}';
{"id": "jsonrpc", "jsonrpc": "2.0", "error": {"code": -32603, "message": "Internal error: Authentication failed when calling \"TestPlan.filter\""}}您可能使用的是一个旧版本的Kiwi,它没有正确地检查API凭据:https://kiwitcms.readthedocs.io/en/latest/changelog.html#kiwi-tcms-8-6-23-aug-2020 <--这也是一个安全漏洞,所以立即升级。
https://stackoverflow.com/questions/66128635
复制相似问题