1
0

openapi.yaml 52 KB

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