feat(token): add optional MAC address whitelist validation - #1
Merged
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Important
📝 变更描述 / Description
为 API Token 增加可选的 MAC 地址白名单限制:
mac_check_enabled、allow_macs配置。TokenAuth在 IP 白名单之后校验客户端提供的X-Client-Mac;缺失、格式错误或不在白名单时拒绝请求。allow_macs使用无默认值的 nullableTEXT,避免 GORM 在 MySQL 5.7/8.0 上生成不兼容的TEXT DEFAULT ''DDL;历史记录仍按关闭状态和空白名单处理。安全边界:服务端无法从公网请求获得客户端真实网卡 MAC。本功能信任
X-Client-Mac,适用于由可信客户端或网关注入该请求头的环境,不应单独作为不可伪造的设备身份凭据。🚀 变更类型 / Type of change
🔗 关联任务 / Related Issue
✅ 提交前检查项 / Checklist
Bug fix,我已提交或关联对应 Issue,且不会将设计取舍、预期不一致或理解偏差直接归类为 bug。📸 运行证明 / Proof of Work
go test -count=1 ./...通过。tokens表迁移测试通过,新增字段为 nullable 且无TEXT默认值。linux/amd64镜像在 MySQL 5.7.44 和 8.0 上首次启动、停止及二次启动均通过。