kong.yml 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408
  1. _format_version: '2.1'
  2. _transform: true
  3. ###
  4. ### Consumers / Users
  5. ###
  6. consumers:
  7. - username: DASHBOARD
  8. - username: anon
  9. keyauth_credentials:
  10. - key: $BRIVEN_ANON_KEY
  11. - key: $BRIVEN_PUBLISHABLE_KEY
  12. - username: service_role
  13. keyauth_credentials:
  14. - key: $BRIVEN_SERVICE_KEY
  15. - key: $BRIVEN_SECRET_KEY
  16. ###
  17. ### Access Control List
  18. ###
  19. acls:
  20. - consumer: anon
  21. group: anon
  22. - consumer: service_role
  23. group: admin
  24. ###
  25. ### Dashboard credentials
  26. ###
  27. basicauth_credentials:
  28. - consumer: DASHBOARD
  29. username: '$DASHBOARD_USERNAME'
  30. password: '$DASHBOARD_PASSWORD'
  31. ###
  32. ### API Routes
  33. ###
  34. services:
  35. ## Open Auth routes
  36. - name: auth-v1-open
  37. _comment: 'Auth: /auth/v1/verify* -> http://auth:9999/verify*'
  38. url: http://auth:9999/verify
  39. routes:
  40. - name: auth-v1-open
  41. strip_path: true
  42. paths:
  43. - /auth/v1/verify
  44. plugins:
  45. - name: cors
  46. - name: auth-v1-open-callback
  47. _comment: 'Auth: /auth/v1/callback* -> http://auth:9999/callback*'
  48. url: http://auth:9999/callback
  49. routes:
  50. - name: auth-v1-open-callback
  51. strip_path: true
  52. paths:
  53. - /auth/v1/callback
  54. plugins:
  55. - name: cors
  56. - name: auth-v1-open-authorize
  57. _comment: 'Auth: /auth/v1/authorize* -> http://auth:9999/authorize*'
  58. url: http://auth:9999/authorize
  59. routes:
  60. - name: auth-v1-open-authorize
  61. strip_path: true
  62. paths:
  63. - /auth/v1/authorize
  64. plugins:
  65. - name: cors
  66. - name: auth-v1-open-jwks
  67. _comment: 'Auth: /auth/v1/.well-known/jwks.json -> http://auth:9999/.well-known/jwks.json'
  68. url: http://auth:9999/.well-known/jwks.json
  69. routes:
  70. - name: auth-v1-open-jwks
  71. strip_path: true
  72. paths:
  73. - /auth/v1/.well-known/jwks.json
  74. plugins:
  75. - name: cors
  76. - name: auth-v1-open-sso-acs
  77. url: "http://auth:9999/sso/saml/acs"
  78. routes:
  79. - name: auth-v1-open-sso-acs
  80. strip_path: true
  81. paths:
  82. - /sso/saml/acs
  83. plugins:
  84. - name: cors
  85. - name: auth-v1-open-sso-metadata
  86. url: "http://auth:9999/sso/saml/metadata"
  87. routes:
  88. - name: auth-v1-open-sso-metadata
  89. strip_path: true
  90. paths:
  91. - /sso/saml/metadata
  92. plugins:
  93. - name: cors
  94. ## Secure Auth routes
  95. - name: auth-v1
  96. _comment: 'Auth: /auth/v1/* -> http://auth:9999/*'
  97. url: http://auth:9999/
  98. routes:
  99. - name: auth-v1-all
  100. strip_path: true
  101. paths:
  102. - /auth/v1/
  103. plugins:
  104. - name: cors
  105. - name: key-auth
  106. config:
  107. hide_credentials: false
  108. - name: request-transformer
  109. config:
  110. add:
  111. headers:
  112. - "Authorization: $LUA_AUTH_EXPR"
  113. replace:
  114. headers:
  115. - "Authorization: $LUA_AUTH_EXPR"
  116. - name: acl
  117. config:
  118. hide_groups_header: true
  119. allow:
  120. - admin
  121. - anon
  122. ## Secure PostgREST routes
  123. - name: rest-v1
  124. _comment: 'PostgREST: /rest/v1/* -> http://rest:3000/*'
  125. url: http://rest:3000/
  126. routes:
  127. - name: rest-v1-all
  128. strip_path: true
  129. paths:
  130. - /rest/v1/
  131. plugins:
  132. - name: cors
  133. - name: key-auth
  134. config:
  135. hide_credentials: false
  136. - name: request-transformer
  137. config:
  138. add:
  139. headers:
  140. - "Authorization: $LUA_AUTH_EXPR"
  141. replace:
  142. headers:
  143. - "Authorization: $LUA_AUTH_EXPR"
  144. - name: acl
  145. config:
  146. hide_groups_header: true
  147. allow:
  148. - admin
  149. - anon
  150. ## Secure GraphQL routes
  151. - name: graphql-v1
  152. _comment: 'PostgREST: /graphql/v1/* -> http://rest:3000/rpc/graphql'
  153. url: http://rest:3000/rpc/graphql
  154. routes:
  155. - name: graphql-v1-all
  156. strip_path: true
  157. paths:
  158. - /graphql/v1
  159. plugins:
  160. - name: cors
  161. - name: key-auth
  162. config:
  163. hide_credentials: false
  164. - name: request-transformer
  165. config:
  166. add:
  167. headers:
  168. - "Content-Profile: graphql_public"
  169. - "Authorization: $LUA_AUTH_EXPR"
  170. replace:
  171. headers:
  172. - "Authorization: $LUA_AUTH_EXPR"
  173. - name: acl
  174. config:
  175. hide_groups_header: true
  176. allow:
  177. - admin
  178. - anon
  179. ## Secure Realtime routes
  180. - name: realtime-v1-ws
  181. _comment: 'Realtime: /realtime/v1/* -> ws://realtime:4000/socket/*'
  182. url: http://realtime-dev.briven-realtime:4000/socket
  183. protocol: ws
  184. routes:
  185. - name: realtime-v1-ws
  186. strip_path: true
  187. paths:
  188. - /realtime/v1/
  189. plugins:
  190. - name: cors
  191. - name: key-auth
  192. config:
  193. hide_credentials: false
  194. - name: request-transformer
  195. config:
  196. add:
  197. headers:
  198. - "x-api-key:$LUA_RT_WS_EXPR"
  199. replace:
  200. querystring:
  201. - "apikey:$LUA_RT_WS_EXPR"
  202. - name: acl
  203. config:
  204. hide_groups_header: true
  205. allow:
  206. - admin
  207. - anon
  208. - name: realtime-v1-rest
  209. _comment: 'Realtime: /realtime/v1/api/* -> http://realtime:4000/api/*'
  210. url: http://realtime-dev.briven-realtime:4000/api
  211. protocol: http
  212. routes:
  213. - name: realtime-v1-rest
  214. strip_path: true
  215. paths:
  216. - /realtime/v1/api
  217. plugins:
  218. - name: cors
  219. - name: key-auth
  220. config:
  221. hide_credentials: false
  222. - name: request-transformer
  223. config:
  224. add:
  225. headers:
  226. - "Authorization: $LUA_AUTH_EXPR"
  227. replace:
  228. headers:
  229. - "Authorization: $LUA_AUTH_EXPR"
  230. - name: acl
  231. config:
  232. hide_groups_header: true
  233. allow:
  234. - admin
  235. - anon
  236. ## Storage API endpoint (with Authorization header transformation).
  237. ## No key-auth — S3 protocol requests don't carry an apikey header.
  238. ##
  239. ## The request-transformer translates opaque API keys to asymmetric JWTs
  240. ## and passes through existing Authorization headers (user JWTs, AWS SigV4).
  241. ## When no Authorization or apikey header is present (S3 presigned URLs),
  242. ## the Lua expression evaluates to nil which Kong renders as empty string.
  243. ## The post-function strips this empty header so Storage's S3 signature
  244. ## verification falls through to query-parameter parsing.
  245. - name: storage-v1
  246. _comment: 'Storage: /storage/v1/* -> http://storage:5000/*'
  247. url: http://storage:5000/
  248. routes:
  249. - name: storage-v1-all
  250. strip_path: true
  251. paths:
  252. - /storage/v1/
  253. plugins:
  254. - name: cors
  255. - name: request-transformer
  256. config:
  257. add:
  258. headers:
  259. - "Authorization: $LUA_AUTH_EXPR"
  260. replace:
  261. headers:
  262. - "Authorization: $LUA_AUTH_EXPR"
  263. - name: post-function
  264. config:
  265. access:
  266. - |
  267. local auth = kong.request.get_header("authorization")
  268. if auth == nil or auth == "" or auth:find("^%s*$") then
  269. kong.service.request.clear_header("authorization")
  270. end
  271. ## Edge Functions routes
  272. - name: functions-v1
  273. _comment: 'Edge Functions: /functions/v1/* -> http://functions:9000/*'
  274. url: http://functions:9000/
  275. read_timeout: 150000
  276. routes:
  277. - name: functions-v1-all
  278. strip_path: true
  279. paths:
  280. - /functions/v1/
  281. plugins:
  282. - name: cors
  283. ## OAuth 2.0 Authorization Server Metadata (RFC 8414)
  284. - name: well-known-oauth
  285. _comment: 'Auth: /.well-known/oauth-authorization-server -> http://auth:9999/.well-known/oauth-authorization-server'
  286. url: http://auth:9999/.well-known/oauth-authorization-server
  287. routes:
  288. - name: well-known-oauth
  289. strip_path: true
  290. paths:
  291. - /.well-known/oauth-authorization-server
  292. plugins:
  293. - name: cors
  294. ## Analytics routes
  295. ## Not used - Studio and Vector talk directly to analytics via Docker networking.
  296. ## If external access is needed, add routes with key-auth matching Logflare's x-api-key auth.
  297. # - name: analytics-v1-api
  298. # _comment: 'Analytics: /analytics/v1/api/endpoints/* -> http://logflare:4000/api/endpoints/*'
  299. # url: http://analytics:4000/api/endpoints
  300. # routes:
  301. # - name: analytics-v1-api
  302. # strip_path: true
  303. # paths:
  304. # - /analytics/v1/api/endpoints/
  305. # - name: analytics-v1
  306. # _comment: 'Analytics: /analytics/v1/* -> http://logflare:4000/*'
  307. # url: http://analytics:4000/
  308. # routes:
  309. # - name: dashboard-v1-all
  310. # strip_path: true
  311. # paths:
  312. # - /analytics/v1
  313. # plugins:
  314. # - name: cors
  315. # - name: basic-auth
  316. # config:
  317. # hide_credentials: true
  318. ## Secure Database routes
  319. - name: meta
  320. _comment: 'pg-meta: /pg/* -> http://pg-meta:8080/*'
  321. url: http://meta:8080/
  322. routes:
  323. - name: meta-all
  324. strip_path: true
  325. paths:
  326. - /pg/
  327. plugins:
  328. - name: key-auth
  329. config:
  330. hide_credentials: false
  331. - name: acl
  332. config:
  333. hide_groups_header: true
  334. allow:
  335. - admin
  336. ## Block access to /api/mcp
  337. - name: mcp-blocker
  338. _comment: 'Block direct access to /api/mcp'
  339. url: http://studio:3000/api/mcp
  340. routes:
  341. - name: mcp-blocker-route
  342. strip_path: true
  343. paths:
  344. - /api/mcp
  345. plugins:
  346. - name: request-termination
  347. config:
  348. status_code: 403
  349. message: "Access is forbidden."
  350. ## MCP endpoint - local access
  351. - name: mcp
  352. _comment: 'MCP: /mcp -> http://studio:3000/api/mcp (local access)'
  353. url: http://studio:3000/api/mcp
  354. routes:
  355. - name: mcp
  356. strip_path: true
  357. paths:
  358. - /mcp
  359. plugins:
  360. # Block access to /mcp by default
  361. - name: request-termination
  362. config:
  363. status_code: 403
  364. message: "Access is forbidden."
  365. # Enable local access (danger zone!)
  366. # 1. Comment out the 'request-termination' section above
  367. # 2. Uncomment the entire section below, including 'deny'
  368. # 3. Add your local IPs to the 'allow' list
  369. #- name: cors
  370. #- name: ip-restriction
  371. # config:
  372. # allow:
  373. # - 127.0.0.1
  374. # - ::1
  375. # deny: []
  376. ## Protected Dashboard - catch all remaining routes
  377. - name: dashboard
  378. _comment: 'Studio: /* -> http://studio:3000/*'
  379. url: http://studio:3000/
  380. routes:
  381. - name: dashboard-all
  382. strip_path: true
  383. paths:
  384. - /
  385. plugins:
  386. - name: cors
  387. - name: basic-auth
  388. config:
  389. hide_credentials: true