{ "swagger": "2.0", "info": { "description": "简单的 Web 应用防火墙管理系统 API", "title": "Simple-WAF API", "termsOfService": "http://swagger.io/terms/", "contact": { "name": "API Support", "url": "http://www.swagger.io/support", "email": "support@swagger.io" }, "license": { "name": "Apache 2.0", "url": "http://www.apache.org/licenses/LICENSE-2.0.html" }, "version": "1.0" }, "host": "localhost:2333", "basePath": "/api/v1", "paths": { "/api/v1/certificates": { "get": { "security": [ { "BearerAuth": [] } ], "description": "获取所有SSL/TLS证书列表,支持分页", "produces": [ "application/json" ], "tags": [ "证书管理" ], "summary": "获取证书列表", "parameters": [ { "type": "integer", "default": 1, "description": "页码", "name": "page", "in": "query" }, { "type": "integer", "default": 10, "description": "每页数量", "name": "size", "in": "query" } ], "responses": { "200": { "description": "获取证书列表成功", "schema": { "allOf": [ { "$ref": "#/definitions/model.SuccessResponse" }, { "type": "object", "properties": { "data": { "$ref": "#/definitions/dto.CertificateListResponse" } } } ] } }, "401": { "description": "未授权访问", "schema": { "$ref": "#/definitions/model.ErrResponseDontShowError" } }, "500": { "description": "服务器内部错误", "schema": { "$ref": "#/definitions/model.ErrResponseDontShowError" } } } }, "post": { "security": [ { "BearerAuth": [] } ], "description": "创建一个新的SSL/TLS证书", "consumes": [ "application/json" ], "produces": [ "application/json" ], "tags": [ "证书管理" ], "summary": "创建新证书", "parameters": [ { "description": "证书信息", "name": "certificate", "in": "body", "required": true, "schema": { "$ref": "#/definitions/dto.CertificateCreateRequest" } } ], "responses": { "200": { "description": "证书创建成功", "schema": { "allOf": [ { "$ref": "#/definitions/model.SuccessResponse" }, { "type": "object", "properties": { "data": { "$ref": "#/definitions/model.CertificateStore" } } } ] } }, "400": { "description": "请求参数错误", "schema": { "$ref": "#/definitions/model.ErrResponse" } }, "401": { "description": "未授权访问", "schema": { "$ref": "#/definitions/model.ErrResponseDontShowError" } }, "403": { "description": "禁止访问", "schema": { "$ref": "#/definitions/model.ErrResponseDontShowError" } }, "409": { "description": "证书名称已存在", "schema": { "$ref": "#/definitions/model.ErrResponseDontShowError" } }, "500": { "description": "服务器内部错误", "schema": { "$ref": "#/definitions/model.ErrResponseDontShowError" } } } } }, "/api/v1/certificates/{id}": { "get": { "security": [ { "BearerAuth": [] } ], "description": "根据ID获取证书详情", "produces": [ "application/json" ], "tags": [ "证书管理" ], "summary": "获取单个证书", "parameters": [ { "type": "string", "description": "证书ID", "name": "id", "in": "path", "required": true } ], "responses": { "200": { "description": "获取证书详情成功", "schema": { "allOf": [ { "$ref": "#/definitions/model.SuccessResponse" }, { "type": "object", "properties": { "data": { "$ref": "#/definitions/model.CertificateStore" } } } ] } }, "401": { "description": "未授权访问", "schema": { "$ref": "#/definitions/model.ErrResponseDontShowError" } }, "404": { "description": "证书不存在", "schema": { "$ref": "#/definitions/model.ErrResponseDontShowError" } }, "500": { "description": "服务器内部错误", "schema": { "$ref": "#/definitions/model.ErrResponseDontShowError" } } } }, "put": { "security": [ { "BearerAuth": [] } ], "description": "更新指定证书的信息", "consumes": [ "application/json" ], "produces": [ "application/json" ], "tags": [ "证书管理" ], "summary": "更新证书", "parameters": [ { "type": "string", "description": "证书ID", "name": "id", "in": "path", "required": true }, { "description": "证书更新信息", "name": "certificate", "in": "body", "required": true, "schema": { "$ref": "#/definitions/dto.CertificateUpdateRequest" } } ], "responses": { "200": { "description": "证书更新成功", "schema": { "allOf": [ { "$ref": "#/definitions/model.SuccessResponse" }, { "type": "object", "properties": { "data": { "$ref": "#/definitions/model.CertificateStore" } } } ] } }, "400": { "description": "请求参数错误", "schema": { "$ref": "#/definitions/model.ErrResponse" } }, "401": { "description": "未授权访问", "schema": { "$ref": "#/definitions/model.ErrResponseDontShowError" } }, "403": { "description": "禁止访问", "schema": { "$ref": "#/definitions/model.ErrResponseDontShowError" } }, "404": { "description": "证书不存在", "schema": { "$ref": "#/definitions/model.ErrResponseDontShowError" } }, "409": { "description": "证书名称已存在", "schema": { "$ref": "#/definitions/model.ErrResponseDontShowError" } }, "500": { "description": "服务器内部错误", "schema": { "$ref": "#/definitions/model.ErrResponseDontShowError" } } } }, "delete": { "security": [ { "BearerAuth": [] } ], "description": "删除指定的SSL/TLS证书", "produces": [ "application/json" ], "tags": [ "证书管理" ], "summary": "删除证书", "parameters": [ { "type": "string", "description": "证书ID", "name": "id", "in": "path", "required": true } ], "responses": { "200": { "description": "证书删除成功", "schema": { "$ref": "#/definitions/model.SuccessResponseNoData" } }, "401": { "description": "未授权访问", "schema": { "$ref": "#/definitions/model.ErrResponseDontShowError" } }, "403": { "description": "禁止访问", "schema": { "$ref": "#/definitions/model.ErrResponseDontShowError" } }, "404": { "description": "证书不存在", "schema": { "$ref": "#/definitions/model.ErrResponseDontShowError" } }, "500": { "description": "服务器内部错误", "schema": { "$ref": "#/definitions/model.ErrResponseDontShowError" } } } } }, "/api/v1/site": { "get": { "security": [ { "BearerAuth": [] } ], "description": "获取所有站点配置列表", "produces": [ "application/json" ], "tags": [ "站点管理" ], "summary": "获取站点列表", "parameters": [ { "type": "integer", "default": 1, "description": "页码", "name": "page", "in": "query" }, { "type": "integer", "default": 10, "description": "每页数量", "name": "size", "in": "query" } ], "responses": { "200": { "description": "获取站点列表成功", "schema": { "allOf": [ { "$ref": "#/definitions/model.SuccessResponse" }, { "type": "object", "properties": { "data": { "$ref": "#/definitions/dto.SiteListResponse" } } } ] } }, "401": { "description": "未授权访问", "schema": { "$ref": "#/definitions/model.ErrResponseDontShowError" } }, "500": { "description": "服务器内部错误", "schema": { "$ref": "#/definitions/model.ErrResponseDontShowError" } } } }, "post": { "security": [ { "BearerAuth": [] } ], "description": "创建一个新的站点配置", "consumes": [ "application/json" ], "produces": [ "application/json" ], "tags": [ "站点管理" ], "summary": "创建新站点", "parameters": [ { "description": "站点信息", "name": "site", "in": "body", "required": true, "schema": { "$ref": "#/definitions/dto.CreateSiteRequest" } } ], "responses": { "200": { "description": "站点创建成功", "schema": { "allOf": [ { "$ref": "#/definitions/model.SuccessResponse" }, { "type": "object", "properties": { "data": { "$ref": "#/definitions/dto.SiteResponse" } } } ] } }, "400": { "description": "请求参数错误", "schema": { "$ref": "#/definitions/model.ErrResponse" } }, "401": { "description": "未授权访问", "schema": { "$ref": "#/definitions/model.ErrResponseDontShowError" } }, "403": { "description": "禁止访问", "schema": { "$ref": "#/definitions/model.ErrResponseDontShowError" } }, "409": { "description": "域名和端口组合已存在", "schema": { "$ref": "#/definitions/model.ErrResponseDontShowError" } }, "500": { "description": "服务器内部错误", "schema": { "$ref": "#/definitions/model.ErrResponseDontShowError" } } } } }, "/api/v1/site/{id}": { "get": { "security": [ { "BearerAuth": [] } ], "description": "根据ID获取站点详情", "produces": [ "application/json" ], "tags": [ "站点管理" ], "summary": "获取单个站点", "parameters": [ { "type": "string", "description": "站点ID", "name": "id", "in": "path", "required": true } ], "responses": { "200": { "description": "获取站点详情成功", "schema": { "allOf": [ { "$ref": "#/definitions/model.SuccessResponse" }, { "type": "object", "properties": { "data": { "$ref": "#/definitions/dto.SiteResponse" } } } ] } }, "401": { "description": "未授权访问", "schema": { "$ref": "#/definitions/model.ErrResponseDontShowError" } }, "404": { "description": "站点不存在", "schema": { "$ref": "#/definitions/model.ErrResponseDontShowError" } }, "500": { "description": "服务器内部错误", "schema": { "$ref": "#/definitions/model.ErrResponseDontShowError" } } } }, "put": { "security": [ { "BearerAuth": [] } ], "description": "更新指定站点的配置", "consumes": [ "application/json" ], "produces": [ "application/json" ], "tags": [ "站点管理" ], "summary": "更新站点", "parameters": [ { "type": "string", "description": "站点ID", "name": "id", "in": "path", "required": true }, { "description": "站点更新信息", "name": "site", "in": "body", "required": true, "schema": { "$ref": "#/definitions/dto.UpdateSiteRequest" } } ], "responses": { "200": { "description": "站点更新成功", "schema": { "allOf": [ { "$ref": "#/definitions/model.SuccessResponse" }, { "type": "object", "properties": { "data": { "$ref": "#/definitions/dto.SiteResponse" } } } ] } }, "400": { "description": "请求参数错误", "schema": { "$ref": "#/definitions/model.ErrResponse" } }, "401": { "description": "未授权访问", "schema": { "$ref": "#/definitions/model.ErrResponseDontShowError" } }, "403": { "description": "禁止访问", "schema": { "$ref": "#/definitions/model.ErrResponseDontShowError" } }, "404": { "description": "站点不存在", "schema": { "$ref": "#/definitions/model.ErrResponseDontShowError" } }, "409": { "description": "域名和端口组合已被其他站点使用", "schema": { "$ref": "#/definitions/model.ErrResponseDontShowError" } }, "500": { "description": "服务器内部错误", "schema": { "$ref": "#/definitions/model.ErrResponseDontShowError" } } } }, "delete": { "security": [ { "BearerAuth": [] } ], "description": "删除指定的站点配置", "produces": [ "application/json" ], "tags": [ "站点管理" ], "summary": "删除站点", "parameters": [ { "type": "string", "description": "站点ID", "name": "id", "in": "path", "required": true } ], "responses": { "200": { "description": "站点删除成功", "schema": { "$ref": "#/definitions/model.SuccessResponseNoData" } }, "401": { "description": "未授权访问", "schema": { "$ref": "#/definitions/model.ErrResponseDontShowError" } }, "403": { "description": "禁止访问", "schema": { "$ref": "#/definitions/model.ErrResponseDontShowError" } }, "404": { "description": "站点不存在", "schema": { "$ref": "#/definitions/model.ErrResponseDontShowError" } }, "500": { "description": "服务器内部错误", "schema": { "$ref": "#/definitions/model.ErrResponseDontShowError" } } } } }, "/api/v1/waf/logs": { "get": { "description": "查询详细的WAF攻击日志记录,提供多条件筛选和分页功能,支持按规则ID、IP、域名、端口和时间范围过滤", "consumes": [ "application/json" ], "produces": [ "application/json" ], "tags": [ "WAF安全日志" ], "summary": "获取详细攻击日志", "parameters": [ { "type": "integer", "description": "规则ID,触发攻击检测的WAF规则标识", "name": "ruleId", "in": "query" }, { "type": "string", "description": "来源IP地址,攻击者地址", "name": "srcIp", "in": "query" }, { "type": "string", "description": "目标IP地址,被攻击的服务器地址", "name": "dstIp", "in": "query" }, { "type": "string", "description": "域名,被攻击的站点域名", "name": "domain", "in": "query" }, { "type": "integer", "description": "来源端口号,发起攻击的端口", "name": "srcPort", "in": "query" }, { "type": "integer", "description": "目标端口号,被攻击的服务端口", "name": "dstPort", "in": "query" }, { "type": "string", "description": "请求ID,唯一标识HTTP请求的ID", "name": "requestId", "in": "query" }, { "type": "string", "description": "查询起始时间 (ISO8601格式,如: 2024-03-17T00:00:00Z)", "name": "startTime", "in": "query" }, { "type": "string", "description": "查询结束时间 (ISO8601格式,如: 2024-03-18T23:59:59Z)", "name": "endTime", "in": "query" }, { "type": "integer", "description": "当前页码,从1开始计数 (默认: 1)", "name": "page", "in": "query" }, { "type": "integer", "description": "每页记录数,最大100条 (默认: 10)", "name": "pageSize", "in": "query" } ], "responses": { "200": { "description": "成功", "schema": { "allOf": [ { "$ref": "#/definitions/model.SuccessResponse" }, { "type": "object", "properties": { "data": { "$ref": "#/definitions/dto.AttackLogResponse" } } } ] } }, "400": { "description": "请求参数错误", "schema": { "$ref": "#/definitions/model.ErrResponse" } }, "500": { "description": "服务器内部错误", "schema": { "$ref": "#/definitions/model.ErrResponseDontShowError" } } } } }, "/api/v1/waf/logs/events": { "get": { "description": "按来源IP、目标端口和域名聚合的攻击事件统计,支持多维度筛选和分页", "consumes": [ "application/json" ], "produces": [ "application/json" ], "tags": [ "WAF安全日志" ], "summary": "获取聚合攻击事件", "parameters": [ { "type": "string", "description": "来源IP地址,攻击者地址", "name": "srcIp", "in": "query" }, { "type": "string", "description": "目标IP地址,被攻击的服务器地址", "name": "dstIp", "in": "query" }, { "type": "string", "description": "域名,被攻击的站点域名", "name": "domain", "in": "query" }, { "type": "integer", "description": "来源端口号,发起攻击的端口", "name": "srcPort", "in": "query" }, { "type": "integer", "description": "目标端口号,被攻击的服务端口", "name": "dstPort", "in": "query" }, { "type": "string", "description": "查询起始时间 (ISO8601格式,如: 2024-03-17T00:00:00Z)", "name": "startTime", "in": "query" }, { "type": "string", "description": "查询结束时间 (ISO8601格式,如: 2024-03-18T23:59:59Z)", "name": "endTime", "in": "query" }, { "type": "integer", "description": "当前页码,从1开始计数 (默认: 1)", "name": "page", "in": "query" }, { "type": "integer", "description": "每页记录数,最大100条 (默认: 10)", "name": "pageSize", "in": "query" } ], "responses": { "200": { "description": "成功", "schema": { "allOf": [ { "$ref": "#/definitions/model.SuccessResponse" }, { "type": "object", "properties": { "data": { "$ref": "#/definitions/dto.AttackEventResponse" } } } ] } }, "400": { "description": "请求参数错误", "schema": { "$ref": "#/definitions/model.ErrResponse" } }, "500": { "description": "服务器内部错误", "schema": { "$ref": "#/definitions/model.ErrResponseDontShowError" } } } } }, "/auth/login": { "post": { "description": "用户登录并获取JWT令牌", "consumes": [ "application/json" ], "produces": [ "application/json" ], "tags": [ "认证" ], "summary": "用户登录", "parameters": [ { "description": "登录信息", "name": "request", "in": "body", "required": true, "schema": { "$ref": "#/definitions/dto.UserLoginRequest" } } ], "responses": { "200": { "description": "登录成功", "schema": { "allOf": [ { "$ref": "#/definitions/model.SuccessResponse" }, { "type": "object", "properties": { "data": { "$ref": "#/definitions/dto.LoginResponseData" } } } ] } }, "400": { "description": "请求参数错误", "schema": { "$ref": "#/definitions/model.ErrResponse" } }, "401": { "description": "用户名或密码错误", "schema": { "$ref": "#/definitions/model.ErrResponseDontShowError" } }, "500": { "description": "服务器内部错误", "schema": { "$ref": "#/definitions/model.ErrResponseDontShowError" } } } } }, "/auth/me": { "get": { "security": [ { "BearerAuth": [] } ], "description": "获取当前登录用户的详细信息", "produces": [ "application/json" ], "tags": [ "认证" ], "summary": "获取当前用户信息", "responses": { "200": { "description": "获取用户信息成功", "schema": { "allOf": [ { "$ref": "#/definitions/model.SuccessResponse" }, { "type": "object", "properties": { "data": { "$ref": "#/definitions/dto.GetUserInfoResponseData" } } } ] } }, "401": { "description": "未授权访问", "schema": { "$ref": "#/definitions/model.ErrResponseDontShowError" } } } } }, "/auth/reset-password": { "post": { "security": [ { "BearerAuth": [] } ], "description": "用户重置自己的密码", "consumes": [ "application/json" ], "produces": [ "application/json" ], "tags": [ "认证" ], "summary": "重置密码", "parameters": [ { "description": "密码重置信息", "name": "request", "in": "body", "required": true, "schema": { "$ref": "#/definitions/dto.UserPasswordResetRequest" } } ], "responses": { "200": { "description": "密码重置成功", "schema": { "$ref": "#/definitions/model.SuccessResponseNoData" } }, "400": { "description": "请求参数错误或原密码错误", "schema": { "$ref": "#/definitions/model.ErrResponseDontShowError" } }, "401": { "description": "未授权访问", "schema": { "$ref": "#/definitions/model.ErrResponseDontShowError" } }, "500": { "description": "服务器内部错误", "schema": { "$ref": "#/definitions/model.ErrResponseDontShowError" } } } } }, "/users": { "get": { "security": [ { "BearerAuth": [] } ], "description": "获取系统中所有用户的列表", "produces": [ "application/json" ], "tags": [ "用户管理" ], "summary": "获取所有用户", "responses": { "200": { "description": "获取用户列表成功", "schema": { "allOf": [ { "$ref": "#/definitions/model.SuccessResponse" }, { "type": "object", "properties": { "data": { "type": "array", "items": { "$ref": "#/definitions/model.User" } } } } ] } }, "401": { "description": "未授权访问", "schema": { "$ref": "#/definitions/model.ErrResponseDontShowError" } }, "403": { "description": "禁止访问", "schema": { "$ref": "#/definitions/model.ErrResponseDontShowError" } }, "500": { "description": "服务器内部错误", "schema": { "$ref": "#/definitions/model.ErrResponseDontShowError" } } } }, "post": { "security": [ { "BearerAuth": [] } ], "description": "管理员创建新用户", "consumes": [ "application/json" ], "produces": [ "application/json" ], "tags": [ "用户管理" ], "summary": "创建新用户", "parameters": [ { "description": "用户创建信息", "name": "request", "in": "body", "required": true, "schema": { "$ref": "#/definitions/dto.UserCreateRequest" } } ], "responses": { "200": { "description": "用户创建成功", "schema": { "$ref": "#/definitions/dto.ResetPasswordResponseData" } }, "400": { "description": "请求参数错误", "schema": { "$ref": "#/definitions/model.ErrResponse" } }, "401": { "description": "未授权访问", "schema": { "$ref": "#/definitions/model.ErrResponseDontShowError" } }, "403": { "description": "禁止访问", "schema": { "$ref": "#/definitions/model.ErrResponseDontShowError" } }, "409": { "description": "用户名已存在", "schema": { "$ref": "#/definitions/model.ErrResponseDontShowError" } }, "500": { "description": "服务器内部错误", "schema": { "$ref": "#/definitions/model.ErrResponseDontShowError" } } } } }, "/users/{id}": { "put": { "security": [ { "BearerAuth": [] } ], "description": "管理员更新指定用户的信息", "consumes": [ "application/json" ], "produces": [ "application/json" ], "tags": [ "用户管理" ], "summary": "更新用户信息", "parameters": [ { "type": "string", "description": "用户ID", "name": "id", "in": "path", "required": true }, { "description": "用户更新信息", "name": "request", "in": "body", "required": true, "schema": { "$ref": "#/definitions/dto.UserUpdateRequest" } } ], "responses": { "200": { "description": "用户更新成功", "schema": { "$ref": "#/definitions/model.APIResponse" } }, "400": { "description": "请求参数错误", "schema": { "$ref": "#/definitions/model.APIResponse" } }, "401": { "description": "未授权访问", "schema": { "$ref": "#/definitions/model.APIResponse" } }, "403": { "description": "禁止访问", "schema": { "$ref": "#/definitions/model.APIResponse" } }, "404": { "description": "用户不存在", "schema": { "$ref": "#/definitions/model.APIResponse" } }, "500": { "description": "服务器内部错误", "schema": { "$ref": "#/definitions/model.APIResponse" } } } }, "delete": { "security": [ { "BearerAuth": [] } ], "description": "管理员删除指定用户", "produces": [ "application/json" ], "tags": [ "用户管理" ], "summary": "删除用户", "parameters": [ { "type": "string", "description": "用户ID", "name": "id", "in": "path", "required": true } ], "responses": { "200": { "description": "用户删除成功", "schema": { "$ref": "#/definitions/model.APIResponse" } }, "401": { "description": "未授权访问", "schema": { "$ref": "#/definitions/model.APIResponse" } }, "403": { "description": "禁止访问", "schema": { "$ref": "#/definitions/model.APIResponse" } }, "404": { "description": "用户不存在", "schema": { "$ref": "#/definitions/model.APIResponse" } }, "500": { "description": "服务器内部错误", "schema": { "$ref": "#/definitions/model.APIResponse" } } } } } }, "definitions": { "dto.AttackEventAggregateResult": { "description": "攻击事件的聚合统计结果,提供IP、域名、端口维度的攻击信息汇总,包含攻击次数、首次和最近攻击时间、持续时间等关键指标", "type": "object", "properties": { "count": { "description": "攻击总次数,同一来源的攻击计数", "type": "integer", "example": 15 }, "domain": { "description": "域名,被攻击的站点", "type": "string", "example": "example.com" }, "dstPort": { "description": "目标端口号,被攻击的服务端口", "type": "integer", "example": 443 }, "durationInMinutes": { "description": "攻击持续时间(分钟),从首次到最近攻击的时间跨度", "type": "number", "example": 18.2 }, "firstAttackTime": { "description": "首次攻击时间,该IP首次发起攻击的时间点", "type": "string", "example": "2024-03-18T08:12:33Z" }, "isOngoing": { "description": "是否正在进行中,标识攻击是否仍在持续", "type": "boolean", "example": true }, "lastAttackTime": { "description": "最近攻击时间,该IP最后一次攻击的时间点", "type": "string", "example": "2024-03-18T08:30:45Z" }, "srcIp": { "description": "来源IP地址,攻击者地址", "type": "string", "example": "192.168.1.100" } } }, "dto.AttackEventResponse": { "description": "攻击事件查询的分页响应结构体,包含聚合结果列表及分页元数据,用于前端展示和翻页控制", "type": "object", "properties": { "currentPage": { "description": "当前页码,从1开始计数", "type": "integer", "example": 1 }, "pageSize": { "description": "每页大小,当前设置的每页记录数", "type": "integer", "example": 10 }, "results": { "description": "聚合结果列表,当前页的攻击事件记录", "type": "array", "items": { "$ref": "#/definitions/dto.AttackEventAggregateResult" } }, "totalCount": { "description": "总记录数,符合条件的攻击事件总数", "type": "integer", "example": 35 }, "totalPages": { "description": "总页数,根据总记录数和每页大小计算", "type": "integer", "example": 4 } } }, "dto.AttackLogResponse": { "description": "攻击日志查询的分页响应结构体,返回详细的WAF日志记录及分页信息,便于安全分析和事件追踪", "type": "object", "properties": { "currentPage": { "description": "当前页码,从1开始计数", "type": "integer", "example": 1 }, "pageSize": { "description": "每页大小,当前设置的每页记录数", "type": "integer", "example": 10 }, "results": { "description": "日志记录列表,当前页的WAF攻击日志详情", "type": "array", "items": { "$ref": "#/definitions/model.WAFLog" } }, "totalCount": { "description": "总记录数,符合查询条件的日志总数", "type": "integer", "example": 128 }, "totalPages": { "description": "总页数,根据总记录数和每页大小计算", "type": "integer", "example": 13 } } }, "dto.BackendDTO": { "type": "object", "required": [ "servers" ], "properties": { "servers": { "description": "服务器列表,至少需要一个服务器", "type": "array", "minItems": 1, "items": { "$ref": "#/definitions/dto.ServerDTO" } } } }, "dto.CertificateCreateRequest": { "description": "创建证书的请求参数", "type": "object", "required": [ "privateKey", "publicKey" ], "properties": { "description": { "description": "证书描述", "type": "string", "example": "用于example.com的证书" }, "domains": { "description": "证书绑定的域名列表", "type": "array", "items": { "type": "string" }, "example": [ "[\"example.com\"]" ] }, "expireDate": { "description": "证书过期日期", "type": "string", "example": "2023-12-31T23:59:59Z" }, "fingerPrint": { "description": "证书指纹", "type": "string", "example": "AA:BB:CC:DD:..." }, "issuerName": { "description": "颁发机构", "type": "string", "example": "Let's Encrypt" }, "name": { "description": "证书名称/别名", "type": "string", "example": "example-cert" }, "privateKey": { "description": "私钥内容(PEM格式)", "type": "string" }, "publicKey": { "description": "公钥内容(PEM格式)", "type": "string" } } }, "dto.CertificateDTO": { "type": "object", "required": [ "certName", "expireDate", "fingerPrint", "issuerName", "privateKey", "publicKey" ], "properties": { "certName": { "description": "证书名称", "type": "string", "example": "my-cert" }, "expireDate": { "description": "过期时间", "type": "string" }, "fingerPrint": { "description": "证书指纹", "type": "string" }, "issuerName": { "description": "颁发机构", "type": "string", "example": "Let's Encrypt" }, "privateKey": { "description": "私钥内容", "type": "string" }, "publicKey": { "description": "公钥内容", "type": "string" } } }, "dto.CertificateListResponse": { "description": "证书列表响应", "type": "object", "properties": { "items": { "description": "证书列表", "type": "array", "items": { "$ref": "#/definitions/model.CertificateStore" } }, "total": { "description": "总数", "type": "integer" } } }, "dto.CertificateUpdateRequest": { "description": "更新证书的请求参数", "type": "object", "properties": { "description": { "description": "证书描述", "type": "string", "example": "用于example.com的证书" }, "domains": { "description": "证书绑定的域名列表", "type": "array", "items": { "type": "string" }, "example": [ "[\"example.com\"]" ] }, "expireDate": { "description": "证书过期日期", "type": "string", "example": "2023-12-31T23:59:59Z" }, "fingerPrint": { "description": "证书指纹", "type": "string", "example": "AA:BB:CC:DD:..." }, "issuerName": { "description": "颁发机构", "type": "string", "example": "Let's Encrypt" }, "name": { "description": "证书名称/别名", "type": "string", "example": "example-cert" }, "privateKey": { "description": "私钥内容(PEM格式)", "type": "string" }, "publicKey": { "description": "公钥内容(PEM格式)", "type": "string" } } }, "dto.CreateSiteRequest": { "description": "创建站点的请求参数", "type": "object", "required": [ "backend", "domain", "listenPort", "name" ], "properties": { "activeStatus": { "description": "站点状态", "type": "boolean", "example": true }, "backend": { "description": "后端服务器配置", "allOf": [ { "$ref": "#/definitions/dto.BackendDTO" } ] }, "certificate": { "description": "证书信息", "allOf": [ { "$ref": "#/definitions/dto.CertificateDTO" } ] }, "domain": { "description": "域名", "type": "string", "example": "example.com" }, "enableHTTPS": { "description": "是否启用HTTPS", "type": "boolean", "example": false }, "listenPort": { "description": "监听端口", "type": "integer", "maximum": 65535, "minimum": 1, "example": 8080 }, "name": { "description": "站点名称", "type": "string", "example": "my-site" }, "wafEnabled": { "description": "是否启用WAF", "type": "boolean", "example": false }, "wafMode": { "description": "WAF模式", "type": "string", "enum": [ "protection", "observation" ], "example": "observation" } } }, "dto.GetUserInfoResponseData": { "type": "object", "properties": { "id": { "type": "string", "example": "1234567890" }, "needReset": { "type": "boolean", "example": false }, "role": { "type": "string", "example": "admin" }, "username": { "type": "string", "example": "user123" } } }, "dto.LoginResponseData": { "type": "object", "properties": { "token": { "description": "JWT token", "type": "string", "example": "eyJhbGciOiJIUzI1NiIs..." }, "user": { "description": "用户信息", "allOf": [ { "$ref": "#/definitions/model.User" } ] } } }, "dto.ResetPasswordResponseData": { "type": "object", "properties": { "code": { "type": "integer", "example": 200 }, "data": { "$ref": "#/definitions/model.User" }, "message": { "type": "string", "example": "操作成功" }, "requestId": { "type": "string", "example": "550e8400-e29b-41d4-a716-446655440000" }, "success": { "type": "boolean", "example": true }, "timestamp": { "type": "string", "example": "2023-01-01T12:00:00Z" } } }, "dto.ServerDTO": { "type": "object", "required": [ "host", "port" ], "properties": { "host": { "description": "主机地址", "type": "string", "example": "backend.example.com" }, "isSSL": { "description": "是否启用SSL", "type": "boolean", "example": false }, "port": { "description": "端口", "type": "integer", "maximum": 65535, "minimum": 1, "example": 80 } } }, "dto.SiteListResponse": { "description": "站点列表响应", "type": "object", "properties": { "items": { "description": "站点列表", "type": "array", "items": { "$ref": "#/definitions/model.Site" } }, "total": { "description": "总数", "type": "integer" } } }, "dto.SiteResponse": { "description": "站点信息响应", "type": "object", "properties": { "activeStatus": { "description": "站点是否激活", "type": "boolean" }, "backend": { "description": "后端服务器配置", "allOf": [ { "$ref": "#/definitions/model.Backend" } ] }, "certificate": { "description": "证书信息", "allOf": [ { "$ref": "#/definitions/model.Certificate" } ] }, "createdAt": { "type": "string" }, "domain": { "description": "域名,如 a.com", "type": "string" }, "enableHTTPS": { "description": "是否启用HTTPS", "type": "boolean" }, "id": { "description": "站点ID", "type": "string" }, "listenPort": { "description": "监听端口,如 9000", "type": "integer" }, "name": { "description": "站点名称", "type": "string" }, "updatedAt": { "type": "string" }, "wafEnabled": { "description": "是否启用WAF", "type": "boolean" }, "wafMode": { "description": "WAF防护模式", "allOf": [ { "$ref": "#/definitions/model.WAFMode" } ] } } }, "dto.UpdateSiteRequest": { "description": "更新站点的请求参数", "type": "object", "properties": { "activeStatus": { "description": "站点状态", "type": "boolean", "example": true }, "backend": { "description": "后端服务器配置", "allOf": [ { "$ref": "#/definitions/dto.BackendDTO" } ] }, "certificate": { "description": "证书信息", "allOf": [ { "$ref": "#/definitions/dto.CertificateDTO" } ] }, "domain": { "description": "域名", "type": "string", "example": "example.com" }, "enableHTTPS": { "description": "是否启用HTTPS", "type": "boolean", "example": false }, "listenPort": { "description": "监听端口", "type": "integer", "maximum": 65535, "minimum": 1, "example": 8080 }, "name": { "description": "站点名称", "type": "string", "example": "my-site" }, "wafEnabled": { "description": "是否启用WAF", "type": "boolean", "example": false }, "wafMode": { "description": "WAF模式", "type": "string", "enum": [ "protection", "observation" ], "example": "observation" } } }, "dto.UserCreateRequest": { "type": "object", "required": [ "password", "role", "username" ], "properties": { "password": { "type": "string", "minLength": 6 }, "role": { "type": "string", "enum": [ "admin", "user" ] }, "username": { "type": "string", "maxLength": 20, "minLength": 3 } } }, "dto.UserLoginRequest": { "type": "object", "required": [ "password", "username" ], "properties": { "password": { "type": "string" }, "username": { "type": "string" } } }, "dto.UserPasswordResetRequest": { "type": "object", "required": [ "newPassword", "oldPassword" ], "properties": { "newPassword": { "type": "string", "minLength": 6 }, "oldPassword": { "type": "string" } } }, "dto.UserUpdateRequest": { "type": "object", "properties": { "needReset": { "type": "boolean" }, "password": { "type": "string", "minLength": 6 }, "role": { "type": "string", "enum": [ "admin", "auditor", "configurator", "user" ] }, "username": { "type": "string", "maxLength": 20, "minLength": 3 } } }, "model.APIResponse": { "description": "API响应的标准格式", "type": "object", "properties": { "code": { "description": "HTTP状态码", "type": "integer", "example": 200 }, "data": { "description": "响应数据" }, "error": { "description": "错误信息(当success=false时)", "type": "string", "example": "参数错误" }, "message": { "description": "响应消息", "type": "string", "example": "操作成功" }, "requestId": { "description": "请求ID,用于跟踪", "type": "string", "example": "550e8400-e29b-41d4-a716-446655440000" }, "success": { "description": "是否成功", "type": "boolean", "example": true }, "timestamp": { "description": "响应时间戳", "type": "string", "example": "2023-01-01T12:00:00Z" } } }, "model.Backend": { "type": "object", "properties": { "servers": { "description": "服务器列表", "type": "array", "items": { "$ref": "#/definitions/model.Server" } } } }, "model.Certificate": { "type": "object", "properties": { "certName": { "description": "证书名称/别名", "type": "string" }, "expireDate": { "description": "证书过期日期", "type": "string" }, "fingerPrint": { "description": "证书指纹", "type": "string" }, "issuerName": { "description": "颁发机构", "type": "string" }, "privateKey": { "description": "私钥内容(PEM格式)", "type": "string" }, "publicKey": { "description": "公钥内容(PEM格式)", "type": "string" } } }, "model.CertificateStore": { "type": "object", "properties": { "createdAt": { "description": "创建时间", "type": "string" }, "description": { "description": "证书描述", "type": "string" }, "domains": { "description": "证书绑定的域名列表", "type": "array", "items": { "type": "string" } }, "expireDate": { "description": "证书过期日期", "type": "string" }, "fingerPrint": { "description": "证书指纹", "type": "string" }, "id": { "description": "证书ID", "type": "string" }, "issuerName": { "description": "颁发机构", "type": "string" }, "name": { "description": "证书名称/别名", "type": "string" }, "privateKey": { "description": "私钥内容(PEM格式)", "type": "string" }, "publicKey": { "description": "公钥内容(PEM格式)", "type": "string" }, "updatedAt": { "description": "更新时间", "type": "string" } } }, "model.ErrResponse": { "description": "错误的API响应标准格式", "type": "object", "properties": { "code": { "type": "integer", "example": 400 }, "error": { "type": "string", "example": "参数错误" }, "message": { "type": "string", "example": "请求参数错误" }, "requestId": { "type": "string", "example": "550e8400-e29b-41d4-a716-446655440000" }, "success": { "type": "boolean", "example": false }, "timestamp": { "type": "string", "example": "2023-01-01T12:00:00Z" } } }, "model.ErrResponseDontShowError": { "description": "错误的API响应标准格式,不展示 error", "type": "object", "properties": { "code": { "type": "integer", "example": 400 }, "message": { "type": "string", "example": "请求参数错误" }, "requestId": { "type": "string", "example": "550e8400-e29b-41d4-a716-446655440000" }, "success": { "type": "boolean", "example": false }, "timestamp": { "type": "string", "example": "2023-01-01T12:00:00Z" } } }, "model.Log": { "description": "详细的WAF规则匹配记录,包含规则触发的详细信息和原始日志", "type": "object", "properties": { "accuracy": { "description": "规则匹配准确度(0-10)", "type": "integer", "example": 9 }, "logRaw": { "description": "原始日志数据", "type": "string", "example": "[2024-03-18 08:12:33] [error] ModSecurity: Access denied with code 403 (phase 1). Matched \"Operator 'Rx' with parameter '(?:scanner)' against variable 'REQUEST_HEADERS:User-Agent'\" [id \"10086\"] [msg \"恶意扫描器检测\"] [severity \"CRITICAL\"]" }, "message": { "description": "日志消息", "type": "string", "example": "恶意扫描器检测" }, "payload": { "description": "攻击载荷", "type": "string", "example": "Scanner/1.0" }, "phase": { "description": "请求处理阶段", "type": "integer", "example": 1 }, "ruleId": { "description": "规则ID", "type": "integer", "example": 10086 }, "secLangRaw": { "description": "安全规则原始定义", "type": "string", "example": "SecRule REQUEST_HEADERS:User-Agent \"@rx (?:scanner)\" \"id:1008,phase:1,severity:'CRITICAL'\"" }, "secMark": { "description": "安全标记", "type": "string", "example": "web_scanner" }, "severity": { "description": "严重级别(0-5)", "type": "integer", "example": 2 } } }, "model.Server": { "type": "object", "properties": { "host": { "description": "主机地址,如 IP 或域名", "type": "string" }, "isSSL": { "description": "是否启用SSL", "type": "boolean" }, "port": { "description": "端口", "type": "integer" } } }, "model.Site": { "type": "object", "properties": { "activeStatus": { "description": "站点是否激活", "type": "boolean" }, "backend": { "description": "后端服务器配置", "allOf": [ { "$ref": "#/definitions/model.Backend" } ] }, "certificate": { "description": "证书信息", "allOf": [ { "$ref": "#/definitions/model.Certificate" } ] }, "createdAt": { "type": "string" }, "domain": { "description": "域名,如 a.com", "type": "string" }, "enableHTTPS": { "description": "是否启用HTTPS", "type": "boolean" }, "id": { "description": "站点ID", "type": "string" }, "listenPort": { "description": "监听端口,如 9000", "type": "integer" }, "name": { "description": "站点名称", "type": "string" }, "updatedAt": { "type": "string" }, "wafEnabled": { "description": "是否启用WAF", "type": "boolean" }, "wafMode": { "description": "WAF防护模式", "allOf": [ { "$ref": "#/definitions/model.WAFMode" } ] } } }, "model.SuccessResponse": { "description": "成功的API响应标准格式", "type": "object", "properties": { "code": { "type": "integer", "example": 200 }, "data": {}, "message": { "type": "string", "example": "操作成功" }, "requestId": { "type": "string", "example": "550e8400-e29b-41d4-a716-446655440000" }, "success": { "type": "boolean", "example": true }, "timestamp": { "type": "string", "example": "2023-01-01T12:00:00Z" } } }, "model.SuccessResponseNoData": { "description": "成功的API响应标准格式,没有 data", "type": "object", "properties": { "code": { "type": "integer", "example": 200 }, "message": { "type": "string", "example": "操作成功" }, "requestId": { "type": "string", "example": "550e8400-e29b-41d4-a716-446655440000" }, "success": { "type": "boolean", "example": true }, "timestamp": { "type": "string", "example": "2023-01-01T12:00:00Z" } } }, "model.User": { "type": "object", "properties": { "createdAt": { "type": "string" }, "id": { "type": "string" }, "lastLogin": { "type": "string" }, "needReset": { "description": "是否需要重置密码", "type": "boolean" }, "permissions": { "description": "额外权限", "type": "array", "items": { "type": "string" } }, "role": { "description": "用户角色", "type": "string" }, "updatedAt": { "type": "string" }, "username": { "type": "string" } } }, "model.WAFLog": { "description": "Web应用防火墙安全事件完整记录,包含详细的攻击检测和防护信息", "type": "object", "properties": { "accuracy": { "description": "规则匹配准确度(0-10)", "type": "integer", "example": 9 }, "createdAt": { "description": "事件发生时间戳", "type": "string", "example": "2024-03-18T08:12:33Z" }, "domain": { "description": "目标域名", "type": "string", "example": "api.example.com" }, "dstIp": { "description": "目标IP地址", "type": "string", "example": "10.0.0.1" }, "dstPort": { "description": "目标端口", "type": "integer", "example": 443 }, "id": { "description": "日志唯一标识符", "type": "string" }, "logs": { "description": "关联的日志条目", "type": "array", "items": { "$ref": "#/definitions/model.Log" } }, "message": { "description": "事件描述消息", "type": "string", "example": "恶意扫描器检测" }, "payload": { "description": "攻击载荷", "type": "string", "example": "Scanner/1.0" }, "phase": { "description": "请求处理阶段", "type": "integer", "example": 1 }, "request": { "description": "原始HTTP请求", "type": "string", "example": "GET /api/v1/users HTTP/1.1\nHost: api.example.com\nUser-Agent: Scanner/1.0" }, "requestId": { "description": "请求唯一标识", "type": "string", "example": "a1b2c3d4e5f6" }, "response": { "description": "原始HTTP响应", "type": "string", "example": "HTTP/1.1 403 Forbidden\nContent-Type: text/html\nContent-Length: 146" }, "ruleId": { "description": "触发的规则ID", "type": "integer", "example": 10086 }, "secLangRaw": { "description": "安全规则原始定义", "type": "string", "example": "SecRule REQUEST_HEADERS:User-Agent \"@rx (?:scanner)\" \"id:1008,phase:1,severity:'CRITICAL'\"" }, "secMark": { "description": "安全标记", "type": "string", "example": "web_scanner" }, "severity": { "description": "事件严重级别(0-5)", "type": "integer", "example": 2 }, "srcIp": { "description": "来源IP地址", "type": "string", "example": "192.168.1.1" }, "srcPort": { "description": "来源端口", "type": "integer", "example": 52134 }, "uri": { "description": "请求URI路径", "type": "string", "example": "/api/v1/users" } } }, "model.WAFMode": { "type": "string", "enum": [ "protection", "observation" ], "x-enum-comments": { "WAFModeObservation": "观察模式", "WAFModeProtection": "防护模式" }, "x-enum-varnames": [ "WAFModeProtection", "WAFModeObservation" ] } }, "securityDefinitions": { "BearerAuth": { "description": "使用 Bearer {token} 格式进行身份验证", "type": "apiKey", "name": "Authorization", "in": "header" } } }