Skip to content

Add local-only web setup editor for external config#17

Merged
pilgrimage233 merged 3 commits intodevelopmentfrom
copilot/add-configuration-setup-web-page
Feb 7, 2026
Merged

Add local-only web setup editor for external config#17
pilgrimage233 merged 3 commits intodevelopmentfrom
copilot/add-configuration-setup-web-page

Conversation

Copy link
Copy Markdown
Contributor

Copilot AI commented Feb 7, 2026

启动时需要手动修改外置配置文件(如 MySQL/Redis 等)不够友好。此变更提供启动初期的可视化配置入口,简化首次部署配置流程。

  • Setup entrypoint & safety guardrails
    • 新增匿名 /setup/config 读取/保存外置配置,仅允许本机访问(setup.allow-remote=true 可选放开)
    • 路径限制 + 安全 YAML 校验,避免非法写入与解析风险
  • UI workflow
    • 新增 setup.html 可视化编辑 application.yml / application-druid.yml
    • 明确安全警告与错误提示,保存后提示需重启
  • Visibility
    • 启动日志输出配置向导地址
    • README 补充入口说明
GET  /setup/config?file=application.yml
POST /setup/config?file=application-druid.yml

Screenshot

Warning

Firewall rules blocked me from connecting to one or more addresses (expand for details)

I tried to connect to the following addresses, but was blocked by firewall rules:

  • mybatis.org
    • Triggering command: /opt/hostedtoolcache/CodeQL/2.24.0/x64/codeql/tools/linux64/java/bin/java /opt/hostedtoolcache/CodeQL/2.24.0/x64/codeql/tools/linux64/java/bin/java -jar /opt/hostedtoolcache/CodeQL/2.24.0/x64/codeql/xml/tools/xml-extractor.jar --fileList=/home/REDACTED/work/Minecraft-Rcon-Manage/.codeql-scratch/dbs/java/working/files-to-index4140316050475057365.list --sourceArchiveDir=/home/REDACTED/work/Minecraft-Rcon-Manage/.codeql-scratch/dbs/java/src --outputDir=/home/REDACTED/work/Minecraft-Rcon-Manage/.codeql-scratch/dbs/java/trap/java (dns block)

If you need me to access, download, or install something from one of these locations, you can either:

Original prompt

如果项目启动用户需要手动修改项目根目录生成的外置config里的配置文件,比如 mysql服务器地址 Redis地址,以及一些其他自定义的东西,很不友好。 可以在启动初期打开一个web页面辅助可视化用户修改配置吗?


💬 We'd love your input! Share your thoughts on Copilot coding agent in our 2 minute survey.

Copilot AI and others added 2 commits February 7, 2026 11:30
Co-authored-by: pilgrimage233 <70379307+pilgrimage233@users.noreply.github.com>
Co-authored-by: pilgrimage233 <70379307+pilgrimage233@users.noreply.github.com>
Copilot AI changed the title [WIP] Add web page for user configuration setup Add local-only web setup editor for external config Feb 7, 2026
Copilot AI requested a review from pilgrimage233 February 7, 2026 11:40
Repository owner deleted a comment from Copilot AI Feb 7, 2026
@pilgrimage233 pilgrimage233 marked this pull request as ready for review February 7, 2026 11:54
Copilot AI review requested due to automatic review settings February 7, 2026 11:54
@pilgrimage233 pilgrimage233 merged commit 0f1b73a into development Feb 7, 2026
5 checks passed
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR introduces a local-only web-based “setup wizard” to read/edit externalized configuration files under the config/ directory during initial startup, aiming to simplify first-time deployment configuration.

Changes:

  • Added setup.html UI for editing application.yml and application-druid.yml via HTTP.
  • Added anonymous /setup/config GET/POST endpoints with “local-only by default” access guard and YAML validation.
  • Added setup.allow-remote configuration flag and startup log/README guidance for the setup entrypoint.

Reviewed changes

Copilot reviewed 5 out of 5 changed files in this pull request and generated 4 comments.

Show a summary per file
File Description
endless-admin/src/main/resources/static/setup.html Provides a browser UI to load/save external config via /setup/config.
endless-admin/src/main/resources/application.yml Adds setup.allow-remote flag (default false).
endless-admin/src/main/java/cc/endmc/web/controller/setup/SetupConfigController.java Implements anonymous config read/write API with local-only gating and YAML parsing.
endless-admin/src/main/java/cc/endmc/EndlessApplication.java Logs the setup wizard URL after startup.
README.md Documents the setup wizard entry URL and remote access flag.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

saveBtn.disabled = true;
reloadBtn.disabled = true;
try {
const response = await fetch(`/setup/config?file=${encodeURIComponent(file)}`);
Copy link

Copilot AI Feb 7, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

这里的 fetch 使用以 “/” 开头的绝对路径(/setup/config)。当应用配置了 server.servlet.context-path(非根路径)时,请求会发到域名根路径而不是当前应用上下文,导致读取/保存失败。建议改为相对路径(例如 setup/config)或基于 window.location 拼出包含 context-path 的 URL。

Suggested change
const response = await fetch(`/setup/config?file=${encodeURIComponent(file)}`);
const response = await fetch(`setup/config?file=${encodeURIComponent(file)}`);

Copilot uses AI. Check for mistakes.
Comment on lines +191 to +202
const saveConfig = async () => {
const file = fileSelect.value;
setStatus('正在保存配置...', '');
saveBtn.disabled = true;
try {
const response = await fetch(`/setup/config?file=${encodeURIComponent(file)}`, {
method: 'POST',
headers: {
'Content-Type': 'text/plain; charset=utf-8'
},
body: contentArea.value
});
Copy link

Copilot AI Feb 7, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

保存接口同样使用了绝对路径 /setup/config,在配置了 server.servlet.context-path 时会指向错误的地址。建议与加载接口保持一致,改为相对路径或根据当前页面上下文动态拼接。

Copilot uses AI. Check for mistakes.
Comment on lines +133 to +136
private boolean isRequestAllowed(HttpServletRequest request)
{
return allowRemote || isLocalAddress(request.getRemoteAddr());
}
Copy link

Copilot AI Feb 7, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

isRequestAllowed 仅基于 request.getRemoteAddr() 的 loopback 判断。在反向代理(Nginx/Traefik)部署且代理与应用同机时,外网请求的 remoteAddr 可能始终是 127.0.0.1/::1,从而绕过“仅本机访问”限制。另外当前全局 CORS 允许任意 Origin 时,浏览器可跨站向 localhost 发起 POST,形成 CSRF 风险。建议在 allow-remote=false 时:检测并拒绝带 Forwarded/X-Forwarded-* 的请求,且为保存操作增加一次性 token/密码校验或显式限制 Origin/关闭 /setup/** 的 CORS。

Copilot uses AI. Check for mistakes.
Comment on lines +154 to +165
private boolean isValidYaml(String content)
{
try
{
SAFE_YAML.load(content);
return true;
}
catch (YAMLException ex)
{
log.warn("YAML格式校验失败", ex);
return false;
}
Copy link

Copilot AI Feb 7, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

YAML 校验这里使用 SAFE_YAML.load(content):它只解析第一个 document(--- 之后的内容可能未被校验),并且 LoaderOptions 未设置 codePointLimit / maxAliasesForCollections 等限制,远程放开时可能被构造超大/高别名输入导致解析耗时或内存膨胀。建议改为遍历 loadAll 校验所有 documents,并在 LoaderOptions 上配置合理上限。

Copilot uses AI. Check for mistakes.
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

Successfully merging this pull request may close these issues.

3 participants