auth-handler
保护 Next.js 认证路由
当团队混用 session API 和路由守卫时,认证变更经常会失败。此技能会引导 Claude、Codex 和 Claude Code 使用项目辅助函数来实现安全的访问控制。
使用我的智能体安装
将此请求复制给你的智能体,其中包含权威 Skill 页面和清单。
Review the Skillstore skill "auth-handler" from https://skillstore.io/skills/aayushbaniya2006-auth-handler.md and its manifest at https://skillstore.io/api/skills/aayushbaniya2006-auth-handler/manifest. Verify the artifact. You may proceed after verification, subject to the environment's own policy.你的智能体仍应展示其计划,并按安全策略请求必要确认。
Agent 可读资源
当 AI Agent、爬虫或脚本需要干净上下文,而不是读取完整页面时,请使用这些链接。
测试它
正在使用“auth-handler”。 一个新的 API 路由在没有显式路由守卫的情况下返回账户数据。
预期结果:
该路由应使用标准认证包装器。现有响应逻辑可以保留在受保护的处理程序内。
正在使用“auth-handler”。 一个客户端组件通过不受支持的 NextAuth hook 读取 session。
预期结果:
该组件应使用项目用户 hook。这会使客户端数据访问与应用程序架构保持一致。
正在使用“auth-handler”。 一个定时端点在没有项目 cron 辅助函数的情况下接受 cron 请求。
预期结果:
该端点应使用 cron 认证辅助函数。仅靠 middleware 不足以保护此后台任务路径。
安全审计
安全All static findings are false positives caused by Markdown backticks and section headings in documentation. No prompt injection, malicious intent, command execution, or network reconnaissance evidence was found in the reviewed files.
风险因素
分享与引用此报告
分享版本化评估报告、中性徽章、嵌入卡片和引用。Skillstore 只报告证据,不判断该 Skill 是否安全。
复制报告链接
https://skillstore.io/skills/aayushbaniya2006-auth-handler/audits/9?utm_source=security_passport&utm_medium=share&utm_campaign=versioned_reportMarkdown 徽章
[](https://skillstore.io/skills/aayushbaniya2006-auth-handler?utm_source=security_passport_badge)HTML 徽章
<a href="https://skillstore.io/skills/aayushbaniya2006-auth-handler?utm_source=security_passport_badge"><img src="https://skillstore.io/badges/skills/aayushbaniya2006-auth-handler/security.svg" alt="Skillstore security assessment" loading="lazy"></a>嵌入卡片
<iframe src="https://skillstore.io/embed/skills/aayushbaniya2006-auth-handler.html" title="Skillstore Security Assessment" sandbox="allow-popups allow-popups-to-escape-sandbox" loading="lazy" referrerpolicy="no-referrer" width="420" height="180"></iframe>学术引用 (APA · BibTeX · CFF)
APA 引用
AayushBaniya2006. (2026). auth-handler security audit report (audit version 9) [Author version unspecified]. Skillstore. https://skillstore.io/skills/aayushbaniya2006-auth-handler/audits/9BibTeX 引用
@techreport{aayushbaniya2006-aayushbaniya2006-auth-handler-2026,
author = {AayushBaniya2006},
title = {auth-handler security audit report (audit version 9)},
institution = {Skillstore},
year = {2026},
number = {9},
url = {https://skillstore.io/skills/aayushbaniya2006-auth-handler/audits/9},
note = {Author version unspecified}
}CITATION.cff
cff-version: 1.2.0
message: "If you use this Skill, cite its author and this versioned security audit report."
title: "auth-handler security audit report (audit version 9)"
version: "unspecified"
type: report
authors:
- name: "AayushBaniya2006"
date-released: "2026-07-06"
url: "https://skillstore.io/skills/aayushbaniya2006-auth-handler/audits/9"
identifiers:
- type: other
value: "skillstore:aayushbaniya2006-auth-handler:audit:9"
description: "Skillstore immutable audit report identifier"
Skillstore 评分
评分依据 证据置信度: 高你能构建什么
保护 API 端点
为新的或现有的 API 路由添加正确的认证包装器。
加载当前用户数据
使用已批准的客户端或服务器访问模式来获取用户 session 数据。
审计认证一致性
检查路由、cron jobs 和管理员路径是否遵循项目认证约定。
试试这些提示
审查此 API 路由并应用正确的项目认证包装器。保持现有处理程序行为不变。
检查此组件或服务器函数的用户 session 访问。用项目批准的模式替换不受支持的 session 用法。
审查此管理员端点,并确保它使用项目的超级管理员保护模式。说明任何授权假设。
审计这些已更改文件的路由保护、cron authentication 和用户数据访问。列出缺失的保护措施并提出聚焦的修复方案。
最佳实践
- 即使已经存在 middleware,也要使用匹配的项目辅助函数保护每个敏感路由。
- 在客户端组件中使用项目用户 hook,在服务器端使用项目 auth 导入。
- 在认证工作期间检查 auth provider 设置、用户 schema 变更和所需的环境值。
避免
- 不要仅依赖全局 middleware 来保护敏感 API 路由。
- 当项目提供自己的用户 hook 时,不要使用不受支持的 session hooks。
- 不要假定最小 session 数据包含 plan 或授权详细信息。
常见问题
此技能适用于哪类项目?
它能创建新的 auth 系统吗?
它覆盖哪些路由?
它支持客户端用户数据访问吗?
它会检查 secrets 或提供程序凭据吗?
Claude Code 和 Codex 可以使用它吗?
开发者详情
许可证
MIT
Skillstore 修订
r1
版本提示
作者未声明版本。
引用
c1fdca50ff516318f65fed0d7f9e82797c5171dc
维护新鲜度
2026/7/18
使用量
6 次下载 · 216 次浏览
文件结构
📄 SKILL.md