P0(高危): - 新增全局 CSRF 中间件(同步器令牌),覆盖全部 30 个表单与 AJAX 请求 - 修复附件上传/列表/删除越权(IDOR),增加 admin/上传者/文章作者所有权校验 - 登录/注册成功后会话轮换,修复会话固定 - 会话密钥改用 crypto/rand 生成,配置缺失 secret 时拒绝启动 P1(中危): - session 与 comment_uid cookie 增加 Secure/SameSite 标志 - 新增安全响应头:CSP、X-Content-Type-Options、X-Frame-Options、HSTS 等 - 新增 web.trusted_proxies 配置,修复 X-Forwarded-For 伪造 - 修复浏览量记录 goroutine 访问已回收 gin.Context 的数据竞争 补充 17 个安全回归测试(middleware/handlers),go test -race 全绿
109 lines
5.2 KiB
HTML
109 lines
5.2 KiB
HTML
{{define "my_article_form"}}
|
|
{{template "header" .}}
|
|
{{template "markdown_assets" .}}
|
|
<section class="max-w-4xl mx-auto px-4 py-12">
|
|
<div class="mb-8">
|
|
<h2 class="text-3xl font-bold text-gray-900">{{.FormTitleText}}</h2>
|
|
</div>
|
|
|
|
{{if .Error}}
|
|
<div class="mb-6 bg-red-50 border border-red-200 text-red-700 px-4 py-3 rounded-lg">
|
|
{{.Error}}
|
|
</div>
|
|
{{end}}
|
|
|
|
<form action="{{.FormAction}}" method="post" class="bg-white rounded-xl shadow-sm border border-gray-200 p-6 space-y-6">
|
|
<input type="hidden" name="_csrf" value="{{.CSRFToken}}">
|
|
{{if .SessionToken}}
|
|
<input type="hidden" name="session_token" value="{{.SessionToken}}">
|
|
{{end}}
|
|
|
|
<div>
|
|
<label class="block text-sm font-medium text-gray-700 mb-2">{{index .Tr "article_field_title"}}</label>
|
|
<input type="text" name="title" value="{{.FormTitle}}" required
|
|
class="w-full px-3 py-2 border border-gray-300 rounded-lg focus:ring-2 focus:ring-blue-500 focus:border-blue-500">
|
|
</div>
|
|
|
|
<div>
|
|
<label class="block text-sm font-medium text-gray-700 mb-2">{{index .Tr "article_field_slug"}}</label>
|
|
<input type="text" name="slug" value="{{.FormSlug}}"
|
|
class="w-full px-3 py-2 border border-gray-300 rounded-lg focus:ring-2 focus:ring-blue-500 focus:border-blue-500">
|
|
<p class="mt-1 text-sm text-gray-500">{{index .Tr "article_slug_help"}}</p>
|
|
</div>
|
|
|
|
<div>
|
|
<label class="block text-sm font-medium text-gray-700 mb-2">{{index .Tr "article_field_summary"}}</label>
|
|
<textarea name="summary" rows="3"
|
|
class="w-full px-3 py-2 border border-gray-300 rounded-lg focus:ring-2 focus:ring-blue-500 focus:border-blue-500">{{.FormSummary}}</textarea>
|
|
</div>
|
|
|
|
<div>
|
|
<label class="block text-sm font-medium text-gray-700 mb-2">{{index .Tr "article_field_content"}}</label>
|
|
<textarea id="content" name="content" rows="20"
|
|
class="w-full px-3 py-2 border border-gray-300 rounded-lg focus:ring-2 focus:ring-blue-500 focus:border-blue-500">{{.FormContent}}</textarea>
|
|
</div>
|
|
|
|
<div>
|
|
<label class="block text-sm font-medium text-gray-700 mb-2">{{index .Tr "article_field_cover"}}</label>
|
|
<input type="text" name="cover" value="{{.FormCover}}"
|
|
class="w-full px-3 py-2 border border-gray-300 rounded-lg focus:ring-2 focus:ring-blue-500 focus:border-blue-500">
|
|
<p class="mt-1 text-sm text-gray-500">{{index .Tr "article_cover_help"}}</p>
|
|
</div>
|
|
|
|
<div>
|
|
<label class="block text-sm font-medium text-gray-700 mb-2">{{index .Tr "article_published_at"}}</label>
|
|
<input type="datetime-local" name="published_at" value="{{.FormPublishedAt}}"
|
|
class="w-full px-3 py-2 border border-gray-300 rounded-lg focus:ring-2 focus:ring-blue-500 focus:border-blue-500">
|
|
<p class="mt-1 text-sm text-gray-500">{{index .Tr "article_published_at_hint"}}</p>
|
|
</div>
|
|
|
|
<div class="grid grid-cols-1 md:grid-cols-2 gap-6">
|
|
<div>
|
|
<label class="block text-sm font-medium text-gray-700 mb-2">{{index .Tr "article_field_status"}}</label>
|
|
<select name="status"
|
|
class="w-full px-3 py-2 border border-gray-300 rounded-lg focus:ring-2 focus:ring-blue-500 focus:border-blue-500">
|
|
<option value="0" {{if eq .FormStatus "0"}}selected{{end}}>{{index .Tr "article_draft"}}</option>
|
|
<option value="1" {{if eq .FormStatus "1"}}selected{{end}}>{{index .Tr "article_published"}}</option>
|
|
</select>
|
|
</div>
|
|
|
|
<div class="flex items-center">
|
|
<label class="flex items-center cursor-pointer">
|
|
<input type="checkbox" name="is_top" value="1" {{if .FormIsTop}}checked{{end}}
|
|
class="w-4 h-4 text-blue-600 border-gray-300 rounded focus:ring-blue-500">
|
|
<span class="ml-2 text-sm font-medium text-gray-700">{{index .Tr "article_field_is_top"}}</span>
|
|
</label>
|
|
</div>
|
|
</div>
|
|
|
|
<div class="flex gap-3">
|
|
<button type="submit"
|
|
class="bg-blue-600 text-white px-6 py-2 rounded-lg font-medium hover:bg-blue-700 transition-colors">
|
|
{{index .Tr "article_save"}}
|
|
</button>
|
|
<a href="/my/articles"
|
|
class="bg-gray-200 text-gray-700 px-6 py-2 rounded-lg font-medium hover:bg-gray-300 transition-colors">
|
|
{{index .Tr "article_cancel"}}
|
|
</a>
|
|
</div>
|
|
</form>
|
|
</section>
|
|
|
|
<script>
|
|
document.addEventListener('DOMContentLoaded', function() {
|
|
var easyMDE = new EasyMDE({
|
|
element: document.getElementById('content'),
|
|
spellChecker: false,
|
|
status: false,
|
|
previewRender: function (plainText, preview) {
|
|
return '<div class="md-body">' + BlogMD.render(plainText) + '</div>';
|
|
},
|
|
toolbar: ["bold", "italic", "heading", "|", "quote", "unordered-list", "ordered-list", "|",
|
|
"link", "image", "|", "preview", "side-by-side", "fullscreen", "|", "guide"]
|
|
});
|
|
});
|
|
</script>
|
|
|
|
{{template "footer" .}}
|
|
{{end}}
|