认证管理服务器

企业级认证管理解决方案,提供安全的凭证管理、多协议认证和实时威胁检测与防护。

  • by jamesjohnsdev
  • JavaScript
  • 本地部署
  • 41 星标
  • 更新于
在 GitHub 查看 nahmanmate/better-auth-mcp-server

使用说明

更好的认证mcp服务器mcp服务器

MCP认证管理服务器

企业级身份验证解决方案提供:

  • 🔐 使用AES-256加密进行安全的凭证管理
  • ⚙️ 多协议身份验证(OAuth2、SAML、LDAP)
  • 🛡️ 实时威胁检测和预防

特性

核心工具

  • analyze_project -分析项目结构以获得身份验证设置建议
  • setup_better_auth -使用项目ID和API密钥配置身份验证提供程序
  • analyze_current_auth -检测现有auth.js/next-auth实现
  • generate_migration_plan -创建分步迁移路径

测试与安全

  • test_auth_flows -验证登录/注册/重置/2fa流程
  • test_security -运行与OWASP一致的安全检查
  • analyze_logs -查看身份验证系统日志以查找问题
  • monitor_auth_flows -实时身份验证监控

可用资源

  • better-auth://config -当前更好的身份验证配置设置
  • better-auth://logs -身份验证系统日志

发展

克隆并安装:

git clone https://github.com/better-auth-mcp-server/better-auth-mcp-server.git
cd better-auth-mcp-server
npm install

构建服务器:

npm run build

对于自动重建的开发:

npm run watch

配置

环境变量

# Required
BETTER_AUTH_PROJECT_ID=your-project-id
BETTER_AUTH_API_KEY=your-api-key

# Optional
BETTER_AUTH_ENV=development|staging|production
LOG_LEVEL=info|debug|error

安全最佳实践

  1. API密钥管理

    • 将API密钥存储在环境变量中
    • 定期旋转按键
    • 根据环境使用不同的密钥
  2. 访问控制

    • 实施速率限制
    • 配置IP分配列表
    • 使用最小特权原则
  3. 监控

    • 启用审核日志记录
    • 监控身份验证失败
    • 设置可疑活动警报

安装

通过Smithery安装

通过以下方式自动安装适用于Claude Desktop的Better Auth MCP服务器 史密瑟里:

npx -y @smithery/cli install @nahmanmate/better-auth-mcp-server --client claude

要与Claude Desktop一起使用,请添加服务器配置:

在MacOS上: ~/Library/Application Support/Claude/claude_desktop_config.json 在Windows上: %APPDATA%/Claude/claude_desktop_config.json

{
  "mcpServers": {
    "better-auth-mcp-server": {
      "command": "node",
      "args": ["/path/to/better-auth-mcp-server/build/index.js"],
      "disabled": false,
      "alwaysAllow": []
    }
  }
}

调试

由于MCP服务器通过stdio进行通信,调试可能具有挑战性。我们建议使用 MCP检查员,可作为包脚本使用:

npm run inspector

检查器将提供一个URL,用于访问浏览器中的调试工具。

使用示例

项目设置

// Initialize Better-Auth in your project
await mcp.useTool('setup_better_auth', {
  projectPath: './my-next-app',
  config: {
    projectId: process.env.BETTER_AUTH_PROJECT_ID,
    apiKey: process.env.BETTER_AUTH_API_KEY
  }
});

// Test core authentication flows
await mcp.useTool('test_auth_flows', {
  flows: ['login', 'register', '2fa']
});

从Auth.js/NextAuth迁移

// Analyze current auth implementation
await mcp.useTool('analyze_current_auth', {
  projectPath: './my-next-app'
});

// Generate migration steps
await mcp.useTool('generate_migration_plan', {
  projectPath: './my-next-app',
  currentAuthType: 'next-auth'
});