/java-skills:sa-token-api-securityfrom java-skills
Implements API security with Sa-Token: parameter signing (anti-tamper/anti-replay), API Key management with scope control, and temporary tokens for short-lived links. Supports multi-app signing, multiple digest algorithms, and database persistence.
Ships in java-skills. Installing the plugin adds it to Claude Code.
What the skill costs in Claude's context, stage by stage
Name and description: Claude knows it exists.
SKILL.md joins the conversation and stays.
Read when SKILL.md points to them.
基于 sa-token-doc/plugin/api-sign.md(591行)+ api-key.md(283行)+ temp-token.md(120行)。
| 场景 | 推荐方案 | 原因 |
|---|---|---|
| 系统A调用系统B的API,防止参数篡改 | API签名 | 轻量级,不需要额外存储 |
| 给第三方开发者提供API访问凭证 | API Key | 可吊销、可控制Scope权限 |
| 生成一个短期的邀请链接 | 临时Token | 无状态、指定过期时间 |
| 需要同时防篡改+身份认证 | API签名+API Key | 两者可同时使用 |
Step 1. 引入 sa-token-sign 依赖
Step 2. 配置 secret-key 和摘要算法
Step 3. 请求端用 SaSignUtil.addSignParamsAndJoin() 构建签名的参数
Step 4. 接收端用 SaSignUtil.checkRequest() 或 @SaCheckSign 校验
Step 1. 引入 sa-token-apikey 依赖
Step 2. 调用 SaApiKeyUtil.createApiKeyModel() 创建API Key
Step 3. 客户端通过请求参数或header提交apikey
Step 4. 服务端用 @SaCheckApiKey 注解校验
Step 1. 调用 SaTempUtil.createToken() 创建临时Token
Step 2. 将Token传递给使用者(URL/消息等)
Step 3. 使用者调用 SaTempUtil.parseToken() 解析
| 主题 | 文件 | 来源 |
|---|---|---|
| API参数签名(防篡改防重放) | references/api-sign.md | GitHub |
| API Key(部分授权管理) | references/api-key.md | GitHub |
| 临时Token(短效链接) | references/temp-token.md | GitHub |
Q: API签名和Same-Token有什么区别? A: API签名用于参数防篡改防重放(数据完整性),Same-Token用于服务间身份认证(身份验证)。可同时使用。
Q: API Key和会话Token有什么区别? A: API Key是静态的、可吊销的、Scope受限的。会话Token是动态的、登录后自动获取的、拥有账号完整权限。场景不同不能互相替代。
Q: 临时Token的有效期怎么设?
A: 创建时通过第二个参数指定(秒),如 SaTempUtil.createToken("10014", 200) 表示200秒。
Q: API Key怎么持久化到数据库?
A: 实现 SaApiKeyDataLoader 接口,框架会先查缓存,缓存不存在时调用DataLoader从数据库加载。
Q: 临时Token能不能JWT模式?
A: 可以。引入 sa-token-temp-jwt 依赖并配置jwt-secret-key,上层API不变,底层使用JWT内核。
本技能不收集、存储或传输任何用户数据。所有代码示例仅供本地开发参考。
agents/openai.yaml (opens in a new tab)evaluation-report.html (opens in a new tab)examples/api-security-demo.md (opens in a new tab)examples/temp-token-scenarios.md (opens in a new tab)references/api-key.md (opens in a new tab)references/api-sign.md (opens in a new tab)references/temp-token.md (opens in a new tab)What SKILL.md sets; muted values are Claude Code's defaults
Three short reads, in order
sa-token, api-security, api-signature, api-key, temporary-token, anti-replay
Generated from the plugin's indexed repository (full-stack-skills/java-skills) — no native marketplace selected
npx claudepluginhub p/full-statck-skills-java-skillsOther plugins' skills for the same job
39 skills in this plugin
/caffeine-patternsCaffeine JVM 本地缓存技能。覆盖本地缓存 vs 远程缓存(Redis)选择决策树、expireAfterWrite vs expireAfterAccess vs refreshAfterWrite 三种过期策略对比与组合规则(refresh < expire)、CacheLoader加载与reload异步刷新模式、Spring Cache @Cacheable集成、maximumSize驱逐策略、recordStats缓存统计。 纠正 LLM:用 ConcurrentHashMap+手动过期、所有缓存走Redis、refreshAfterWrite > expireAfterWrite导致永远不刷新、CacheLoader返回null导致缓存穿透。/commons-patternsApache Commons 最佳实践模式。从官方文档提炼,覆盖 Commons Lang3(StringUtils千面判空/isEmpty vs isBlank/Validate抛NullPointerException迁移)、Commons IO(IOUtils.toString大文件陷阱/FileUtils.lineIterator逐行读模式/FilenameUtils.normalize路径规范化)、Commons Collections4(CollectionUtils.union/intersection/subtract集合运算)。 纠正 LLM 误用:混淆 StringUtils.isBlank vs isEmpty、IOUtils.toString 读大文件OOM、不知道 LineIterator 逐行读模式、用 lang 而非 lang3 包名。/