All files / src/lib/api-docs/endpoints/admin security.ts

100% Statements 100/100
100% Branches 0/0
100% Functions 0/0
100% Lines 100/100

Press n or j to go to the next uncovered block, b, p or k for the previous block.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 1011x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x  
/**
 * Admin Security Endpoints
 * Security monitoring, blocked IPs, and security events
 */
 
import type { ApiEndpoint } from '@/types/api-docs';
 
export const adminSecurityEndpoints: ApiEndpoint[] = [
  {
    id: 'admin-security-overview',
    method: 'GET',
    path: '/api/admin/security/overview',
    summary: 'Get security overview',
    description: 'Returns security dashboard with threat summary',
    category: 'admin-security',
    requiresAuth: true,
    adminOnly: true,
    responses: [
      { status: 200, description: 'Security overview', example: { success: true, data: { threats: 0, blockedRequests: 150, suspiciousActivity: 3 } } },
    ],
  },
  {
    id: 'admin-security-events',
    method: 'GET',
    path: '/api/admin/security/events',
    summary: 'List security events',
    description: 'Returns security events and audit log',
    category: 'admin-security',
    requiresAuth: true,
    adminOnly: true,
    parameters: [
      { name: 'type', type: 'string', required: false, location: 'query', description: 'Event type filter', enum: ['login', 'failed_login', 'password_change', 'suspicious'] },
      { name: 'severity', type: 'string', required: false, location: 'query', description: 'Severity filter', enum: ['low', 'medium', 'high', 'critical'] },
      { name: 'startDate', type: 'string', required: false, location: 'query', description: 'Start date' },
      { name: 'endDate', type: 'string', required: false, location: 'query', description: 'End date' },
      { name: 'limit', type: 'number', required: false, location: 'query', description: 'Number of events' },
    ],
    responses: [
      { status: 200, description: 'List of security events' },
    ],
  },
  {
    id: 'admin-security-blocked-ips-list',
    method: 'GET',
    path: '/api/admin/security/blocked-ips',
    summary: 'List blocked IPs',
    description: 'Returns list of blocked IP addresses',
    category: 'admin-security',
    requiresAuth: true,
    adminOnly: true,
    parameters: [
      { name: 'active', type: 'boolean', required: false, location: 'query', description: 'Filter active blocks only' },
    ],
    responses: [
      { status: 200, description: 'List of blocked IPs' },
    ],
  },
  {
    id: 'admin-security-blocked-ips-create',
    method: 'POST',
    path: '/api/admin/security/blocked-ips',
    summary: 'Block IP address',
    description: 'Adds an IP address to the block list',
    category: 'admin-security',
    requiresAuth: true,
    adminOnly: true,
    requestBody: {
      contentType: 'application/json',
      fields: [
        { name: 'ip', type: 'string', required: true, description: 'IP address to block' },
        { name: 'reason', type: 'string', required: true, description: 'Reason for blocking' },
        { name: 'expiresAt', type: 'string', required: false, description: 'Expiration date (ISO 8601)' },
      ],
    },
    responses: [
      { status: 201, description: 'IP blocked' },
      { status: 400, description: 'Invalid IP address' },
    ],
  },
  {
    id: 'admin-security-blocked-ips-delete',
    method: 'DELETE',
    path: '/api/admin/security/blocked-ips',
    summary: 'Unblock IP address',
    description: 'Removes an IP address from the block list',
    category: 'admin-security',
    requiresAuth: true,
    adminOnly: true,
    requestBody: {
      contentType: 'application/json',
      fields: [
        { name: 'ip', type: 'string', required: true, description: 'IP address to unblock' },
      ],
    },
    responses: [
      { status: 200, description: 'IP unblocked' },
      { status: 404, description: 'IP not found in block list' },
    ],
  },
];