1
0

openapi.yaml 53 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048
  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: '**UI BFF only.** Used to refresh role / display_name during a session.'
  1459. x-internal: true
  1460. security:
  1461. - BearerAuth: []
  1462. parameters:
  1463. - name: id
  1464. in: path
  1465. required: true
  1466. schema:
  1467. type: integer
  1468. responses:
  1469. '200':
  1470. description: User record
  1471. content:
  1472. 'application/json':
  1473. schema:
  1474. '$ref': '#/components/schemas/User'
  1475. components:
  1476. securitySchemes:
  1477. BearerAuth:
  1478. type: http
  1479. scheme: bearer
  1480. description: |
  1481. Token in the form `irdb_<kind>_<32 base32 chars>`.
  1482. See `doc/auth-flows.md` for the four token kinds.
  1483. parameters:
  1484. Page:
  1485. name: page
  1486. in: query
  1487. schema:
  1488. type: integer
  1489. minimum: 1
  1490. default: 1
  1491. PageSize:
  1492. name: page_size
  1493. in: query
  1494. schema:
  1495. type: integer
  1496. minimum: 1
  1497. maximum: 200
  1498. default: 50
  1499. ActingUserId:
  1500. name: X-Acting-User-Id
  1501. in: header
  1502. description: |
  1503. Required when authenticating with a `service` token.
  1504. The api applies RBAC for the named user. Ignored on other token kinds.
  1505. schema:
  1506. type: integer
  1507. schemas:
  1508. Error:
  1509. type: object
  1510. required:
  1511. - error
  1512. properties:
  1513. error:
  1514. type: string
  1515. example: unauthorized
  1516. details:
  1517. type: object
  1518. description: Field-level errors for `validation_failed`.
  1519. additionalProperties:
  1520. type: string
  1521. ReportRequest:
  1522. type: object
  1523. required:
  1524. - ip
  1525. - category
  1526. properties:
  1527. ip:
  1528. type: string
  1529. example: '203.0.113.42'
  1530. category:
  1531. type: string
  1532. example: brute_force
  1533. metadata:
  1534. type: object
  1535. description: Free-form per-report data, max 4 KB after json_encode.
  1536. additionalProperties: true
  1537. ReportResponse:
  1538. type: object
  1539. properties:
  1540. report_id:
  1541. type: integer
  1542. example: 12345
  1543. ip:
  1544. type: string
  1545. example: '203.0.113.42'
  1546. received_at:
  1547. type: string
  1548. format: date-time
  1549. BlocklistEntry:
  1550. type: object
  1551. properties:
  1552. ip_or_cidr:
  1553. type: string
  1554. example: '203.0.113.42'
  1555. categories:
  1556. type: array
  1557. items:
  1558. type: string
  1559. score:
  1560. type: number
  1561. format: float
  1562. example: 1.42
  1563. reason:
  1564. type: string
  1565. enum:
  1566. - scored
  1567. - manual
  1568. example: scored
  1569. BlocklistJson:
  1570. type: object
  1571. properties:
  1572. count:
  1573. type: integer
  1574. example: 42
  1575. generated_at:
  1576. type: string
  1577. format: date-time
  1578. policy:
  1579. type: string
  1580. example: moderate
  1581. entries:
  1582. type: array
  1583. items:
  1584. '$ref': '#/components/schemas/BlocklistEntry'
  1585. Token:
  1586. type: object
  1587. properties:
  1588. id:
  1589. type: integer
  1590. kind:
  1591. type: string
  1592. enum:
  1593. - reporter
  1594. - consumer
  1595. - admin
  1596. prefix:
  1597. type: string
  1598. example: irdb_adm
  1599. reporter_id:
  1600. type: integer
  1601. nullable: true
  1602. consumer_id:
  1603. type: integer
  1604. nullable: true
  1605. role:
  1606. type: string
  1607. nullable: true
  1608. enum:
  1609. - viewer
  1610. - operator
  1611. - admin
  1612. - null
  1613. user_id:
  1614. type: integer
  1615. nullable: true
  1616. description: |
  1617. For admin-kind tokens issued via the API, the id of the admin
  1618. user who minted the token. Reporter, consumer, service, and
  1619. admin tokens minted via `bin/console tokens:create` carry null.
  1620. When non-null, the token is rejected (401) at auth time if the
  1621. issuer is later disabled or demoted below the token's role.
  1622. (SEC_REVIEW F16.)
  1623. user_label:
  1624. type: string
  1625. nullable: true
  1626. description: |
  1627. Denormalised display name (or email) of the issuing user;
  1628. null when `user_id` is null or the user has since been deleted.
  1629. Surfaced on list responses only — not part of the create
  1630. response.
  1631. expires_at:
  1632. type: string
  1633. format: date-time
  1634. nullable: true
  1635. revoked_at:
  1636. type: string
  1637. format: date-time
  1638. nullable: true
  1639. last_used_at:
  1640. type: string
  1641. format: date-time
  1642. nullable: true
  1643. TokenCreated:
  1644. allOf:
  1645. - '$ref': '#/components/schemas/Token'
  1646. - type: object
  1647. properties:
  1648. raw_token:
  1649. type: string
  1650. description: Returned ONCE on creation — copy it now, never displayed again.
  1651. example: irdb_adm_AAAAAAAABBBBBBBBCCCCCCCCDDDDDDDD
  1652. Reporter:
  1653. type: object
  1654. properties:
  1655. id:
  1656. type: integer
  1657. name:
  1658. type: string
  1659. example: web-prod-01
  1660. description:
  1661. type: string
  1662. nullable: true
  1663. trust_weight:
  1664. type: number
  1665. format: float
  1666. minimum: 0
  1667. maximum: 2
  1668. is_active:
  1669. type: boolean
  1670. audit_enabled:
  1671. type: boolean
  1672. description: When false, suppresses `report.received` audit rows for this reporter even if the global toggle is on.
  1673. Consumer:
  1674. type: object
  1675. properties:
  1676. id:
  1677. type: integer
  1678. name:
  1679. type: string
  1680. example: edge-fw-01
  1681. description:
  1682. type: string
  1683. nullable: true
  1684. policy_id:
  1685. type: integer
  1686. is_active:
  1687. type: boolean
  1688. audit_enabled:
  1689. type: boolean
  1690. description: When false, suppresses `blocklist.requested` audit rows for this consumer even if the global toggle is on.
  1691. last_pulled_at:
  1692. type: string
  1693. format: date-time
  1694. nullable: true
  1695. Category:
  1696. type: object
  1697. properties:
  1698. id:
  1699. type: integer
  1700. slug:
  1701. type: string
  1702. example: brute_force
  1703. name:
  1704. type: string
  1705. description:
  1706. type: string
  1707. nullable: true
  1708. decay_function:
  1709. type: string
  1710. enum:
  1711. - linear
  1712. - exponential
  1713. decay_param:
  1714. type: number
  1715. format: float
  1716. is_active:
  1717. type: boolean
  1718. Policy:
  1719. type: object
  1720. properties:
  1721. id:
  1722. type: integer
  1723. name:
  1724. type: string
  1725. example: moderate
  1726. description:
  1727. type: string
  1728. nullable: true
  1729. include_manual_blocks:
  1730. type: boolean
  1731. thresholds:
  1732. type: object
  1733. description: '`{category_slug: threshold}`'
  1734. additionalProperties:
  1735. type: number
  1736. format: float
  1737. ManualBlock:
  1738. type: object
  1739. properties:
  1740. id:
  1741. type: integer
  1742. kind:
  1743. type: string
  1744. enum:
  1745. - ip
  1746. - subnet
  1747. ip:
  1748. type: string
  1749. nullable: true
  1750. cidr:
  1751. type: string
  1752. nullable: true
  1753. reason:
  1754. type: string
  1755. nullable: true
  1756. expires_at:
  1757. type: string
  1758. format: date-time
  1759. nullable: true
  1760. created_at:
  1761. type: string
  1762. format: date-time
  1763. AllowlistEntry:
  1764. type: object
  1765. properties:
  1766. id:
  1767. type: integer
  1768. kind:
  1769. type: string
  1770. enum:
  1771. - ip
  1772. - subnet
  1773. ip:
  1774. type: string
  1775. nullable: true
  1776. cidr:
  1777. type: string
  1778. nullable: true
  1779. reason:
  1780. type: string
  1781. nullable: true
  1782. created_at:
  1783. type: string
  1784. format: date-time
  1785. IpDetail:
  1786. type: object
  1787. properties:
  1788. ip:
  1789. type: string
  1790. is_ipv4:
  1791. type: boolean
  1792. scores:
  1793. type: array
  1794. items:
  1795. type: object
  1796. properties:
  1797. category:
  1798. type: string
  1799. score:
  1800. type: number
  1801. format: float
  1802. last_report_at:
  1803. type: string
  1804. format: date-time
  1805. nullable: true
  1806. report_count_30d:
  1807. type: integer
  1808. enrichment:
  1809. type: object
  1810. properties:
  1811. country_code:
  1812. type: string
  1813. nullable: true
  1814. asn:
  1815. type: integer
  1816. nullable: true
  1817. as_org:
  1818. type: string
  1819. nullable: true
  1820. enriched_at:
  1821. type: string
  1822. format: date-time
  1823. nullable: true
  1824. status:
  1825. type: string
  1826. enum:
  1827. - scored
  1828. - manually_blocked
  1829. - allowlisted
  1830. - clean
  1831. manual_block:
  1832. type: object
  1833. nullable: true
  1834. allowlist:
  1835. type: object
  1836. nullable: true
  1837. history:
  1838. type: array
  1839. items:
  1840. type: object
  1841. has_more:
  1842. type: boolean
  1843. AuditEntry:
  1844. type: object
  1845. properties:
  1846. id:
  1847. type: integer
  1848. occurred_at:
  1849. type: string
  1850. format: date-time
  1851. actor_kind:
  1852. type: string
  1853. enum:
  1854. - user
  1855. - admin-token
  1856. - reporter
  1857. - consumer
  1858. - system
  1859. actor_id:
  1860. type: string
  1861. nullable: true
  1862. actor_via:
  1863. type: string
  1864. nullable: true
  1865. description: |
  1866. SEC_REVIEW F11. Upstream auth path used by the actor. `oidc` /
  1867. `local` are subdivisions of `actor_kind=user`; the others mirror
  1868. their `actor_kind`. NULL on rows written before the column was
  1869. added.
  1870. enum:
  1871. - oidc
  1872. - local
  1873. - admin-token
  1874. - service
  1875. - reporter
  1876. - consumer
  1877. - system
  1878. action:
  1879. type: string
  1880. example: manual_block.created
  1881. entity_type:
  1882. type: string
  1883. nullable: true
  1884. entity_id:
  1885. type: string
  1886. nullable: true
  1887. entity_label:
  1888. type: string
  1889. nullable: true
  1890. description: Human-readable identifier for the target (name, slug, IP, CIDR, prefix). Frozen at write time.
  1891. details:
  1892. type: object
  1893. nullable: true
  1894. additionalProperties: true
  1895. description: 'For update events, contains a `changes` map of `{field: {from, to}}` for every modified field.'
  1896. source_ip:
  1897. type: string
  1898. nullable: true
  1899. JobStatus:
  1900. type: object
  1901. properties:
  1902. name:
  1903. type: string
  1904. default_interval_seconds:
  1905. type: integer
  1906. max_runtime_seconds:
  1907. type: integer
  1908. overdue:
  1909. type: boolean
  1910. last_run:
  1911. type: object
  1912. nullable: true
  1913. properties:
  1914. id:
  1915. type: integer
  1916. status:
  1917. type: string
  1918. enum:
  1919. - success
  1920. - failure
  1921. - skipped_locked
  1922. - running
  1923. items_processed:
  1924. type: integer
  1925. triggered_by:
  1926. type: string
  1927. enum:
  1928. - schedule
  1929. - manual
  1930. - api
  1931. started_at:
  1932. type: string
  1933. format: date-time
  1934. nullable: true
  1935. finished_at:
  1936. type: string
  1937. format: date-time
  1938. nullable: true
  1939. error_message:
  1940. type: string
  1941. nullable: true
  1942. JobOutcome:
  1943. type: object
  1944. properties:
  1945. job:
  1946. type: string
  1947. status:
  1948. type: string
  1949. enum:
  1950. - success
  1951. - failure
  1952. - skipped_locked
  1953. - running
  1954. items_processed:
  1955. type: integer
  1956. duration_ms:
  1957. type: integer
  1958. run_id:
  1959. type: integer
  1960. nullable: true
  1961. error:
  1962. type: string
  1963. nullable: true
  1964. User:
  1965. type: object
  1966. properties:
  1967. id:
  1968. type: integer
  1969. email:
  1970. type: string
  1971. nullable: true
  1972. display_name:
  1973. type: string
  1974. role:
  1975. type: string
  1976. enum:
  1977. - viewer
  1978. - operator
  1979. - admin
  1980. source:
  1981. type: string
  1982. enum:
  1983. - oidc
  1984. - local
  1985. - admin-token
  1986. is_local:
  1987. type: boolean
  1988. UserRecord:
  1989. type: object
  1990. description: |
  1991. Admin-API representation of a `users` row. Shared by
  1992. `/api/v1/admin/users` list/get/patch.
  1993. properties:
  1994. id:
  1995. type: integer
  1996. subject:
  1997. type: string
  1998. nullable: true
  1999. description: OIDC `sub` claim (null for the local-admin row).
  2000. email:
  2001. type: string
  2002. nullable: true
  2003. display_name:
  2004. type: string
  2005. nullable: true
  2006. role:
  2007. type: string
  2008. enum:
  2009. - viewer
  2010. - operator
  2011. - admin
  2012. is_local:
  2013. type: boolean
  2014. disabled:
  2015. type: boolean
  2016. disabled_at:
  2017. type: string
  2018. format: date-time
  2019. nullable: true
  2020. Pagination:
  2021. type: object
  2022. properties:
  2023. page:
  2024. type: integer
  2025. minimum: 1
  2026. example: 1
  2027. page_size:
  2028. type: integer
  2029. minimum: 1
  2030. maximum: 200
  2031. example: 50
  2032. total:
  2033. type: integer
  2034. minimum: 0
  2035. example: 1284