Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

kernel supports read-only publishing services #11364

Closed
Zuoqiu-Yingyi opened this issue May 12, 2024 · 6 comments
Closed

kernel supports read-only publishing services #11364

Zuoqiu-Yingyi opened this issue May 12, 2024 · 6 comments

Comments

@Zuoqiu-Yingyi
Copy link
Contributor

In what scenarios do you need this feature?

当前内核服务仅能在内核启动时设置为只读模式, 无法同时支持 #6568 中所述的编辑与发布

Describe the optimal solution

参考桌面端基于 ReverseProxy6806 端口的反向代理, 发布服务也可以通过反向代理实现

  1. 用户自定义的发布端口接收到请求后使用 BasicAuth 鉴权 (可选)
  2. 反向代理服务附加一个 HTTP 请求头字段 Proxy-Authorization, 该请求头的字段值为一个 JWT, 里面保存相关的上下文信息
  3. 反向代理转发该请求至主服务端口
  4. 主服务 CheckAuth 中间件获取附加的 HTTP 请求头字段, 校验并解析
    • 获取 || 校验 || 解析失败: 回退到正常的认证流程
    • 获取 && 校验 && 解析成功: 将解析后的载荷添加到请求上下文中并删除该请求头 (避免通过 api/network/echo 获取该 JWT)
  5. 主服务 CheckReadonly 中间件通过请求的上下文动态判断是否组织访问

Describe the candidate solution

No response

Other information

只读模式下 /api/system/getConf 等 API 会暴露设置中的一些敏感字段, 需要额外处理
WebSocket /ws 需要动态判断是否来自于只读发布服务

@88250
Copy link
Member

88250 commented May 12, 2024

需要增加新的内核启动参数吗?比如只读伺服的端口。

@Zuoqiu-Yingyi
Copy link
Contributor Author

需要增加新的内核启动参数吗?比如只读伺服的端口。

可以直接在设置面板/conf.json中设置

@88250
Copy link
Member

88250 commented May 12, 2024

需要的配置项麻烦列出我们讨论看看。

@Zuoqiu-Yingyi
Copy link
Contributor Author

需要的配置项麻烦列出我们讨论看看。

直接在 PR 中讨论吧

@leolee9086
Copy link

config.repo

包含了同步数据仓库的密钥

config.api

包含了apitoken

config.ai

包含了AI的apiKey

config.sync

包含了s3和webdav的相关信息.

config.localIPs

包含了本地ip地址,如果用户使用了代理转发隐藏ip可能这里不方便暴露

config.userData

包含账户信息

看了下conf.json里面这些字段是不是要过滤一下?

@88250 88250 moved this to Short Term in SiYuan Roadmap May 17, 2024
@88250 88250 removed this from SiYuan Roadmap May 17, 2024
@88250
Copy link
Member

88250 commented May 20, 2024

在 PR 中继续跟进。

@88250 88250 closed this as completed May 20, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants