Enhanced ChatGPT Clone: Features Agents, MCP, Skills, DeepSeek, Anthropic, AWS, OpenAI, Responses API, Azure, Groq, o1, GPT-5, Mistral, OpenRouter, Vertex AI, Gemini, Artifacts, AI model switching, message search, Code Interpreter, langchain, DALL-E-3, OpenAPI Actions, Functions, Secure Multi-User Auth, Presets, open-source for self-hosting. Active
TypeScript aianthropicartifactsawsazurechatgptchatgpt-cloneclaudeclonedeepseekgeminigooglegpt-5librechatmcpo1openairesponses-apivisionwebui
const express = require('express');
const { createAdminAuditLogHandlers, isAuditFailClosed } = require('@librechat/api');
const { SystemCapabilities } = require('@librechat/data-schemas');
const { requireCapability } = require('~/server/middleware/roles/capabilities');
const { requireJwtAuth } = require('~/server/middleware');
const db = require('~/models');
const router = express.Router();
const requireAdminAccess = requireCapability(SystemCapabilities.ACCESS_ADMIN);
const requireAuditLogRead = requireCapability(SystemCapabilities.READ_AUDIT_LOG);
const handlers = createAdminAuditLogHandlers({
listAuditLogPage: db.listAuditLogPage,
findAuditLogEntry: db.findAuditLogEntry,
streamAuditLogEntries: db.streamAuditLogEntries,
verifyAuditChain: db.verifyAuditChain,
recordAuditEntry: db.recordAuditEntry,
auditFailClosed: isAuditFailClosed(),
});
/**
* `ACCESS_ADMIN` gates entry to the admin surface; `READ_AUDIT_LOG` then gates
* this specific feature within that surface. The two capabilities are
* independent in `CapabilityImplications`, so a role delegated only
* `READ_AUDIT_LOG` without `ACCESS_ADMIN` would otherwise bypass the admin
* boundary on this router — every other admin router enforces the same pair.
*/
router.use(requireJwtAuth, requireAdminAccess, requireAuditLogRead);
router.get('/', handlers.listAuditLog);
/** Literal sub-paths MUST precede `/:id` so they aren't matched as `{ id }`. */
router.get('/export.csv', handlers.exportAuditLogCsv);
router.get('/verify', handlers.verifyAuditLog);
router.get('/:id', handlers.getAuditLogEntry);
module.exports = router;