(req, res, next)
| 41 | error: { type: 'authentication_error', message: 'Invalid API key' } |
| 42 | }) |
| 43 | } |
| 44 | return res.status(401).json({ error: 'Unauthorized' }) |
| 45 | } |
| 46 | |
| 47 | // 将权限信息附加到请求对象 |
| 48 | req.isAdmin = isAdmin |
| 49 | req.apiKey = apiKey |
| 50 | next() |
| 51 | } |
| 52 | |
| 53 | /** |
| 54 | * 管理员权限验证中间件 - 只允许管理员API Key |
| 55 | */ |
| 56 | const adminKeyVerify = (req, res, next) => { |
| 57 | const apiKey = req.headers['authorization'] || req.headers['Authorization'] || req.headers['x-api-key'] |
nothing calls this directly
no test coverage detected