1
0

openapi.yaml 54 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061
  1. openapi: '3.0.3'
  2. info:
  3. title: IRDB — IP Reputation Database
  4. version: '1.0.0'
  5. description: |
  6. Self-hosted IP reputation service: ingest abuse reports, distribute tailored block lists.
  7. ## Versioning
  8. Single major version `v1`. Changes within `v1` are additive only — new endpoints, new optional fields, new optional query params. Breaking changes ship as `v2`.
  9. ## Endpoint groups
  10. - **Public**: machine clients (reporters, consumers).
  11. - **Admin**: UI BFF + admin-kind tokens. RBAC enforced server-side.
  12. - **Auth**: UI BFF only — bridges browser auth to user records. Marked `x-internal: true`.
  13. - **Internal jobs**: not in this spec. Scheduler-only, network-restricted.
  14. ## Authentication
  15. Bearer token in the `Authorization` header. Four token kinds: `reporter`, `consumer`, `admin`, `service`. See `doc/auth-flows.md`.
  16. ## Errors
  17. Uniform envelope: `{"error":"<code>","details":{...}}`. Validation errors include `details`. Authentication failures return `401` `unauthorized`. Authorization failures return `403`.
  18. ## Rate limiting
  19. Public endpoints: 60 req/s/token (configurable). On exhaustion: `429` with `Retry-After: 1`.
  20. license:
  21. name: TBD
  22. servers:
  23. - url: http://localhost:8081
  24. description: Default compose deployment
  25. - url: https://reputation-api.example.com
  26. description: Production (replace hostname)
  27. tags:
  28. - name: Public
  29. description: 'Machine clients: reporters and blocklist consumers.'
  30. - name: Admin
  31. description: UI BFF + admin-kind tokens.
  32. - name: Auth
  33. description: UI BFF only. Service token required, no impersonation.
  34. security:
  35. - BearerAuth: []
  36. paths:
  37. '/api/v1/report':
  38. post:
  39. tags:
  40. - Public
  41. summary: Submit an abuse report
  42. description: |
  43. Token kind: `reporter`. Rate limit: 60 req/s per token (configurable).
  44. Returns `202 Accepted` on success.
  45. security:
  46. - BearerAuth: []
  47. requestBody:
  48. required: true
  49. content:
  50. 'application/json':
  51. schema:
  52. '$ref': '#/components/schemas/ReportRequest'
  53. responses:
  54. '202':
  55. description: Report accepted
  56. content:
  57. 'application/json':
  58. schema:
  59. '$ref': '#/components/schemas/ReportResponse'
  60. '400':
  61. description: Validation failed
  62. content:
  63. 'application/json':
  64. schema:
  65. '$ref': '#/components/schemas/Error'
  66. '401':
  67. description: Bad / wrong-kind token
  68. content:
  69. 'application/json':
  70. schema:
  71. '$ref': '#/components/schemas/Error'
  72. '429':
  73. description: Rate limited
  74. headers:
  75. Retry-After:
  76. schema:
  77. type: integer
  78. description: Seconds to wait before retrying.
  79. content:
  80. 'application/json':
  81. schema:
  82. '$ref': '#/components/schemas/Error'
  83. '/api/v1/blocklist':
  84. get:
  85. tags:
  86. - Public
  87. summary: Pull a tailored blocklist
  88. description: |
  89. Token kind: `consumer`. The consumer's bound policy decides which IPs/CIDRs land in the output.
  90. Cached internally for 30 s per consumer. Honour `If-None-Match` to skip retransfer.
  91. `?format=json` returns structured rows; default is `text/plain`, one entry per line.
  92. security:
  93. - BearerAuth: []
  94. parameters:
  95. - name: format
  96. in: query
  97. schema:
  98. type: string
  99. enum:
  100. - text
  101. - json
  102. default: text
  103. - name: If-None-Match
  104. in: header
  105. schema:
  106. type: string
  107. responses:
  108. '200':
  109. description: Current blocklist
  110. headers:
  111. ETag:
  112. schema:
  113. type: string
  114. X-Blocklist-Generated-At:
  115. schema:
  116. type: string
  117. format: date-time
  118. X-Blocklist-Entries:
  119. schema:
  120. type: integer
  121. X-Blocklist-Policy:
  122. schema:
  123. type: string
  124. content:
  125. 'text/plain':
  126. schema:
  127. type: string
  128. example: |
  129. 203.0.113.42
  130. 198.51.100.0/24
  131. 'application/json':
  132. schema:
  133. '$ref': '#/components/schemas/BlocklistJson'
  134. '304':
  135. description: Not modified — body matches `If-None-Match`
  136. '401':
  137. description: Bad / wrong-kind token
  138. '/api/v1/admin/me':
  139. get:
  140. tags:
  141. - Admin
  142. summary: Current acting identity
  143. security:
  144. - BearerAuth: []
  145. parameters:
  146. - '$ref': '#/components/parameters/ActingUserId'
  147. responses:
  148. '200':
  149. description: Identity info
  150. content:
  151. 'application/json':
  152. schema:
  153. '$ref': '#/components/schemas/User'
  154. '/api/v1/admin/ips':
  155. get:
  156. tags:
  157. - Admin
  158. summary: Search IPs
  159. security:
  160. - BearerAuth: []
  161. parameters:
  162. - '$ref': '#/components/parameters/ActingUserId'
  163. - name: q
  164. in: query
  165. schema:
  166. type: string
  167. - name: category
  168. in: query
  169. schema:
  170. type: string
  171. - name: min_score
  172. in: query
  173. schema:
  174. type: number
  175. format: float
  176. - name: max_score
  177. in: query
  178. schema:
  179. type: number
  180. format: float
  181. - name: country
  182. in: query
  183. schema:
  184. type: string
  185. - name: asn
  186. in: query
  187. schema:
  188. type: integer
  189. - name: status
  190. in: query
  191. schema:
  192. type: string
  193. enum:
  194. - scored
  195. - manual
  196. - allowlisted
  197. - clean
  198. - '$ref': '#/components/parameters/Page'
  199. - '$ref': '#/components/parameters/PageSize'
  200. responses:
  201. '200':
  202. description: Page of IPs
  203. content:
  204. 'application/json':
  205. schema:
  206. type: object
  207. properties:
  208. page:
  209. type: integer
  210. minimum: 1
  211. example: 1
  212. page_size:
  213. type: integer
  214. minimum: 1
  215. maximum: 200
  216. example: 50
  217. total:
  218. type: integer
  219. minimum: 0
  220. example: 1284
  221. items:
  222. type: array
  223. items:
  224. type: object
  225. '/api/v1/admin/ips/countries':
  226. get:
  227. tags:
  228. - Admin
  229. summary: Country code dropdown source
  230. security:
  231. - BearerAuth: []
  232. parameters:
  233. - '$ref': '#/components/parameters/ActingUserId'
  234. responses:
  235. '200':
  236. description: '`[{code, count}]`'
  237. content:
  238. 'application/json':
  239. schema:
  240. type: object
  241. properties:
  242. items:
  243. type: array
  244. items:
  245. type: object
  246. properties:
  247. code:
  248. type: string
  249. count:
  250. type: integer
  251. '/api/v1/admin/ips/{ip}':
  252. get:
  253. tags:
  254. - Admin
  255. summary: IP detail
  256. security:
  257. - BearerAuth: []
  258. parameters:
  259. - '$ref': '#/components/parameters/ActingUserId'
  260. - name: ip
  261. in: path
  262. required: true
  263. schema:
  264. type: string
  265. responses:
  266. '200':
  267. description: IP detail
  268. content:
  269. 'application/json':
  270. schema:
  271. '$ref': '#/components/schemas/IpDetail'
  272. '404':
  273. description: Invalid IP / not found
  274. '/api/v1/admin/stats/dashboard':
  275. get:
  276. tags:
  277. - Admin
  278. summary: Dashboard stats (30s cached)
  279. security:
  280. - BearerAuth: []
  281. parameters:
  282. - '$ref': '#/components/parameters/ActingUserId'
  283. responses:
  284. '200':
  285. description: Dashboard payload
  286. content:
  287. 'application/json':
  288. schema:
  289. type: object
  290. '/api/v1/admin/manual-blocks':
  291. get:
  292. tags:
  293. - Admin
  294. summary: List manual blocks
  295. security:
  296. - BearerAuth: []
  297. parameters:
  298. - '$ref': '#/components/parameters/ActingUserId'
  299. responses:
  300. '200':
  301. description: list
  302. post:
  303. tags:
  304. - Admin
  305. summary: Create manual block
  306. description: Operator+ role required. `kind=ip` requires `ip`; `kind=subnet` requires `cidr`.
  307. security:
  308. - BearerAuth: []
  309. parameters:
  310. - '$ref': '#/components/parameters/ActingUserId'
  311. requestBody:
  312. required: true
  313. content:
  314. 'application/json':
  315. schema:
  316. type: object
  317. properties:
  318. kind:
  319. type: string
  320. enum:
  321. - ip
  322. - subnet
  323. ip:
  324. type: string
  325. cidr:
  326. type: string
  327. reason:
  328. type: string
  329. expires_at:
  330. type: string
  331. format: date-time
  332. responses:
  333. '201':
  334. description: Created
  335. content:
  336. 'application/json':
  337. schema:
  338. '$ref': '#/components/schemas/ManualBlock'
  339. '/api/v1/admin/manual-blocks/{id}':
  340. get:
  341. tags:
  342. - Admin
  343. summary: Show manual block
  344. security:
  345. - BearerAuth: []
  346. parameters:
  347. - '$ref': '#/components/parameters/ActingUserId'
  348. - name: id
  349. in: path
  350. required: true
  351. schema:
  352. type: integer
  353. responses:
  354. '200':
  355. description: manual block
  356. content:
  357. 'application/json':
  358. schema:
  359. '$ref': '#/components/schemas/ManualBlock'
  360. delete:
  361. tags:
  362. - Admin
  363. summary: Delete manual block
  364. security:
  365. - BearerAuth: []
  366. parameters:
  367. - '$ref': '#/components/parameters/ActingUserId'
  368. - name: id
  369. in: path
  370. required: true
  371. schema:
  372. type: integer
  373. responses:
  374. '204':
  375. description: Deleted
  376. '/api/v1/admin/allowlist':
  377. get:
  378. tags:
  379. - Admin
  380. summary: List allowlist
  381. security:
  382. - BearerAuth: []
  383. parameters:
  384. - '$ref': '#/components/parameters/ActingUserId'
  385. responses:
  386. '200':
  387. description: list
  388. post:
  389. tags:
  390. - Admin
  391. summary: Create allowlist entry
  392. security:
  393. - BearerAuth: []
  394. parameters:
  395. - '$ref': '#/components/parameters/ActingUserId'
  396. requestBody:
  397. required: true
  398. content:
  399. 'application/json':
  400. schema:
  401. type: object
  402. properties:
  403. kind:
  404. type: string
  405. enum:
  406. - ip
  407. - subnet
  408. ip:
  409. type: string
  410. cidr:
  411. type: string
  412. reason:
  413. type: string
  414. responses:
  415. '201':
  416. description: Created
  417. content:
  418. 'application/json':
  419. schema:
  420. '$ref': '#/components/schemas/AllowlistEntry'
  421. '/api/v1/admin/allowlist/{id}':
  422. get:
  423. tags:
  424. - Admin
  425. summary: Show allowlist entry
  426. security:
  427. - BearerAuth: []
  428. parameters:
  429. - '$ref': '#/components/parameters/ActingUserId'
  430. - name: id
  431. in: path
  432. required: true
  433. schema:
  434. type: integer
  435. responses:
  436. '200':
  437. description: allowlist entry
  438. content:
  439. 'application/json':
  440. schema:
  441. '$ref': '#/components/schemas/AllowlistEntry'
  442. delete:
  443. tags:
  444. - Admin
  445. summary: Delete allowlist entry
  446. security:
  447. - BearerAuth: []
  448. parameters:
  449. - '$ref': '#/components/parameters/ActingUserId'
  450. - name: id
  451. in: path
  452. required: true
  453. schema:
  454. type: integer
  455. responses:
  456. '204':
  457. description: Deleted
  458. '/api/v1/admin/reporters':
  459. get:
  460. tags:
  461. - Admin
  462. summary: List reporters
  463. security:
  464. - BearerAuth: []
  465. parameters:
  466. - '$ref': '#/components/parameters/ActingUserId'
  467. responses:
  468. '200':
  469. description: list
  470. post:
  471. tags:
  472. - Admin
  473. summary: Create reporter
  474. security:
  475. - BearerAuth: []
  476. parameters:
  477. - '$ref': '#/components/parameters/ActingUserId'
  478. requestBody:
  479. required: true
  480. content:
  481. 'application/json':
  482. schema:
  483. '$ref': '#/components/schemas/Reporter'
  484. responses:
  485. '201':
  486. description: Created
  487. content:
  488. 'application/json':
  489. schema:
  490. '$ref': '#/components/schemas/Reporter'
  491. '/api/v1/admin/reporters/{id}':
  492. get:
  493. tags:
  494. - Admin
  495. summary: Show reporter
  496. security:
  497. - BearerAuth: []
  498. parameters:
  499. - '$ref': '#/components/parameters/ActingUserId'
  500. - name: id
  501. in: path
  502. required: true
  503. schema:
  504. type: integer
  505. responses:
  506. '200':
  507. description: reporter
  508. content:
  509. 'application/json':
  510. schema:
  511. '$ref': '#/components/schemas/Reporter'
  512. patch:
  513. tags:
  514. - Admin
  515. summary: Update reporter
  516. security:
  517. - BearerAuth: []
  518. parameters:
  519. - '$ref': '#/components/parameters/ActingUserId'
  520. - name: id
  521. in: path
  522. required: true
  523. schema:
  524. type: integer
  525. requestBody:
  526. content:
  527. 'application/json':
  528. schema:
  529. '$ref': '#/components/schemas/Reporter'
  530. responses:
  531. '200':
  532. description: Updated
  533. content:
  534. 'application/json':
  535. schema:
  536. '$ref': '#/components/schemas/Reporter'
  537. delete:
  538. tags:
  539. - Admin
  540. summary: Soft-delete reporter
  541. security:
  542. - BearerAuth: []
  543. parameters:
  544. - '$ref': '#/components/parameters/ActingUserId'
  545. - name: id
  546. in: path
  547. required: true
  548. schema:
  549. type: integer
  550. responses:
  551. '204':
  552. description: Deleted
  553. '409':
  554. description: Has reports — flagged inactive instead.
  555. '/api/v1/admin/consumers':
  556. get:
  557. tags:
  558. - Admin
  559. summary: List consumers
  560. security:
  561. - BearerAuth: []
  562. parameters:
  563. - '$ref': '#/components/parameters/ActingUserId'
  564. responses:
  565. '200':
  566. description: list
  567. post:
  568. tags:
  569. - Admin
  570. summary: Create consumer
  571. security:
  572. - BearerAuth: []
  573. parameters:
  574. - '$ref': '#/components/parameters/ActingUserId'
  575. requestBody:
  576. required: true
  577. content:
  578. 'application/json':
  579. schema:
  580. '$ref': '#/components/schemas/Consumer'
  581. responses:
  582. '201':
  583. description: Created
  584. content:
  585. 'application/json':
  586. schema:
  587. '$ref': '#/components/schemas/Consumer'
  588. '/api/v1/admin/consumers/{id}':
  589. get:
  590. tags:
  591. - Admin
  592. summary: Show consumer
  593. security:
  594. - BearerAuth: []
  595. parameters:
  596. - '$ref': '#/components/parameters/ActingUserId'
  597. - name: id
  598. in: path
  599. required: true
  600. schema:
  601. type: integer
  602. responses:
  603. '200':
  604. description: consumer
  605. content:
  606. 'application/json':
  607. schema:
  608. '$ref': '#/components/schemas/Consumer'
  609. patch:
  610. tags:
  611. - Admin
  612. summary: Update consumer
  613. security:
  614. - BearerAuth: []
  615. parameters:
  616. - '$ref': '#/components/parameters/ActingUserId'
  617. - name: id
  618. in: path
  619. required: true
  620. schema:
  621. type: integer
  622. requestBody:
  623. content:
  624. 'application/json':
  625. schema:
  626. '$ref': '#/components/schemas/Consumer'
  627. responses:
  628. '200':
  629. description: Updated
  630. delete:
  631. tags:
  632. - Admin
  633. summary: Soft-delete consumer
  634. security:
  635. - BearerAuth: []
  636. parameters:
  637. - '$ref': '#/components/parameters/ActingUserId'
  638. - name: id
  639. in: path
  640. required: true
  641. schema:
  642. type: integer
  643. responses:
  644. '204':
  645. description: Deleted
  646. '/api/v1/admin/tokens':
  647. get:
  648. tags:
  649. - Admin
  650. summary: List tokens
  651. description: Service tokens are filtered out unconditionally.
  652. security:
  653. - BearerAuth: []
  654. parameters:
  655. - '$ref': '#/components/parameters/ActingUserId'
  656. responses:
  657. '200':
  658. description: list
  659. post:
  660. tags:
  661. - Admin
  662. summary: Create token
  663. description: Returns the raw token ONCE in `raw_token`. Service tokens are not creatable here.
  664. security:
  665. - BearerAuth: []
  666. parameters:
  667. - '$ref': '#/components/parameters/ActingUserId'
  668. requestBody:
  669. required: true
  670. content:
  671. 'application/json':
  672. schema:
  673. type: object
  674. properties:
  675. kind:
  676. type: string
  677. enum:
  678. - reporter
  679. - consumer
  680. - admin
  681. reporter_id:
  682. type: integer
  683. consumer_id:
  684. type: integer
  685. role:
  686. type: string
  687. enum:
  688. - viewer
  689. - operator
  690. - admin
  691. expires_at:
  692. type: string
  693. format: date-time
  694. responses:
  695. '201':
  696. description: Created
  697. content:
  698. 'application/json':
  699. schema:
  700. '$ref': '#/components/schemas/TokenCreated'
  701. '/api/v1/admin/tokens/{id}':
  702. delete:
  703. tags:
  704. - Admin
  705. summary: Revoke token
  706. security:
  707. - BearerAuth: []
  708. parameters:
  709. - '$ref': '#/components/parameters/ActingUserId'
  710. - name: id
  711. in: path
  712. required: true
  713. schema:
  714. type: integer
  715. responses:
  716. '204':
  717. description: Revoked
  718. '/api/v1/admin/tokens/{id}/purge':
  719. delete:
  720. tags:
  721. - Admin
  722. summary: Permanently delete a revoked token
  723. description: |
  724. Hard-deletes the row. Requires the token to be already revoked
  725. (`revoked_at` set); active tokens return 409 to keep "revoke first,
  726. then prune" the only path that removes data. Service tokens cannot
  727. be deleted.
  728. security:
  729. - BearerAuth: []
  730. parameters:
  731. - '$ref': '#/components/parameters/ActingUserId'
  732. - name: id
  733. in: path
  734. required: true
  735. schema:
  736. type: integer
  737. responses:
  738. '204':
  739. description: Deleted
  740. '403':
  741. description: Service token; not deletable via API
  742. '404':
  743. description: Not found
  744. '409':
  745. description: Token still active; revoke it first
  746. '/api/v1/admin/categories':
  747. get:
  748. tags:
  749. - Admin
  750. summary: List categories
  751. security:
  752. - BearerAuth: []
  753. parameters:
  754. - '$ref': '#/components/parameters/ActingUserId'
  755. responses:
  756. '200':
  757. description: list
  758. post:
  759. tags:
  760. - Admin
  761. summary: Create category
  762. security:
  763. - BearerAuth: []
  764. parameters:
  765. - '$ref': '#/components/parameters/ActingUserId'
  766. requestBody:
  767. required: true
  768. content:
  769. 'application/json':
  770. schema:
  771. '$ref': '#/components/schemas/Category'
  772. responses:
  773. '201':
  774. description: Created
  775. content:
  776. 'application/json':
  777. schema:
  778. '$ref': '#/components/schemas/Category'
  779. '/api/v1/admin/categories/{id}':
  780. get:
  781. tags:
  782. - Admin
  783. summary: Show category
  784. security:
  785. - BearerAuth: []
  786. parameters:
  787. - '$ref': '#/components/parameters/ActingUserId'
  788. - name: id
  789. in: path
  790. required: true
  791. schema:
  792. type: integer
  793. responses:
  794. '200':
  795. description: category
  796. content:
  797. 'application/json':
  798. schema:
  799. '$ref': '#/components/schemas/Category'
  800. patch:
  801. tags:
  802. - Admin
  803. summary: Update category
  804. security:
  805. - BearerAuth: []
  806. parameters:
  807. - '$ref': '#/components/parameters/ActingUserId'
  808. - name: id
  809. in: path
  810. required: true
  811. schema:
  812. type: integer
  813. requestBody:
  814. content:
  815. 'application/json':
  816. schema:
  817. '$ref': '#/components/schemas/Category'
  818. responses:
  819. '200':
  820. description: Updated
  821. delete:
  822. tags:
  823. - Admin
  824. summary: Hard-delete category (refused if in use)
  825. security:
  826. - BearerAuth: []
  827. parameters:
  828. - '$ref': '#/components/parameters/ActingUserId'
  829. - name: id
  830. in: path
  831. required: true
  832. schema:
  833. type: integer
  834. responses:
  835. '204':
  836. description: Deleted
  837. '409':
  838. description: Category in use; soft-delete via PATCH `is_active=false`.
  839. '/api/v1/admin/policies':
  840. get:
  841. tags:
  842. - Admin
  843. summary: List policies
  844. security:
  845. - BearerAuth: []
  846. parameters:
  847. - '$ref': '#/components/parameters/ActingUserId'
  848. responses:
  849. '200':
  850. description: list
  851. post:
  852. tags:
  853. - Admin
  854. summary: Create policy
  855. security:
  856. - BearerAuth: []
  857. parameters:
  858. - '$ref': '#/components/parameters/ActingUserId'
  859. requestBody:
  860. required: true
  861. content:
  862. 'application/json':
  863. schema:
  864. '$ref': '#/components/schemas/Policy'
  865. responses:
  866. '201':
  867. description: Created
  868. content:
  869. 'application/json':
  870. schema:
  871. '$ref': '#/components/schemas/Policy'
  872. '/api/v1/admin/policies/{id}':
  873. get:
  874. tags:
  875. - Admin
  876. summary: Show policy
  877. security:
  878. - BearerAuth: []
  879. parameters:
  880. - '$ref': '#/components/parameters/ActingUserId'
  881. - name: id
  882. in: path
  883. required: true
  884. schema:
  885. type: integer
  886. responses:
  887. '200':
  888. description: policy
  889. content:
  890. 'application/json':
  891. schema:
  892. '$ref': '#/components/schemas/Policy'
  893. patch:
  894. tags:
  895. - Admin
  896. summary: Update policy (replaces thresholds wholesale when present)
  897. security:
  898. - BearerAuth: []
  899. parameters:
  900. - '$ref': '#/components/parameters/ActingUserId'
  901. - name: id
  902. in: path
  903. required: true
  904. schema:
  905. type: integer
  906. requestBody:
  907. content:
  908. 'application/json':
  909. schema:
  910. '$ref': '#/components/schemas/Policy'
  911. responses:
  912. '200':
  913. description: Updated
  914. delete:
  915. tags:
  916. - Admin
  917. summary: Delete policy (refused if used by consumers)
  918. security:
  919. - BearerAuth: []
  920. parameters:
  921. - '$ref': '#/components/parameters/ActingUserId'
  922. - name: id
  923. in: path
  924. required: true
  925. schema:
  926. type: integer
  927. responses:
  928. '204':
  929. description: Deleted
  930. '409':
  931. description: Policy in use
  932. '/api/v1/admin/policies/{id}/preview':
  933. get:
  934. tags:
  935. - Admin
  936. summary: Preview policy (count + sample)
  937. security:
  938. - BearerAuth: []
  939. parameters:
  940. - '$ref': '#/components/parameters/ActingUserId'
  941. - name: id
  942. in: path
  943. required: true
  944. schema:
  945. type: integer
  946. responses:
  947. '200':
  948. description: Preview
  949. '/api/v1/admin/users':
  950. get:
  951. tags:
  952. - Admin
  953. summary: List users (Admin)
  954. description: |
  955. Roster of every IRDB user (OIDC + the single local-admin row).
  956. Used by the admin **users** page to disable / re-enable accounts
  957. (SEC_REVIEW F11).
  958. security:
  959. - BearerAuth: []
  960. parameters:
  961. - '$ref': '#/components/parameters/ActingUserId'
  962. - '$ref': '#/components/parameters/Page'
  963. - '$ref': '#/components/parameters/PageSize'
  964. responses:
  965. '200':
  966. description: User page
  967. content:
  968. 'application/json':
  969. schema:
  970. type: object
  971. properties:
  972. page:
  973. type: integer
  974. page_size:
  975. type: integer
  976. total:
  977. type: integer
  978. items:
  979. type: array
  980. items:
  981. '$ref': '#/components/schemas/UserRecord'
  982. '/api/v1/admin/users/{id}':
  983. get:
  984. tags:
  985. - Admin
  986. summary: Get user (Admin)
  987. security:
  988. - BearerAuth: []
  989. parameters:
  990. - '$ref': '#/components/parameters/ActingUserId'
  991. - name: id
  992. in: path
  993. required: true
  994. schema:
  995. type: integer
  996. responses:
  997. '200':
  998. description: User record
  999. content:
  1000. 'application/json':
  1001. schema:
  1002. '$ref': '#/components/schemas/UserRecord'
  1003. '404':
  1004. description: Not found
  1005. patch:
  1006. tags:
  1007. - Admin
  1008. summary: Disable / enable user (Admin)
  1009. description: |
  1010. SEC_REVIEW F11. Toggles `disabled_at` on the user row. A disabled
  1011. user cannot complete OIDC or local sign-in and cannot be
  1012. impersonated via the service token (impersonation 403s with
  1013. `user_disabled`).
  1014. Refused with 409 when:
  1015. - the target id matches the acting user (`cannot_disable_self`),
  1016. - the target is the local-admin row (`cannot_disable_local_admin`).
  1017. security:
  1018. - BearerAuth: []
  1019. parameters:
  1020. - '$ref': '#/components/parameters/ActingUserId'
  1021. - name: id
  1022. in: path
  1023. required: true
  1024. schema:
  1025. type: integer
  1026. requestBody:
  1027. required: true
  1028. content:
  1029. 'application/json':
  1030. schema:
  1031. type: object
  1032. required: [disabled]
  1033. properties:
  1034. disabled:
  1035. type: boolean
  1036. responses:
  1037. '200':
  1038. description: Updated record
  1039. content:
  1040. 'application/json':
  1041. schema:
  1042. '$ref': '#/components/schemas/UserRecord'
  1043. '400':
  1044. description: Validation error
  1045. '404':
  1046. description: Not found
  1047. '409':
  1048. description: Refused (self-disable or local-admin)
  1049. content:
  1050. 'application/json':
  1051. schema:
  1052. type: object
  1053. properties:
  1054. error:
  1055. type: string
  1056. enum:
  1057. - cannot_disable_self
  1058. - cannot_disable_local_admin
  1059. '/api/v1/admin/audit-log':
  1060. get:
  1061. tags:
  1062. - Admin
  1063. summary: Filtered audit log
  1064. security:
  1065. - BearerAuth: []
  1066. parameters:
  1067. - '$ref': '#/components/parameters/ActingUserId'
  1068. - name: actor_kind
  1069. in: query
  1070. schema:
  1071. type: string
  1072. enum:
  1073. - user
  1074. - admin-token
  1075. - reporter
  1076. - consumer
  1077. - system
  1078. - name: actor_id
  1079. in: query
  1080. schema:
  1081. type: integer
  1082. - name: actor_via
  1083. in: query
  1084. description: |
  1085. SEC_REVIEW F11. Filter rows by upstream auth path. `oidc` and
  1086. `local` further split rows that already have `actor_kind=user`
  1087. (impersonation), so an auditor can scope a review to local-admin
  1088. actions vs OIDC-user actions without joining the users table.
  1089. schema:
  1090. type: string
  1091. enum:
  1092. - oidc
  1093. - local
  1094. - admin-token
  1095. - service
  1096. - reporter
  1097. - consumer
  1098. - system
  1099. - name: action
  1100. in: query
  1101. schema:
  1102. type: string
  1103. - name: entity_type
  1104. in: query
  1105. schema:
  1106. type: string
  1107. - name: entity_id
  1108. in: query
  1109. schema:
  1110. type: string
  1111. - name: subject_kind
  1112. in: query
  1113. description: |
  1114. With `subject_id`, returns rows where the (kind, id) pair matches
  1115. either the audit row's target OR its actor. Useful for per-entity
  1116. detail pages that want both admin actions on the entity and
  1117. events emitted by it (`report.received`, `blocklist.requested`).
  1118. Both halves must be supplied together; otherwise 400.
  1119. schema:
  1120. type: string
  1121. - name: subject_id
  1122. in: query
  1123. schema:
  1124. type: string
  1125. - name: from
  1126. in: query
  1127. schema:
  1128. type: string
  1129. format: date-time
  1130. - name: to
  1131. in: query
  1132. schema:
  1133. type: string
  1134. format: date-time
  1135. - '$ref': '#/components/parameters/Page'
  1136. - '$ref': '#/components/parameters/PageSize'
  1137. responses:
  1138. '200':
  1139. description: Audit page
  1140. content:
  1141. 'application/json':
  1142. schema:
  1143. type: object
  1144. properties:
  1145. page:
  1146. type: integer
  1147. minimum: 1
  1148. example: 1
  1149. page_size:
  1150. type: integer
  1151. minimum: 1
  1152. maximum: 200
  1153. example: 50
  1154. total:
  1155. type: integer
  1156. minimum: 0
  1157. example: 1284
  1158. items:
  1159. type: array
  1160. items:
  1161. '$ref': '#/components/schemas/AuditEntry'
  1162. '/api/v1/admin/jobs/status':
  1163. get:
  1164. tags:
  1165. - Admin
  1166. summary: Jobs status (Viewer)
  1167. security:
  1168. - BearerAuth: []
  1169. parameters:
  1170. - '$ref': '#/components/parameters/ActingUserId'
  1171. responses:
  1172. '200':
  1173. description: Jobs status
  1174. content:
  1175. 'application/json':
  1176. schema:
  1177. type: object
  1178. properties:
  1179. now:
  1180. type: string
  1181. format: date-time
  1182. jobs:
  1183. type: object
  1184. additionalProperties:
  1185. '$ref': '#/components/schemas/JobStatus'
  1186. '/api/v1/admin/jobs/trigger/{name}':
  1187. post:
  1188. tags:
  1189. - Admin
  1190. summary: Manually trigger a job (Admin)
  1191. description: 'Whitelisted params: `full`, `max_rows`, `reenrich`. Other body fields are dropped.'
  1192. security:
  1193. - BearerAuth: []
  1194. parameters:
  1195. - '$ref': '#/components/parameters/ActingUserId'
  1196. - name: name
  1197. in: path
  1198. required: true
  1199. schema:
  1200. type: string
  1201. requestBody:
  1202. content:
  1203. 'application/json':
  1204. schema:
  1205. type: object
  1206. properties:
  1207. full:
  1208. type: boolean
  1209. max_rows:
  1210. type: integer
  1211. reenrich:
  1212. type: boolean
  1213. responses:
  1214. '200':
  1215. description: Job ran
  1216. content:
  1217. 'application/json':
  1218. schema:
  1219. '$ref': '#/components/schemas/JobOutcome'
  1220. '404':
  1221. description: Unknown job
  1222. '409':
  1223. description: Lock held; status=`skipped_locked`
  1224. '412':
  1225. description: refresh-geoip without credential
  1226. '/api/v1/admin/config':
  1227. get:
  1228. tags:
  1229. - Admin
  1230. summary: Effective config (secrets masked)
  1231. description: Admin only.
  1232. security:
  1233. - BearerAuth: []
  1234. parameters:
  1235. - '$ref': '#/components/parameters/ActingUserId'
  1236. responses:
  1237. '200':
  1238. description: Config sections
  1239. content:
  1240. 'application/json':
  1241. schema:
  1242. type: object
  1243. properties:
  1244. sections:
  1245. type: object
  1246. additionalProperties:
  1247. type: object
  1248. '/api/v1/admin/app-settings':
  1249. get:
  1250. tags:
  1251. - Admin
  1252. summary: Runtime feature flags (Admin)
  1253. description: |
  1254. Returns the runtime-mutable feature flags. Currently exposes the
  1255. audit-emission toggles for high-volume public endpoints
  1256. (`audit_report_received_enabled`, `audit_blocklist_request_enabled`).
  1257. security:
  1258. - BearerAuth: []
  1259. parameters:
  1260. - '$ref': '#/components/parameters/ActingUserId'
  1261. responses:
  1262. '200':
  1263. description: Current toggle state
  1264. content:
  1265. 'application/json':
  1266. schema:
  1267. type: object
  1268. additionalProperties:
  1269. type: boolean
  1270. patch:
  1271. tags:
  1272. - Admin
  1273. summary: Update runtime feature flags (Admin)
  1274. description: |
  1275. Updates one or more runtime feature flags. Body keys not listed are left
  1276. untouched. Returns the post-update snapshot.
  1277. security:
  1278. - BearerAuth: []
  1279. parameters:
  1280. - '$ref': '#/components/parameters/ActingUserId'
  1281. requestBody:
  1282. required: true
  1283. content:
  1284. 'application/json':
  1285. schema:
  1286. type: object
  1287. properties:
  1288. audit_report_received_enabled:
  1289. type: boolean
  1290. audit_blocklist_request_enabled:
  1291. type: boolean
  1292. responses:
  1293. '200':
  1294. description: Updated snapshot
  1295. content:
  1296. 'application/json':
  1297. schema:
  1298. type: object
  1299. additionalProperties:
  1300. type: boolean
  1301. '400':
  1302. description: Validation error
  1303. '/api/v1/admin/maintenance/purge':
  1304. post:
  1305. tags:
  1306. - Admin
  1307. summary: Wipe operational data (Admin)
  1308. description: |
  1309. Deletes reports, scores, enrichment, manual blocks, allowlist, audit log, job history, reporters, consumers, policies, and non-service tokens. Preserves users, OIDC role mappings, abuse categories, and the `service`-kind token.
  1310. Requires `confirm: "PURGE"` in the body — any other value returns 400.
  1311. security:
  1312. - BearerAuth: []
  1313. parameters:
  1314. - '$ref': '#/components/parameters/ActingUserId'
  1315. requestBody:
  1316. required: true
  1317. content:
  1318. 'application/json':
  1319. schema:
  1320. type: object
  1321. required:
  1322. - confirm
  1323. properties:
  1324. confirm:
  1325. type: string
  1326. enum:
  1327. - PURGE
  1328. responses:
  1329. '200':
  1330. description: Purge succeeded
  1331. content:
  1332. 'application/json':
  1333. schema:
  1334. type: object
  1335. properties:
  1336. status:
  1337. type: string
  1338. example: purged
  1339. deleted:
  1340. type: object
  1341. additionalProperties:
  1342. type: integer
  1343. '400':
  1344. description: Missing or wrong `confirm` value
  1345. '/api/v1/admin/maintenance/seed-demo':
  1346. post:
  1347. tags:
  1348. - Admin
  1349. summary: Load demo dataset (Admin)
  1350. description: |
  1351. Populates reporters, consumers, IPs, reports, manual blocks, allowlist, and synthetic GeoIP for demos and screenshots. Triggers a full score recompute on completion. Idempotent: returns 409 if demo data is already present.
  1352. Requires `confirm: "SEED"` in the body — any other value returns 400.
  1353. security:
  1354. - BearerAuth: []
  1355. parameters:
  1356. - '$ref': '#/components/parameters/ActingUserId'
  1357. requestBody:
  1358. required: true
  1359. content:
  1360. 'application/json':
  1361. schema:
  1362. type: object
  1363. required:
  1364. - confirm
  1365. properties:
  1366. confirm:
  1367. type: string
  1368. enum:
  1369. - SEED
  1370. responses:
  1371. '200':
  1372. description: Demo data inserted
  1373. content:
  1374. 'application/json':
  1375. schema:
  1376. type: object
  1377. properties:
  1378. status:
  1379. type: string
  1380. example: seeded
  1381. summary:
  1382. type: object
  1383. additionalProperties:
  1384. type: integer
  1385. recompute:
  1386. '$ref': '#/components/schemas/JobOutcome'
  1387. '400':
  1388. description: Missing or wrong `confirm` value
  1389. '409':
  1390. description: Demo data already present
  1391. '412':
  1392. description: No categories configured
  1393. '/api/v1/auth/users/upsert-oidc':
  1394. post:
  1395. tags:
  1396. - Auth
  1397. summary: Upsert an OIDC-authenticated user
  1398. description: |
  1399. **UI BFF only.** Service-token-required, no impersonation header.
  1400. Resolves the user record + role (via `oidc_role_mappings`) for a freshly-validated ID token.
  1401. x-internal: true
  1402. security:
  1403. - BearerAuth: []
  1404. requestBody:
  1405. required: true
  1406. content:
  1407. 'application/json':
  1408. schema:
  1409. type: object
  1410. properties:
  1411. subject:
  1412. type: string
  1413. email:
  1414. type: string
  1415. display_name:
  1416. type: string
  1417. groups:
  1418. type: array
  1419. items:
  1420. type: string
  1421. responses:
  1422. '200':
  1423. description: User record
  1424. content:
  1425. 'application/json':
  1426. schema:
  1427. '$ref': '#/components/schemas/User'
  1428. '/api/v1/auth/users/upsert-local':
  1429. post:
  1430. tags:
  1431. - Auth
  1432. summary: Upsert the local-admin user
  1433. description: '**UI BFF only.** Called after the UI validates the local-admin password.'
  1434. x-internal: true
  1435. security:
  1436. - BearerAuth: []
  1437. requestBody:
  1438. required: true
  1439. content:
  1440. 'application/json':
  1441. schema:
  1442. type: object
  1443. properties:
  1444. username:
  1445. type: string
  1446. responses:
  1447. '200':
  1448. description: User record
  1449. content:
  1450. 'application/json':
  1451. schema:
  1452. '$ref': '#/components/schemas/User'
  1453. '/api/v1/auth/users/{id}':
  1454. get:
  1455. tags:
  1456. - Auth
  1457. summary: Refetch a user record
  1458. description: |
  1459. **UI BFF only.** Used to refresh role / display_name during a session.
  1460. Every call (200 and 404) emits a `user.fetched` audit row so iterative enumeration of user ids leaves a per-id trail (SEC_REVIEW F17). The route group is also rate-limited per service-token id (SEC_REVIEW F14).
  1461. x-internal: true
  1462. security:
  1463. - BearerAuth: []
  1464. parameters:
  1465. - name: id
  1466. in: path
  1467. required: true
  1468. schema:
  1469. type: integer
  1470. responses:
  1471. '200':
  1472. description: User record
  1473. content:
  1474. 'application/json':
  1475. schema:
  1476. '$ref': '#/components/schemas/User'
  1477. '404':
  1478. description: No user with this id
  1479. content:
  1480. 'application/json':
  1481. schema:
  1482. type: object
  1483. properties:
  1484. error:
  1485. type: string
  1486. example: not_found
  1487. components:
  1488. securitySchemes:
  1489. BearerAuth:
  1490. type: http
  1491. scheme: bearer
  1492. description: |
  1493. Token in the form `irdb_<kind>_<32 base32 chars>`.
  1494. See `doc/auth-flows.md` for the four token kinds.
  1495. parameters:
  1496. Page:
  1497. name: page
  1498. in: query
  1499. schema:
  1500. type: integer
  1501. minimum: 1
  1502. default: 1
  1503. PageSize:
  1504. name: page_size
  1505. in: query
  1506. schema:
  1507. type: integer
  1508. minimum: 1
  1509. maximum: 200
  1510. default: 50
  1511. ActingUserId:
  1512. name: X-Acting-User-Id
  1513. in: header
  1514. description: |
  1515. Required when authenticating with a `service` token.
  1516. The api applies RBAC for the named user. Ignored on other token kinds.
  1517. schema:
  1518. type: integer
  1519. schemas:
  1520. Error:
  1521. type: object
  1522. required:
  1523. - error
  1524. properties:
  1525. error:
  1526. type: string
  1527. example: unauthorized
  1528. details:
  1529. type: object
  1530. description: Field-level errors for `validation_failed`.
  1531. additionalProperties:
  1532. type: string
  1533. ReportRequest:
  1534. type: object
  1535. required:
  1536. - ip
  1537. - category
  1538. properties:
  1539. ip:
  1540. type: string
  1541. example: '203.0.113.42'
  1542. category:
  1543. type: string
  1544. example: brute_force
  1545. metadata:
  1546. type: object
  1547. description: Free-form per-report data, max 4 KB after json_encode.
  1548. additionalProperties: true
  1549. ReportResponse:
  1550. type: object
  1551. properties:
  1552. report_id:
  1553. type: integer
  1554. example: 12345
  1555. ip:
  1556. type: string
  1557. example: '203.0.113.42'
  1558. received_at:
  1559. type: string
  1560. format: date-time
  1561. BlocklistEntry:
  1562. type: object
  1563. properties:
  1564. ip_or_cidr:
  1565. type: string
  1566. example: '203.0.113.42'
  1567. categories:
  1568. type: array
  1569. items:
  1570. type: string
  1571. score:
  1572. type: number
  1573. format: float
  1574. example: 1.42
  1575. reason:
  1576. type: string
  1577. enum:
  1578. - scored
  1579. - manual
  1580. example: scored
  1581. BlocklistJson:
  1582. type: object
  1583. properties:
  1584. count:
  1585. type: integer
  1586. example: 42
  1587. generated_at:
  1588. type: string
  1589. format: date-time
  1590. policy:
  1591. type: string
  1592. example: moderate
  1593. entries:
  1594. type: array
  1595. items:
  1596. '$ref': '#/components/schemas/BlocklistEntry'
  1597. Token:
  1598. type: object
  1599. properties:
  1600. id:
  1601. type: integer
  1602. kind:
  1603. type: string
  1604. enum:
  1605. - reporter
  1606. - consumer
  1607. - admin
  1608. prefix:
  1609. type: string
  1610. example: irdb_adm
  1611. reporter_id:
  1612. type: integer
  1613. nullable: true
  1614. consumer_id:
  1615. type: integer
  1616. nullable: true
  1617. role:
  1618. type: string
  1619. nullable: true
  1620. enum:
  1621. - viewer
  1622. - operator
  1623. - admin
  1624. - null
  1625. user_id:
  1626. type: integer
  1627. nullable: true
  1628. description: |
  1629. For admin-kind tokens issued via the API, the id of the admin
  1630. user who minted the token. Reporter, consumer, service, and
  1631. admin tokens minted via `bin/console tokens:create` carry null.
  1632. When non-null, the token is rejected (401) at auth time if the
  1633. issuer is later disabled or demoted below the token's role.
  1634. (SEC_REVIEW F16.)
  1635. user_label:
  1636. type: string
  1637. nullable: true
  1638. description: |
  1639. Denormalised display name (or email) of the issuing user;
  1640. null when `user_id` is null or the user has since been deleted.
  1641. Surfaced on list responses only — not part of the create
  1642. response.
  1643. expires_at:
  1644. type: string
  1645. format: date-time
  1646. nullable: true
  1647. revoked_at:
  1648. type: string
  1649. format: date-time
  1650. nullable: true
  1651. last_used_at:
  1652. type: string
  1653. format: date-time
  1654. nullable: true
  1655. TokenCreated:
  1656. allOf:
  1657. - '$ref': '#/components/schemas/Token'
  1658. - type: object
  1659. properties:
  1660. raw_token:
  1661. type: string
  1662. description: Returned ONCE on creation — copy it now, never displayed again.
  1663. example: irdb_adm_AAAAAAAABBBBBBBBCCCCCCCCDDDDDDDD
  1664. Reporter:
  1665. type: object
  1666. properties:
  1667. id:
  1668. type: integer
  1669. name:
  1670. type: string
  1671. example: web-prod-01
  1672. description:
  1673. type: string
  1674. nullable: true
  1675. trust_weight:
  1676. type: number
  1677. format: float
  1678. minimum: 0
  1679. maximum: 2
  1680. is_active:
  1681. type: boolean
  1682. audit_enabled:
  1683. type: boolean
  1684. description: When false, suppresses `report.received` audit rows for this reporter even if the global toggle is on.
  1685. Consumer:
  1686. type: object
  1687. properties:
  1688. id:
  1689. type: integer
  1690. name:
  1691. type: string
  1692. example: edge-fw-01
  1693. description:
  1694. type: string
  1695. nullable: true
  1696. policy_id:
  1697. type: integer
  1698. is_active:
  1699. type: boolean
  1700. audit_enabled:
  1701. type: boolean
  1702. description: When false, suppresses `blocklist.requested` audit rows for this consumer even if the global toggle is on.
  1703. last_pulled_at:
  1704. type: string
  1705. format: date-time
  1706. nullable: true
  1707. Category:
  1708. type: object
  1709. properties:
  1710. id:
  1711. type: integer
  1712. slug:
  1713. type: string
  1714. example: brute_force
  1715. name:
  1716. type: string
  1717. description:
  1718. type: string
  1719. nullable: true
  1720. decay_function:
  1721. type: string
  1722. enum:
  1723. - linear
  1724. - exponential
  1725. decay_param:
  1726. type: number
  1727. format: float
  1728. is_active:
  1729. type: boolean
  1730. Policy:
  1731. type: object
  1732. properties:
  1733. id:
  1734. type: integer
  1735. name:
  1736. type: string
  1737. example: moderate
  1738. description:
  1739. type: string
  1740. nullable: true
  1741. include_manual_blocks:
  1742. type: boolean
  1743. thresholds:
  1744. type: object
  1745. description: '`{category_slug: threshold}`'
  1746. additionalProperties:
  1747. type: number
  1748. format: float
  1749. ManualBlock:
  1750. type: object
  1751. properties:
  1752. id:
  1753. type: integer
  1754. kind:
  1755. type: string
  1756. enum:
  1757. - ip
  1758. - subnet
  1759. ip:
  1760. type: string
  1761. nullable: true
  1762. cidr:
  1763. type: string
  1764. nullable: true
  1765. reason:
  1766. type: string
  1767. nullable: true
  1768. expires_at:
  1769. type: string
  1770. format: date-time
  1771. nullable: true
  1772. created_at:
  1773. type: string
  1774. format: date-time
  1775. AllowlistEntry:
  1776. type: object
  1777. properties:
  1778. id:
  1779. type: integer
  1780. kind:
  1781. type: string
  1782. enum:
  1783. - ip
  1784. - subnet
  1785. ip:
  1786. type: string
  1787. nullable: true
  1788. cidr:
  1789. type: string
  1790. nullable: true
  1791. reason:
  1792. type: string
  1793. nullable: true
  1794. created_at:
  1795. type: string
  1796. format: date-time
  1797. IpDetail:
  1798. type: object
  1799. properties:
  1800. ip:
  1801. type: string
  1802. is_ipv4:
  1803. type: boolean
  1804. scores:
  1805. type: array
  1806. items:
  1807. type: object
  1808. properties:
  1809. category:
  1810. type: string
  1811. score:
  1812. type: number
  1813. format: float
  1814. last_report_at:
  1815. type: string
  1816. format: date-time
  1817. nullable: true
  1818. report_count_30d:
  1819. type: integer
  1820. enrichment:
  1821. type: object
  1822. properties:
  1823. country_code:
  1824. type: string
  1825. nullable: true
  1826. asn:
  1827. type: integer
  1828. nullable: true
  1829. as_org:
  1830. type: string
  1831. nullable: true
  1832. enriched_at:
  1833. type: string
  1834. format: date-time
  1835. nullable: true
  1836. status:
  1837. type: string
  1838. enum:
  1839. - scored
  1840. - manually_blocked
  1841. - allowlisted
  1842. - clean
  1843. manual_block:
  1844. type: object
  1845. nullable: true
  1846. allowlist:
  1847. type: object
  1848. nullable: true
  1849. history:
  1850. type: array
  1851. items:
  1852. type: object
  1853. has_more:
  1854. type: boolean
  1855. AuditEntry:
  1856. type: object
  1857. properties:
  1858. id:
  1859. type: integer
  1860. occurred_at:
  1861. type: string
  1862. format: date-time
  1863. actor_kind:
  1864. type: string
  1865. enum:
  1866. - user
  1867. - admin-token
  1868. - reporter
  1869. - consumer
  1870. - system
  1871. actor_id:
  1872. type: string
  1873. nullable: true
  1874. actor_via:
  1875. type: string
  1876. nullable: true
  1877. description: |
  1878. SEC_REVIEW F11. Upstream auth path used by the actor. `oidc` /
  1879. `local` are subdivisions of `actor_kind=user`; the others mirror
  1880. their `actor_kind`. NULL on rows written before the column was
  1881. added.
  1882. enum:
  1883. - oidc
  1884. - local
  1885. - admin-token
  1886. - service
  1887. - reporter
  1888. - consumer
  1889. - system
  1890. action:
  1891. type: string
  1892. example: manual_block.created
  1893. entity_type:
  1894. type: string
  1895. nullable: true
  1896. entity_id:
  1897. type: string
  1898. nullable: true
  1899. entity_label:
  1900. type: string
  1901. nullable: true
  1902. description: Human-readable identifier for the target (name, slug, IP, CIDR, prefix). Frozen at write time.
  1903. details:
  1904. type: object
  1905. nullable: true
  1906. additionalProperties: true
  1907. description: 'For update events, contains a `changes` map of `{field: {from, to}}` for every modified field.'
  1908. source_ip:
  1909. type: string
  1910. nullable: true
  1911. JobStatus:
  1912. type: object
  1913. properties:
  1914. name:
  1915. type: string
  1916. default_interval_seconds:
  1917. type: integer
  1918. max_runtime_seconds:
  1919. type: integer
  1920. overdue:
  1921. type: boolean
  1922. last_run:
  1923. type: object
  1924. nullable: true
  1925. properties:
  1926. id:
  1927. type: integer
  1928. status:
  1929. type: string
  1930. enum:
  1931. - success
  1932. - failure
  1933. - skipped_locked
  1934. - running
  1935. items_processed:
  1936. type: integer
  1937. triggered_by:
  1938. type: string
  1939. enum:
  1940. - schedule
  1941. - manual
  1942. - api
  1943. started_at:
  1944. type: string
  1945. format: date-time
  1946. nullable: true
  1947. finished_at:
  1948. type: string
  1949. format: date-time
  1950. nullable: true
  1951. error_message:
  1952. type: string
  1953. nullable: true
  1954. JobOutcome:
  1955. type: object
  1956. properties:
  1957. job:
  1958. type: string
  1959. status:
  1960. type: string
  1961. enum:
  1962. - success
  1963. - failure
  1964. - skipped_locked
  1965. - running
  1966. items_processed:
  1967. type: integer
  1968. duration_ms:
  1969. type: integer
  1970. run_id:
  1971. type: integer
  1972. nullable: true
  1973. error:
  1974. type: string
  1975. nullable: true
  1976. User:
  1977. type: object
  1978. properties:
  1979. id:
  1980. type: integer
  1981. email:
  1982. type: string
  1983. nullable: true
  1984. display_name:
  1985. type: string
  1986. role:
  1987. type: string
  1988. enum:
  1989. - viewer
  1990. - operator
  1991. - admin
  1992. source:
  1993. type: string
  1994. enum:
  1995. - oidc
  1996. - local
  1997. - admin-token
  1998. is_local:
  1999. type: boolean
  2000. UserRecord:
  2001. type: object
  2002. description: |
  2003. Admin-API representation of a `users` row. Shared by
  2004. `/api/v1/admin/users` list/get/patch.
  2005. properties:
  2006. id:
  2007. type: integer
  2008. subject:
  2009. type: string
  2010. nullable: true
  2011. description: OIDC `sub` claim (null for the local-admin row).
  2012. email:
  2013. type: string
  2014. nullable: true
  2015. display_name:
  2016. type: string
  2017. nullable: true
  2018. role:
  2019. type: string
  2020. enum:
  2021. - viewer
  2022. - operator
  2023. - admin
  2024. is_local:
  2025. type: boolean
  2026. disabled:
  2027. type: boolean
  2028. disabled_at:
  2029. type: string
  2030. format: date-time
  2031. nullable: true
  2032. Pagination:
  2033. type: object
  2034. properties:
  2035. page:
  2036. type: integer
  2037. minimum: 1
  2038. example: 1
  2039. page_size:
  2040. type: integer
  2041. minimum: 1
  2042. maximum: 200
  2043. example: 50
  2044. total:
  2045. type: integer
  2046. minimum: 0
  2047. example: 1284