Conversation
新增接口:用户列表、发表文章、新增分类/标签 新增apiToken校验
发表评论/发表文章/新增分类接口增加校验csrfToken、 文章详情不返回csrfToken、 单元测试修改
发布文章、新增标签/分类接口修改 增加可选校验高敏接口设置
Action.php
Outdated
| protected \Typecho\Widget\Response $response; | ||
|
|
||
|
|
||
| protected $version; |
There was a problem hiding this comment.
这里 $version 始终是常量?常量不会变,不需要作为类成员
|
|
||
| ### 2025-07-21 | ||
|
|
||
| - 适配typecho1.3 |
There was a problem hiding this comment.
主要是一些方法传参在1.2可以,1.3会报错
Action.php
Outdated
| $this->sendCORS(); | ||
| $this->parseRequest(); | ||
|
|
||
| // 1.3不会调用、手动调用方法 |
There was a problem hiding this comment.
不需要判断,测试发现1.2.1跟1.3都需要这样写才会生效
Action.php
Outdated
| private function sendCORS() | ||
| { | ||
| $httpOrigin = $this->request->getServer('HTTP_ORIGIN'); | ||
| $httpHost = $this->request->getServer('HTTP_HOST'); |
There was a problem hiding this comment.
origin 和 host 不是一个概念吧?origin 会包含协议,这里改成 host 是不是 breaking change 了
| private function parseRequest() | ||
| { | ||
| if ($this->request->isPost()) { | ||
| $pathInfo = (string)$this->request->getPathInfo(); |
There was a problem hiding this comment.
upload上传file时解析会报错,所以加了一个配置跳过解析
Action.php
Outdated
| if ($this->config->validateLogin == 1 && !$this->widget('Widget_User')->hasLogin()) { | ||
| $this->throwError('User must be logged in', 401); | ||
| } | ||
| if (empty($_FILES)) { |
There was a problem hiding this comment.
这些解析请求体上传文件的逻辑单独拆到一个文件里,插件 controller 只要关心最终解析出来的文件结果即可。
不要把复杂逻辑耦合在这里。
| /** | ||
| * 上传文件 | ||
| */ | ||
| public function uploadAction() |
Action.php
Outdated
| { | ||
| $this->lockMethod('post'); | ||
| $this->checkState('deleteFile'); | ||
| if ($this->config->validateLogin == 1 && !$this->widget('Widget_User')->hasLogin()) { |
| # 变更日志 | ||
|
|
||
| ### 2025-09-15 | ||
| - 新增文件管理接口 |
There was a problem hiding this comment.
这里引入文件管理接口,想要解决的问题是什么?
个人觉得引入操作文件的 API 很可能有安全风险。
|
有个问题,引入文件管理接口,想要解决的问题是什么呢?我似乎不能推导出这个功能使用的场景。 而且引入操作文件的 API 很可能有安全风险,需要有严格的权限控制和校验,很容易引入漏洞。感觉 ROI 并不高。 |
我写的一个插件需要用到文件管理功能,所以加了这几个api |
既然同样是插件,这个不能实现在你的插件中吗? |
不行啊,是一个笔记软件的插件,是用来同步本地笔记到typecho上的 |
#31