nene2-python 1.8.26__tar.gz → 1.8.27__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (275) hide show
  1. {nene2_python-1.8.26 → nene2_python-1.8.27}/CHANGELOG.md +11 -0
  2. {nene2_python-1.8.26 → nene2_python-1.8.27}/PKG-INFO +1 -1
  3. nene2_python-1.8.27/docs/field-trials/2026-05-field-trial-81.md +198 -0
  4. {nene2_python-1.8.26 → nene2_python-1.8.27}/pyproject.toml +1 -1
  5. {nene2_python-1.8.26 → nene2_python-1.8.27}/src/nene2/middleware/setup.py +47 -3
  6. {nene2_python-1.8.26 → nene2_python-1.8.27}/tests/nene2/middleware/test_setup_middlewares.py +65 -0
  7. {nene2_python-1.8.26 → nene2_python-1.8.27}/uv.lock +1 -1
  8. {nene2_python-1.8.26 → nene2_python-1.8.27}/.env.example +0 -0
  9. {nene2_python-1.8.26 → nene2_python-1.8.27}/.github/workflows/ci.yml +0 -0
  10. {nene2_python-1.8.26 → nene2_python-1.8.27}/.github/workflows/docs.yml +0 -0
  11. {nene2_python-1.8.26 → nene2_python-1.8.27}/.github/workflows/publish.yml +0 -0
  12. {nene2_python-1.8.26 → nene2_python-1.8.27}/.gitignore +0 -0
  13. {nene2_python-1.8.26 → nene2_python-1.8.27}/.vitepress/config.mts +0 -0
  14. {nene2_python-1.8.26 → nene2_python-1.8.27}/.vitepress/theme/custom.css +0 -0
  15. {nene2_python-1.8.26 → nene2_python-1.8.27}/.vitepress/theme/index.ts +0 -0
  16. {nene2_python-1.8.26 → nene2_python-1.8.27}/AGENTS.md +0 -0
  17. {nene2_python-1.8.26 → nene2_python-1.8.27}/CLAUDE.md +0 -0
  18. {nene2_python-1.8.26 → nene2_python-1.8.27}/Dockerfile +0 -0
  19. {nene2_python-1.8.26 → nene2_python-1.8.27}/LICENSE +0 -0
  20. {nene2_python-1.8.26 → nene2_python-1.8.27}/README.md +0 -0
  21. {nene2_python-1.8.26 → nene2_python-1.8.27}/alembic/README +0 -0
  22. {nene2_python-1.8.26 → nene2_python-1.8.27}/alembic/env.py +0 -0
  23. {nene2_python-1.8.26 → nene2_python-1.8.27}/alembic/script.py.mako +0 -0
  24. {nene2_python-1.8.26 → nene2_python-1.8.27}/alembic/versions/001_create_notes_and_tags_tables.py +0 -0
  25. {nene2_python-1.8.26 → nene2_python-1.8.27}/alembic.ini +0 -0
  26. {nene2_python-1.8.26 → nene2_python-1.8.27}/compose.yaml +0 -0
  27. {nene2_python-1.8.26 → nene2_python-1.8.27}/docs/adr/0001-toolchain.md +0 -0
  28. {nene2_python-1.8.26 → nene2_python-1.8.27}/docs/adr/0002-clean-architecture.md +0 -0
  29. {nene2_python-1.8.26 → nene2_python-1.8.27}/docs/adr/0003-security-first.md +0 -0
  30. {nene2_python-1.8.26 → nene2_python-1.8.27}/docs/adr/0004-ai-first-design.md +0 -0
  31. {nene2_python-1.8.26 → nene2_python-1.8.27}/docs/adr/0005-logging.md +0 -0
  32. {nene2_python-1.8.26 → nene2_python-1.8.27}/docs/adr/0006-rate-limiting.md +0 -0
  33. {nene2_python-1.8.26 → nene2_python-1.8.27}/docs/adr/0009-mcp-design.md +0 -0
  34. {nene2_python-1.8.26 → nene2_python-1.8.27}/docs/adr/0010-async-use-case.md +0 -0
  35. {nene2_python-1.8.26 → nene2_python-1.8.27}/docs/adr/0011-mcp-as-core-dependency.md +0 -0
  36. {nene2_python-1.8.26 → nene2_python-1.8.27}/docs/de/index.md +0 -0
  37. {nene2_python-1.8.26 → nene2_python-1.8.27}/docs/de/tutorials/getting-started.md +0 -0
  38. {nene2_python-1.8.26 → nene2_python-1.8.27}/docs/explanation/architecture.md +0 -0
  39. {nene2_python-1.8.26 → nene2_python-1.8.27}/docs/explanation/design-philosophy.md +0 -0
  40. {nene2_python-1.8.26 → nene2_python-1.8.27}/docs/field-trials/2026-05-field-trial-1.md +0 -0
  41. {nene2_python-1.8.26 → nene2_python-1.8.27}/docs/field-trials/2026-05-field-trial-10.md +0 -0
  42. {nene2_python-1.8.26 → nene2_python-1.8.27}/docs/field-trials/2026-05-field-trial-11.md +0 -0
  43. {nene2_python-1.8.26 → nene2_python-1.8.27}/docs/field-trials/2026-05-field-trial-12.md +0 -0
  44. {nene2_python-1.8.26 → nene2_python-1.8.27}/docs/field-trials/2026-05-field-trial-13.md +0 -0
  45. {nene2_python-1.8.26 → nene2_python-1.8.27}/docs/field-trials/2026-05-field-trial-14.md +0 -0
  46. {nene2_python-1.8.26 → nene2_python-1.8.27}/docs/field-trials/2026-05-field-trial-15.md +0 -0
  47. {nene2_python-1.8.26 → nene2_python-1.8.27}/docs/field-trials/2026-05-field-trial-16.md +0 -0
  48. {nene2_python-1.8.26 → nene2_python-1.8.27}/docs/field-trials/2026-05-field-trial-17.md +0 -0
  49. {nene2_python-1.8.26 → nene2_python-1.8.27}/docs/field-trials/2026-05-field-trial-18.md +0 -0
  50. {nene2_python-1.8.26 → nene2_python-1.8.27}/docs/field-trials/2026-05-field-trial-19.md +0 -0
  51. {nene2_python-1.8.26 → nene2_python-1.8.27}/docs/field-trials/2026-05-field-trial-2.md +0 -0
  52. {nene2_python-1.8.26 → nene2_python-1.8.27}/docs/field-trials/2026-05-field-trial-20.md +0 -0
  53. {nene2_python-1.8.26 → nene2_python-1.8.27}/docs/field-trials/2026-05-field-trial-21.md +0 -0
  54. {nene2_python-1.8.26 → nene2_python-1.8.27}/docs/field-trials/2026-05-field-trial-22.md +0 -0
  55. {nene2_python-1.8.26 → nene2_python-1.8.27}/docs/field-trials/2026-05-field-trial-23.md +0 -0
  56. {nene2_python-1.8.26 → nene2_python-1.8.27}/docs/field-trials/2026-05-field-trial-24.md +0 -0
  57. {nene2_python-1.8.26 → nene2_python-1.8.27}/docs/field-trials/2026-05-field-trial-25.md +0 -0
  58. {nene2_python-1.8.26 → nene2_python-1.8.27}/docs/field-trials/2026-05-field-trial-26.md +0 -0
  59. {nene2_python-1.8.26 → nene2_python-1.8.27}/docs/field-trials/2026-05-field-trial-27.md +0 -0
  60. {nene2_python-1.8.26 → nene2_python-1.8.27}/docs/field-trials/2026-05-field-trial-28.md +0 -0
  61. {nene2_python-1.8.26 → nene2_python-1.8.27}/docs/field-trials/2026-05-field-trial-29.md +0 -0
  62. {nene2_python-1.8.26 → nene2_python-1.8.27}/docs/field-trials/2026-05-field-trial-3.md +0 -0
  63. {nene2_python-1.8.26 → nene2_python-1.8.27}/docs/field-trials/2026-05-field-trial-30.md +0 -0
  64. {nene2_python-1.8.26 → nene2_python-1.8.27}/docs/field-trials/2026-05-field-trial-31.md +0 -0
  65. {nene2_python-1.8.26 → nene2_python-1.8.27}/docs/field-trials/2026-05-field-trial-32.md +0 -0
  66. {nene2_python-1.8.26 → nene2_python-1.8.27}/docs/field-trials/2026-05-field-trial-33.md +0 -0
  67. {nene2_python-1.8.26 → nene2_python-1.8.27}/docs/field-trials/2026-05-field-trial-34.md +0 -0
  68. {nene2_python-1.8.26 → nene2_python-1.8.27}/docs/field-trials/2026-05-field-trial-35.md +0 -0
  69. {nene2_python-1.8.26 → nene2_python-1.8.27}/docs/field-trials/2026-05-field-trial-36.md +0 -0
  70. {nene2_python-1.8.26 → nene2_python-1.8.27}/docs/field-trials/2026-05-field-trial-37.md +0 -0
  71. {nene2_python-1.8.26 → nene2_python-1.8.27}/docs/field-trials/2026-05-field-trial-38.md +0 -0
  72. {nene2_python-1.8.26 → nene2_python-1.8.27}/docs/field-trials/2026-05-field-trial-39.md +0 -0
  73. {nene2_python-1.8.26 → nene2_python-1.8.27}/docs/field-trials/2026-05-field-trial-4.md +0 -0
  74. {nene2_python-1.8.26 → nene2_python-1.8.27}/docs/field-trials/2026-05-field-trial-40.md +0 -0
  75. {nene2_python-1.8.26 → nene2_python-1.8.27}/docs/field-trials/2026-05-field-trial-41.md +0 -0
  76. {nene2_python-1.8.26 → nene2_python-1.8.27}/docs/field-trials/2026-05-field-trial-42.md +0 -0
  77. {nene2_python-1.8.26 → nene2_python-1.8.27}/docs/field-trials/2026-05-field-trial-43.md +0 -0
  78. {nene2_python-1.8.26 → nene2_python-1.8.27}/docs/field-trials/2026-05-field-trial-44.md +0 -0
  79. {nene2_python-1.8.26 → nene2_python-1.8.27}/docs/field-trials/2026-05-field-trial-45.md +0 -0
  80. {nene2_python-1.8.26 → nene2_python-1.8.27}/docs/field-trials/2026-05-field-trial-46.md +0 -0
  81. {nene2_python-1.8.26 → nene2_python-1.8.27}/docs/field-trials/2026-05-field-trial-47.md +0 -0
  82. {nene2_python-1.8.26 → nene2_python-1.8.27}/docs/field-trials/2026-05-field-trial-48.md +0 -0
  83. {nene2_python-1.8.26 → nene2_python-1.8.27}/docs/field-trials/2026-05-field-trial-49.md +0 -0
  84. {nene2_python-1.8.26 → nene2_python-1.8.27}/docs/field-trials/2026-05-field-trial-5.md +0 -0
  85. {nene2_python-1.8.26 → nene2_python-1.8.27}/docs/field-trials/2026-05-field-trial-50.md +0 -0
  86. {nene2_python-1.8.26 → nene2_python-1.8.27}/docs/field-trials/2026-05-field-trial-51.md +0 -0
  87. {nene2_python-1.8.26 → nene2_python-1.8.27}/docs/field-trials/2026-05-field-trial-52.md +0 -0
  88. {nene2_python-1.8.26 → nene2_python-1.8.27}/docs/field-trials/2026-05-field-trial-53.md +0 -0
  89. {nene2_python-1.8.26 → nene2_python-1.8.27}/docs/field-trials/2026-05-field-trial-54.md +0 -0
  90. {nene2_python-1.8.26 → nene2_python-1.8.27}/docs/field-trials/2026-05-field-trial-55.md +0 -0
  91. {nene2_python-1.8.26 → nene2_python-1.8.27}/docs/field-trials/2026-05-field-trial-56.md +0 -0
  92. {nene2_python-1.8.26 → nene2_python-1.8.27}/docs/field-trials/2026-05-field-trial-57.md +0 -0
  93. {nene2_python-1.8.26 → nene2_python-1.8.27}/docs/field-trials/2026-05-field-trial-58.md +0 -0
  94. {nene2_python-1.8.26 → nene2_python-1.8.27}/docs/field-trials/2026-05-field-trial-59.md +0 -0
  95. {nene2_python-1.8.26 → nene2_python-1.8.27}/docs/field-trials/2026-05-field-trial-6.md +0 -0
  96. {nene2_python-1.8.26 → nene2_python-1.8.27}/docs/field-trials/2026-05-field-trial-60.md +0 -0
  97. {nene2_python-1.8.26 → nene2_python-1.8.27}/docs/field-trials/2026-05-field-trial-61.md +0 -0
  98. {nene2_python-1.8.26 → nene2_python-1.8.27}/docs/field-trials/2026-05-field-trial-62.md +0 -0
  99. {nene2_python-1.8.26 → nene2_python-1.8.27}/docs/field-trials/2026-05-field-trial-63.md +0 -0
  100. {nene2_python-1.8.26 → nene2_python-1.8.27}/docs/field-trials/2026-05-field-trial-64.md +0 -0
  101. {nene2_python-1.8.26 → nene2_python-1.8.27}/docs/field-trials/2026-05-field-trial-65.md +0 -0
  102. {nene2_python-1.8.26 → nene2_python-1.8.27}/docs/field-trials/2026-05-field-trial-66.md +0 -0
  103. {nene2_python-1.8.26 → nene2_python-1.8.27}/docs/field-trials/2026-05-field-trial-67.md +0 -0
  104. {nene2_python-1.8.26 → nene2_python-1.8.27}/docs/field-trials/2026-05-field-trial-68.md +0 -0
  105. {nene2_python-1.8.26 → nene2_python-1.8.27}/docs/field-trials/2026-05-field-trial-69.md +0 -0
  106. {nene2_python-1.8.26 → nene2_python-1.8.27}/docs/field-trials/2026-05-field-trial-7.md +0 -0
  107. {nene2_python-1.8.26 → nene2_python-1.8.27}/docs/field-trials/2026-05-field-trial-70.md +0 -0
  108. {nene2_python-1.8.26 → nene2_python-1.8.27}/docs/field-trials/2026-05-field-trial-71.md +0 -0
  109. {nene2_python-1.8.26 → nene2_python-1.8.27}/docs/field-trials/2026-05-field-trial-72.md +0 -0
  110. {nene2_python-1.8.26 → nene2_python-1.8.27}/docs/field-trials/2026-05-field-trial-73.md +0 -0
  111. {nene2_python-1.8.26 → nene2_python-1.8.27}/docs/field-trials/2026-05-field-trial-74.md +0 -0
  112. {nene2_python-1.8.26 → nene2_python-1.8.27}/docs/field-trials/2026-05-field-trial-75.md +0 -0
  113. {nene2_python-1.8.26 → nene2_python-1.8.27}/docs/field-trials/2026-05-field-trial-76.md +0 -0
  114. {nene2_python-1.8.26 → nene2_python-1.8.27}/docs/field-trials/2026-05-field-trial-77.md +0 -0
  115. {nene2_python-1.8.26 → nene2_python-1.8.27}/docs/field-trials/2026-05-field-trial-78.md +0 -0
  116. {nene2_python-1.8.26 → nene2_python-1.8.27}/docs/field-trials/2026-05-field-trial-79.md +0 -0
  117. {nene2_python-1.8.26 → nene2_python-1.8.27}/docs/field-trials/2026-05-field-trial-8.md +0 -0
  118. {nene2_python-1.8.26 → nene2_python-1.8.27}/docs/field-trials/2026-05-field-trial-80.md +0 -0
  119. {nene2_python-1.8.26 → nene2_python-1.8.27}/docs/field-trials/2026-05-field-trial-9.md +0 -0
  120. {nene2_python-1.8.26 → nene2_python-1.8.27}/docs/fr/index.md +0 -0
  121. {nene2_python-1.8.26 → nene2_python-1.8.27}/docs/fr/tutorials/getting-started.md +0 -0
  122. {nene2_python-1.8.26 → nene2_python-1.8.27}/docs/how-to/add-new-domain.md +0 -0
  123. {nene2_python-1.8.26 → nene2_python-1.8.27}/docs/how-to/async-use-case.md +0 -0
  124. {nene2_python-1.8.26 → nene2_python-1.8.27}/docs/how-to/configure-auth.md +0 -0
  125. {nene2_python-1.8.26 → nene2_python-1.8.27}/docs/how-to/middleware-stack.md +0 -0
  126. {nene2_python-1.8.26 → nene2_python-1.8.27}/docs/how-to/new-project.md +0 -0
  127. {nene2_python-1.8.26 → nene2_python-1.8.27}/docs/how-to/problem-details.md +0 -0
  128. {nene2_python-1.8.26 → nene2_python-1.8.27}/docs/how-to/run-tests.md +0 -0
  129. {nene2_python-1.8.26 → nene2_python-1.8.27}/docs/how-to/sqlalchemy-repository.md +0 -0
  130. {nene2_python-1.8.26 → nene2_python-1.8.27}/docs/how-to/validation.md +0 -0
  131. {nene2_python-1.8.26 → nene2_python-1.8.27}/docs/howto/mcp-setup.md +0 -0
  132. {nene2_python-1.8.26 → nene2_python-1.8.27}/docs/index.md +0 -0
  133. {nene2_python-1.8.26 → nene2_python-1.8.27}/docs/ja/explanation/architecture.md +0 -0
  134. {nene2_python-1.8.26 → nene2_python-1.8.27}/docs/ja/explanation/design-philosophy.md +0 -0
  135. {nene2_python-1.8.26 → nene2_python-1.8.27}/docs/ja/how-to/add-new-domain.md +0 -0
  136. {nene2_python-1.8.26 → nene2_python-1.8.27}/docs/ja/how-to/configure-auth.md +0 -0
  137. {nene2_python-1.8.26 → nene2_python-1.8.27}/docs/ja/how-to/new-project.md +0 -0
  138. {nene2_python-1.8.26 → nene2_python-1.8.27}/docs/ja/how-to/run-tests.md +0 -0
  139. {nene2_python-1.8.26 → nene2_python-1.8.27}/docs/ja/how-to/sqlalchemy-repository.md +0 -0
  140. {nene2_python-1.8.26 → nene2_python-1.8.27}/docs/ja/howto/mcp-setup.md +0 -0
  141. {nene2_python-1.8.26 → nene2_python-1.8.27}/docs/ja/index.md +0 -0
  142. {nene2_python-1.8.26 → nene2_python-1.8.27}/docs/ja/reference/api.md +0 -0
  143. {nene2_python-1.8.26 → nene2_python-1.8.27}/docs/ja/reference/configuration.md +0 -0
  144. {nene2_python-1.8.26 → nene2_python-1.8.27}/docs/ja/reference/framework-modules.md +0 -0
  145. {nene2_python-1.8.26 → nene2_python-1.8.27}/docs/ja/tutorials/first-domain.md +0 -0
  146. {nene2_python-1.8.26 → nene2_python-1.8.27}/docs/ja/tutorials/getting-started.md +0 -0
  147. {nene2_python-1.8.26 → nene2_python-1.8.27}/docs/pt-br/index.md +0 -0
  148. {nene2_python-1.8.26 → nene2_python-1.8.27}/docs/pt-br/tutorials/getting-started.md +0 -0
  149. {nene2_python-1.8.26 → nene2_python-1.8.27}/docs/reference/api.md +0 -0
  150. {nene2_python-1.8.26 → nene2_python-1.8.27}/docs/reference/configuration.md +0 -0
  151. {nene2_python-1.8.26 → nene2_python-1.8.27}/docs/reference/framework-modules.md +0 -0
  152. {nene2_python-1.8.26 → nene2_python-1.8.27}/docs/roadmap.md +0 -0
  153. {nene2_python-1.8.26 → nene2_python-1.8.27}/docs/todo/current.md +0 -0
  154. {nene2_python-1.8.26 → nene2_python-1.8.27}/docs/tutorials/first-domain.md +0 -0
  155. {nene2_python-1.8.26 → nene2_python-1.8.27}/docs/tutorials/getting-started.md +0 -0
  156. {nene2_python-1.8.26 → nene2_python-1.8.27}/docs/zh/index.md +0 -0
  157. {nene2_python-1.8.26 → nene2_python-1.8.27}/docs/zh/tutorials/getting-started.md +0 -0
  158. {nene2_python-1.8.26 → nene2_python-1.8.27}/package-lock.json +0 -0
  159. {nene2_python-1.8.26 → nene2_python-1.8.27}/package.json +0 -0
  160. {nene2_python-1.8.26 → nene2_python-1.8.27}/src/example/__init__.py +0 -0
  161. {nene2_python-1.8.26 → nene2_python-1.8.27}/src/example/__main__.py +0 -0
  162. {nene2_python-1.8.26 → nene2_python-1.8.27}/src/example/app.py +0 -0
  163. {nene2_python-1.8.26 → nene2_python-1.8.27}/src/example/comment/__init__.py +0 -0
  164. {nene2_python-1.8.26 → nene2_python-1.8.27}/src/example/comment/entity.py +0 -0
  165. {nene2_python-1.8.26 → nene2_python-1.8.27}/src/example/comment/exceptions.py +0 -0
  166. {nene2_python-1.8.26 → nene2_python-1.8.27}/src/example/comment/handler.py +0 -0
  167. {nene2_python-1.8.26 → nene2_python-1.8.27}/src/example/comment/repository.py +0 -0
  168. {nene2_python-1.8.26 → nene2_python-1.8.27}/src/example/comment/sqlalchemy_repository.py +0 -0
  169. {nene2_python-1.8.26 → nene2_python-1.8.27}/src/example/comment/use_case.py +0 -0
  170. {nene2_python-1.8.26 → nene2_python-1.8.27}/src/example/mcp.py +0 -0
  171. {nene2_python-1.8.26 → nene2_python-1.8.27}/src/example/note/__init__.py +0 -0
  172. {nene2_python-1.8.26 → nene2_python-1.8.27}/src/example/note/async_use_case.py +0 -0
  173. {nene2_python-1.8.26 → nene2_python-1.8.27}/src/example/note/entity.py +0 -0
  174. {nene2_python-1.8.26 → nene2_python-1.8.27}/src/example/note/exceptions.py +0 -0
  175. {nene2_python-1.8.26 → nene2_python-1.8.27}/src/example/note/handler.py +0 -0
  176. {nene2_python-1.8.26 → nene2_python-1.8.27}/src/example/note/repository.py +0 -0
  177. {nene2_python-1.8.26 → nene2_python-1.8.27}/src/example/note/sqlalchemy_repository.py +0 -0
  178. {nene2_python-1.8.26 → nene2_python-1.8.27}/src/example/note/use_case.py +0 -0
  179. {nene2_python-1.8.26 → nene2_python-1.8.27}/src/example/schema.py +0 -0
  180. {nene2_python-1.8.26 → nene2_python-1.8.27}/src/example/tag/__init__.py +0 -0
  181. {nene2_python-1.8.26 → nene2_python-1.8.27}/src/example/tag/entity.py +0 -0
  182. {nene2_python-1.8.26 → nene2_python-1.8.27}/src/example/tag/exceptions.py +0 -0
  183. {nene2_python-1.8.26 → nene2_python-1.8.27}/src/example/tag/handler.py +0 -0
  184. {nene2_python-1.8.26 → nene2_python-1.8.27}/src/example/tag/repository.py +0 -0
  185. {nene2_python-1.8.26 → nene2_python-1.8.27}/src/example/tag/sqlalchemy_repository.py +0 -0
  186. {nene2_python-1.8.26 → nene2_python-1.8.27}/src/example/tag/use_case.py +0 -0
  187. {nene2_python-1.8.26 → nene2_python-1.8.27}/src/nene2/__init__.py +0 -0
  188. {nene2_python-1.8.26 → nene2_python-1.8.27}/src/nene2/auth/__init__.py +0 -0
  189. {nene2_python-1.8.26 → nene2_python-1.8.27}/src/nene2/auth/api_key.py +0 -0
  190. {nene2_python-1.8.26 → nene2_python-1.8.27}/src/nene2/auth/bearer_token.py +0 -0
  191. {nene2_python-1.8.26 → nene2_python-1.8.27}/src/nene2/auth/exceptions.py +0 -0
  192. {nene2_python-1.8.26 → nene2_python-1.8.27}/src/nene2/auth/interfaces.py +0 -0
  193. {nene2_python-1.8.26 → nene2_python-1.8.27}/src/nene2/auth/local_verifier.py +0 -0
  194. {nene2_python-1.8.26 → nene2_python-1.8.27}/src/nene2/config/__init__.py +0 -0
  195. {nene2_python-1.8.26 → nene2_python-1.8.27}/src/nene2/config/settings.py +0 -0
  196. {nene2_python-1.8.26 → nene2_python-1.8.27}/src/nene2/database/__init__.py +0 -0
  197. {nene2_python-1.8.26 → nene2_python-1.8.27}/src/nene2/database/exceptions.py +0 -0
  198. {nene2_python-1.8.26 → nene2_python-1.8.27}/src/nene2/database/health.py +0 -0
  199. {nene2_python-1.8.26 → nene2_python-1.8.27}/src/nene2/database/interfaces.py +0 -0
  200. {nene2_python-1.8.26 → nene2_python-1.8.27}/src/nene2/database/sqlalchemy_executor.py +0 -0
  201. {nene2_python-1.8.26 → nene2_python-1.8.27}/src/nene2/database/utils.py +0 -0
  202. {nene2_python-1.8.26 → nene2_python-1.8.27}/src/nene2/http/__init__.py +0 -0
  203. {nene2_python-1.8.26 → nene2_python-1.8.27}/src/nene2/http/health.py +0 -0
  204. {nene2_python-1.8.26 → nene2_python-1.8.27}/src/nene2/http/pagination.py +0 -0
  205. {nene2_python-1.8.26 → nene2_python-1.8.27}/src/nene2/http/problem_details.py +0 -0
  206. {nene2_python-1.8.26 → nene2_python-1.8.27}/src/nene2/log/__init__.py +0 -0
  207. {nene2_python-1.8.26 → nene2_python-1.8.27}/src/nene2/log/setup.py +0 -0
  208. {nene2_python-1.8.26 → nene2_python-1.8.27}/src/nene2/mcp/__init__.py +0 -0
  209. {nene2_python-1.8.26 → nene2_python-1.8.27}/src/nene2/mcp/http_client.py +0 -0
  210. {nene2_python-1.8.26 → nene2_python-1.8.27}/src/nene2/mcp/server.py +0 -0
  211. {nene2_python-1.8.26 → nene2_python-1.8.27}/src/nene2/middleware/__init__.py +0 -0
  212. {nene2_python-1.8.26 → nene2_python-1.8.27}/src/nene2/middleware/domain_exception.py +0 -0
  213. {nene2_python-1.8.26 → nene2_python-1.8.27}/src/nene2/middleware/error_handler.py +0 -0
  214. {nene2_python-1.8.26 → nene2_python-1.8.27}/src/nene2/middleware/request_id.py +0 -0
  215. {nene2_python-1.8.26 → nene2_python-1.8.27}/src/nene2/middleware/request_logging.py +0 -0
  216. {nene2_python-1.8.26 → nene2_python-1.8.27}/src/nene2/middleware/request_size_limit.py +0 -0
  217. {nene2_python-1.8.26 → nene2_python-1.8.27}/src/nene2/middleware/security_headers.py +0 -0
  218. {nene2_python-1.8.26 → nene2_python-1.8.27}/src/nene2/middleware/throttle.py +0 -0
  219. {nene2_python-1.8.26 → nene2_python-1.8.27}/src/nene2/py.typed +0 -0
  220. {nene2_python-1.8.26 → nene2_python-1.8.27}/src/nene2/use_case/__init__.py +0 -0
  221. {nene2_python-1.8.26 → nene2_python-1.8.27}/src/nene2/use_case/protocols.py +0 -0
  222. {nene2_python-1.8.26 → nene2_python-1.8.27}/src/nene2/validation/__init__.py +0 -0
  223. {nene2_python-1.8.26 → nene2_python-1.8.27}/src/nene2/validation/exceptions.py +0 -0
  224. {nene2_python-1.8.26 → nene2_python-1.8.27}/src/scripts/__init__.py +0 -0
  225. {nene2_python-1.8.26 → nene2_python-1.8.27}/src/scripts/export_openapi.py +0 -0
  226. {nene2_python-1.8.26 → nene2_python-1.8.27}/tests/__init__.py +0 -0
  227. {nene2_python-1.8.26 → nene2_python-1.8.27}/tests/example/__init__.py +0 -0
  228. {nene2_python-1.8.26 → nene2_python-1.8.27}/tests/example/comment/__init__.py +0 -0
  229. {nene2_python-1.8.26 → nene2_python-1.8.27}/tests/example/comment/test_comment_http.py +0 -0
  230. {nene2_python-1.8.26 → nene2_python-1.8.27}/tests/example/comment/test_comment_repository.py +0 -0
  231. {nene2_python-1.8.26 → nene2_python-1.8.27}/tests/example/comment/test_comment_use_case.py +0 -0
  232. {nene2_python-1.8.26 → nene2_python-1.8.27}/tests/example/conftest.py +0 -0
  233. {nene2_python-1.8.26 → nene2_python-1.8.27}/tests/example/note/__init__.py +0 -0
  234. {nene2_python-1.8.26 → nene2_python-1.8.27}/tests/example/note/test_async_note_use_case.py +0 -0
  235. {nene2_python-1.8.26 → nene2_python-1.8.27}/tests/example/note/test_list_notes.py +0 -0
  236. {nene2_python-1.8.26 → nene2_python-1.8.27}/tests/example/note/test_note_repository.py +0 -0
  237. {nene2_python-1.8.26 → nene2_python-1.8.27}/tests/example/tag/__init__.py +0 -0
  238. {nene2_python-1.8.26 → nene2_python-1.8.27}/tests/example/tag/test_tag_repository.py +0 -0
  239. {nene2_python-1.8.26 → nene2_python-1.8.27}/tests/example/tag/test_tags.py +0 -0
  240. {nene2_python-1.8.26 → nene2_python-1.8.27}/tests/example/test_cors.py +0 -0
  241. {nene2_python-1.8.26 → nene2_python-1.8.27}/tests/example/test_mcp.py +0 -0
  242. {nene2_python-1.8.26 → nene2_python-1.8.27}/tests/nene2/__init__.py +0 -0
  243. {nene2_python-1.8.26 → nene2_python-1.8.27}/tests/nene2/auth/__init__.py +0 -0
  244. {nene2_python-1.8.26 → nene2_python-1.8.27}/tests/nene2/auth/test_api_key.py +0 -0
  245. {nene2_python-1.8.26 → nene2_python-1.8.27}/tests/nene2/auth/test_bearer_token.py +0 -0
  246. {nene2_python-1.8.26 → nene2_python-1.8.27}/tests/nene2/auth/test_token_issuer.py +0 -0
  247. {nene2_python-1.8.26 → nene2_python-1.8.27}/tests/nene2/config/__init__.py +0 -0
  248. {nene2_python-1.8.26 → nene2_python-1.8.27}/tests/nene2/config/test_settings.py +0 -0
  249. {nene2_python-1.8.26 → nene2_python-1.8.27}/tests/nene2/database/__init__.py +0 -0
  250. {nene2_python-1.8.26 → nene2_python-1.8.27}/tests/nene2/database/test_transaction.py +0 -0
  251. {nene2_python-1.8.26 → nene2_python-1.8.27}/tests/nene2/database/test_utils.py +0 -0
  252. {nene2_python-1.8.26 → nene2_python-1.8.27}/tests/nene2/http/__init__.py +0 -0
  253. {nene2_python-1.8.26 → nene2_python-1.8.27}/tests/nene2/http/test_health.py +0 -0
  254. {nene2_python-1.8.26 → nene2_python-1.8.27}/tests/nene2/http/test_pagination.py +0 -0
  255. {nene2_python-1.8.26 → nene2_python-1.8.27}/tests/nene2/http/test_problem_details.py +0 -0
  256. {nene2_python-1.8.26 → nene2_python-1.8.27}/tests/nene2/log/__init__.py +0 -0
  257. {nene2_python-1.8.26 → nene2_python-1.8.27}/tests/nene2/log/test_setup.py +0 -0
  258. {nene2_python-1.8.26 → nene2_python-1.8.27}/tests/nene2/mcp/__init__.py +0 -0
  259. {nene2_python-1.8.26 → nene2_python-1.8.27}/tests/nene2/mcp/test_http_client.py +0 -0
  260. {nene2_python-1.8.26 → nene2_python-1.8.27}/tests/nene2/mcp/test_server.py +0 -0
  261. {nene2_python-1.8.26 → nene2_python-1.8.27}/tests/nene2/middleware/__init__.py +0 -0
  262. {nene2_python-1.8.26 → nene2_python-1.8.27}/tests/nene2/middleware/test_error_handler.py +0 -0
  263. {nene2_python-1.8.26 → nene2_python-1.8.27}/tests/nene2/middleware/test_request_id.py +0 -0
  264. {nene2_python-1.8.26 → nene2_python-1.8.27}/tests/nene2/middleware/test_request_logging.py +0 -0
  265. {nene2_python-1.8.26 → nene2_python-1.8.27}/tests/nene2/middleware/test_request_size_limit.py +0 -0
  266. {nene2_python-1.8.26 → nene2_python-1.8.27}/tests/nene2/middleware/test_security_headers.py +0 -0
  267. {nene2_python-1.8.26 → nene2_python-1.8.27}/tests/nene2/middleware/test_simple_domain_handler.py +0 -0
  268. {nene2_python-1.8.26 → nene2_python-1.8.27}/tests/nene2/middleware/test_throttle.py +0 -0
  269. {nene2_python-1.8.26 → nene2_python-1.8.27}/tests/nene2/use_case/__init__.py +0 -0
  270. {nene2_python-1.8.26 → nene2_python-1.8.27}/tests/nene2/use_case/test_protocols.py +0 -0
  271. {nene2_python-1.8.26 → nene2_python-1.8.27}/tests/nene2/use_case/test_run_in_threadpool.py +0 -0
  272. {nene2_python-1.8.26 → nene2_python-1.8.27}/tests/nene2/validation/__init__.py +0 -0
  273. {nene2_python-1.8.26 → nene2_python-1.8.27}/tests/nene2/validation/test_exceptions.py +0 -0
  274. {nene2_python-1.8.26 → nene2_python-1.8.27}/tests/scripts/__init__.py +0 -0
  275. {nene2_python-1.8.26 → nene2_python-1.8.27}/tests/scripts/test_export_openapi.py +0 -0
@@ -5,6 +5,17 @@ Format follows [Keep a Changelog](https://keepachangelog.com/en/1.1.0/).
5
5
 
6
6
  ---
7
7
 
8
+ ## [1.8.26] — 2026-05-20
9
+
10
+ FT80 フィールドトライアル — LocalMcpServer + HttpxMcpClient MCP E2E 検証と list_tools() 追加。
11
+
12
+ ### Added
13
+ - `LocalMcpServer` に `list_tools()` メソッドを追加 (#342) (FT80)
14
+ — 登録済みツール名の一覧を返す。デバッグ・イントロスペクション用途
15
+ - Field trial report: `docs/field-trials/2026-05-field-trial-80.md` (FT80)
16
+
17
+ ---
18
+
8
19
  ## [1.8.25] — 2026-05-20
9
20
 
10
21
  FT79 フィールドトライアル — RequestLoggingMiddleware の構造化ログ検証と context_extractor 追加。
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: nene2-python
3
- Version: 1.8.26
3
+ Version: 1.8.27
4
4
  Summary: NENE2 Python — minimal API framework following NENE2's design philosophy
5
5
  Project-URL: Homepage, https://github.com/hideyukiMORI/nene2-python
6
6
  Project-URL: Repository, https://github.com/hideyukiMORI/nene2-python
@@ -0,0 +1,198 @@
1
+ # FT81: CORS 設定 — setup_middlewares() と CORSMiddleware の組み合わせ
2
+
3
+ **日付**: 2026-05-20
4
+ **テーマ**: setup_middlewares() に CORS サポートがない場合の正しい設定パターン検証
5
+ **バージョン**: v1.8.26
6
+ **FTディレクトリ**: `/home/xi/docker/nene2-python-FT/ft81-cors/`
7
+
8
+ ---
9
+
10
+ ## 概要
11
+
12
+ nene2 の `setup_middlewares()` は CORS をサポートしていないため、
13
+ ブラウザから API を呼び出すアプリで CORS が必要になった際に
14
+ ユーザーは `CORSMiddleware` を手動で追加する必要がある。
15
+ その際、Starlette の LIFO ミドルウェア順序を理解していないと
16
+ OPTIONS プリフライトが正常に動作しない問題を確認した。
17
+
18
+ ---
19
+
20
+ ## 実装パターン
21
+
22
+ ### 正しい CORS 設定(CORS を最外側に配置)
23
+
24
+ ```python
25
+ from fastapi import FastAPI
26
+ from fastapi.middleware.cors import CORSMiddleware
27
+ from nene2.middleware import setup_middlewares
28
+
29
+ ALLOWED_ORIGINS = [
30
+ "https://app.example.com",
31
+ "https://admin.example.com",
32
+ ]
33
+
34
+ app = FastAPI()
35
+
36
+ # ✅ CORS を先に add_middleware → setup_middlewares() 後は LIFO で最外側になる
37
+ app.add_middleware(
38
+ CORSMiddleware,
39
+ allow_origins=ALLOWED_ORIGINS,
40
+ allow_methods=["GET", "POST", "PUT", "DELETE", "OPTIONS"],
41
+ allow_headers=["Authorization", "Content-Type"],
42
+ allow_credentials=True,
43
+ )
44
+ setup_middlewares(app)
45
+ ```
46
+
47
+ ### 間違ったパターン(CORS が内側になる)
48
+
49
+ ```python
50
+ # ❌ setup_middlewares() の後に CORS を追加すると内側に入る
51
+ app = FastAPI()
52
+ setup_middlewares(app)
53
+ app.add_middleware(CORSMiddleware, allow_origins=["https://app.example.com"])
54
+ # → OPTIONS プリフライトが nene2 ミドルウェアに遮断される可能性がある
55
+ ```
56
+
57
+ ### 禁止パターン(CLAUDE.md ポリシー違反)
58
+
59
+ ```python
60
+ # ❌ CLAUDE.md 明示禁止: allow_origins=["*"]
61
+ app.add_middleware(
62
+ CORSMiddleware,
63
+ allow_origins=["*"], # セキュリティリスク
64
+ )
65
+ ```
66
+
67
+ ---
68
+
69
+ ## 発見した問題
70
+
71
+ ### 問題1: setup_middlewares() に CORS パラメーターがない
72
+
73
+ ```python
74
+ # CORS が必要でも setup_middlewares() のシグネチャに cors パラメーターなし
75
+ setup_middlewares(
76
+ app,
77
+ # cors_allowed_origins=["https://app.example.com"], # 存在しない
78
+ )
79
+ ```
80
+
81
+ ユーザーは `FastAPI.add_middleware(CORSMiddleware, ...)` を直接呼ぶ必要がある。
82
+ FastAPI/Starlette のドキュメントを参照しなければ方法がわからない。
83
+
84
+ ### 問題2: ミドルウェア順序が直感に反する(LIFO)
85
+
86
+ ```python
87
+ # Starlette は LIFO — 最後に add_middleware したものが最外側になる
88
+ # つまり CORS を「最外側にしたい」なら「最初に add する」
89
+
90
+ app.add_middleware(CORSMiddleware, ...) # ← 先に追加 = 最外側(正しい)
91
+ setup_middlewares(app) # ← 後から追加 = 内側
92
+
93
+ # 逆にすると:
94
+ setup_middlewares(app) # ← 先に追加 = 最内側(危険)
95
+ app.add_middleware(CORSMiddleware, ...) # ← 後から追加 = 最外側になってしまう
96
+ ```
97
+
98
+ 「最外側に置きたいなら先に add する」という反直感的な順序。
99
+
100
+ ### 問題3: nene2 が allow_origins=["*"] を禁止しない
101
+
102
+ ```python
103
+ # CLAUDE.md で明示禁止されているが、nene2 フレームワークは検証しない
104
+ app.add_middleware(
105
+ CORSMiddleware,
106
+ allow_origins=["*"], # 禁止ポリシーだが動作してしまう
107
+ )
108
+ ```
109
+
110
+ フレームワークレベルで `ValueError` を raise することも可能だが、
111
+ `setup_middlewares()` を経由しない場合は検証できない。
112
+
113
+ ### 問題4: 複数オリジン・credentials 設定パターンがドキュメントにない
114
+
115
+ 本番アプリでは複数オリジン(本番環境 + ステージング環境)や
116
+ `allow_credentials=True` が必要なケースが多いが、
117
+ nene2 のドキュメントにこのパターンの記載がない。
118
+
119
+ ---
120
+
121
+ ## テスト結果(全13件パス)
122
+
123
+ ```
124
+ test_list_items_returns_200 PASSED
125
+ test_create_item_returns_201 PASSED
126
+ test_cors_allowed_origin_returns_access_control_header PASSED
127
+ test_cors_disallowed_origin_no_access_control_header PASSED
128
+ test_cors_preflight_options_returns_200 PASSED # OPTIONS プリフライト正常動作
129
+ test_cors_preflight_disallowed_origin PASSED
130
+ test_cors_credentials_allowed PASSED
131
+ test_security_headers_present_with_cors PASSED # nene2 ミドルウェアと共存
132
+ test_request_id_present_with_cors PASSED # X-Request-Id と共存
133
+ test_friction_no_cors_in_setup_middlewares PASSED # 摩擦: CORS パラメーターなし
134
+ test_friction_cors_order_matters PASSED # 摩擦: LIFO 順序問題
135
+ test_friction_wildcard_origin_is_insecure PASSED # 摩擦: ["*"] を止めない
136
+ test_friction_multiple_origins_not_documented PASSED # 摩擦: ドキュメント不足
137
+ ```
138
+
139
+ ---
140
+
141
+ ## 摩擦ポイント一覧
142
+
143
+ | ID | 内容 | 深刻度 |
144
+ |---|---|---|
145
+ | F81-1 | `setup_middlewares()` に CORS パラメーターがなく手動追加が必要 | 中 |
146
+ | F81-2 | Starlette の LIFO 順序を知らないと OPTIONS プリフライトが壊れる | 中 |
147
+ | F81-3 | `allow_origins=["*"]` を nene2 が禁止しない(ポリシーのみ) | 低 |
148
+ | F81-4 | 複数オリジン・credentials パターンがドキュメントに未記載 | 低 |
149
+
150
+ ---
151
+
152
+ ## 使用感(主観評価)
153
+
154
+ ### 直感性 ★★★☆☆
155
+
156
+ `setup_middlewares()` を使うと CORS は自分で追加しなければならず、
157
+ しかも「先に add する = 最外側になる」という反直感的な順序ルールがある。
158
+ FastAPI や Express.js、Spring Security の CORS 設定を知っているユーザーでも
159
+ nene2 特有の LIFO 順序で一度はつまずく。
160
+
161
+ ### 実害の深刻さ ★★★☆☆
162
+
163
+ ブラウザからの CORS エラーは「API が動かない」として即座に表面化する。
164
+ 原因が「ミドルウェア順序」であることを特定するのに時間がかかることがある。
165
+ 特に OPTIONS プリフライトが通らないと PUT/DELETE/POST with Auth が全滅する。
166
+
167
+ ### 修正のしやすさ ★★★★★
168
+
169
+ `setup_middlewares()` に `cors_allowed_origins` パラメーターを追加するだけ。
170
+ CORS は最外側(最初の add_middleware)に固定できるため、
171
+ ユーザーが順序を気にする必要がなくなる。
172
+
173
+ ```python
174
+ # 理想の API:
175
+ setup_middlewares(
176
+ app,
177
+ cors_allowed_origins=["https://app.example.com"],
178
+ cors_allow_credentials=True,
179
+ )
180
+ ```
181
+
182
+ ### 総合コメント
183
+
184
+ CORS は「作ったら必ず必要になる」機能でありながら、
185
+ nene2 の `setup_middlewares()` には組み込まれていない。
186
+ `["*"]` 禁止は CLAUDE.md のポリシーとして正しいが、
187
+ フレームワークが強制しないと誰かが違反する。
188
+ `cors_allowed_origins` を追加してワイルドカードを `ValueError` にすれば
189
+ セキュリティポリシーをコードで強制できる。
190
+
191
+ ---
192
+
193
+ ## 推奨アクション
194
+
195
+ 1. **Issue**: `setup_middlewares()` に `cors_allowed_origins` パラメーターを追加
196
+ — `allow_origins=["*"]` を渡した場合に `ValueError` を raise
197
+ — CORS を最外側に自動配置(ユーザーが順序を意識しなくていい)
198
+ 2. **docs**: 複数オリジン・credentials のパターンを how-to ガイドに追加
@@ -1,6 +1,6 @@
1
1
  [project]
2
2
  name = "nene2-python"
3
- version = "1.8.26"
3
+ version = "1.8.27"
4
4
  description = "NENE2 Python — minimal API framework following NENE2's design philosophy"
5
5
  readme = "README.md"
6
6
  license = {text = "MIT"}
@@ -3,6 +3,7 @@
3
3
  from typing import Any
4
4
 
5
5
  from starlette.applications import Starlette
6
+ from starlette.middleware.cors import CORSMiddleware
6
7
 
7
8
  from .domain_exception import DomainExceptionHandlerProtocol
8
9
  from .error_handler import ErrorHandlerMiddleware
@@ -15,6 +16,10 @@ from .throttle import ThrottleMiddleware
15
16
  _DEFAULT_MAX_BYTES = 1_048_576 # 1 MiB
16
17
 
17
18
 
19
+ _CORS_ALLOW_METHODS = ["GET", "POST", "PUT", "PATCH", "DELETE", "OPTIONS"]
20
+ _CORS_ALLOW_HEADERS = ["Authorization", "Content-Type"]
21
+
22
+
18
23
  def setup_middlewares(
19
24
  app: object,
20
25
  *,
@@ -32,6 +37,10 @@ def setup_middlewares(
32
37
  hsts: bool = False,
33
38
  csp: str | None = None,
34
39
  security_extra_no_csp_paths: list[str] | None = None,
40
+ cors_allowed_origins: list[str] | None = None,
41
+ cors_allow_credentials: bool = False,
42
+ cors_allow_methods: list[str] | None = None,
43
+ cors_allow_headers: list[str] | None = None,
35
44
  ) -> None:
36
45
  """Register all nene2 middlewares in the correct order.
37
46
 
@@ -41,7 +50,7 @@ def setup_middlewares(
41
50
 
42
51
  Effective stack (outermost → innermost)::
43
52
 
44
- RequestId → SecurityHeaders → SizeLimit → Throttle → RequestLogging → ErrorHandler
53
+ CORS → RequestId → SecurityHeaders → SizeLimit → Throttle → RequestLogging → ErrorHandler
45
54
 
46
55
  **Minimal usage** — all options have sensible defaults::
47
56
 
@@ -50,6 +59,14 @@ def setup_middlewares(
50
59
  app = FastAPI()
51
60
  setup_middlewares(app)
52
61
 
62
+ **With CORS** (explicit origins required — wildcards are rejected)::
63
+
64
+ setup_middlewares(
65
+ app,
66
+ cors_allowed_origins=["https://app.example.com"],
67
+ cors_allow_credentials=True,
68
+ )
69
+
53
70
  **With customisation**::
54
71
 
55
72
  setup_middlewares(
@@ -103,13 +120,29 @@ def setup_middlewares(
103
120
  hsts: Enable Strict-Transport-Security header (default: False).
104
121
  csp: Custom Content-Security-Policy value. Defaults to nene2's built-in policy.
105
122
  security_extra_no_csp_paths: Additional paths to skip CSP (on top of /docs, /redoc).
123
+ cors_allowed_origins: Explicit list of allowed CORS origins.
124
+ Pass ``None`` (default) to skip :class:`CORSMiddleware`.
125
+ Passing ``["*"]`` raises :exc:`ValueError` — wildcard origins are forbidden
126
+ per nene2 security policy.
127
+ cors_allow_credentials: Allow cookies and ``Authorization`` headers in CORS
128
+ requests (default: False).
129
+ cors_allow_methods: HTTP methods exposed via CORS
130
+ (default: GET, POST, PUT, PATCH, DELETE, OPTIONS).
131
+ cors_allow_headers: Request headers exposed via CORS
132
+ (default: Authorization, Content-Type).
106
133
  """
107
134
  if not isinstance(app, Starlette):
108
135
  raise TypeError(f"app must be a Starlette/FastAPI instance, got {type(app)!r}")
109
136
 
137
+ if cors_allowed_origins is not None and "*" in cors_allowed_origins:
138
+ raise ValueError(
139
+ "cors_allowed_origins must not contain '*'. "
140
+ "wildcard CORS origins are forbidden — list explicit origins instead."
141
+ )
142
+
110
143
  # Add in reverse order — first added = innermost, last added = outermost.
111
144
  # Desired outermost → innermost:
112
- # RequestId → SecurityHeaders → SizeLimit → Throttle → RequestLogging → ErrorHandler
145
+ # CORS → RequestId → SecurityHeaders → SizeLimit → Throttle → RequestLogging → ErrorHandler
113
146
 
114
147
  # 1. Innermost: ErrorHandlerMiddleware (also registers RequestValidationError handler)
115
148
  ErrorHandlerMiddleware.install(app, debug=debug, domain_handlers=domain_handlers)
@@ -144,5 +177,16 @@ def setup_middlewares(
144
177
  sec_kwargs["extra_no_csp_paths"] = security_extra_no_csp_paths
145
178
  app.add_middleware(SecurityHeadersMiddleware, **sec_kwargs)
146
179
 
147
- # 6. Outermost: RequestIdMiddleware
180
+ # 6. RequestIdMiddleware
148
181
  app.add_middleware(RequestIdMiddleware)
182
+
183
+ # 7. Outermost: CORSMiddleware (optional) — must be outermost so OPTIONS preflight
184
+ # responses are handled before any other middleware processes the request.
185
+ if cors_allowed_origins is not None:
186
+ app.add_middleware(
187
+ CORSMiddleware,
188
+ allow_origins=cors_allowed_origins,
189
+ allow_credentials=cors_allow_credentials,
190
+ allow_methods=cors_allow_methods or _CORS_ALLOW_METHODS,
191
+ allow_headers=cors_allow_headers or _CORS_ALLOW_HEADERS,
192
+ )
@@ -122,3 +122,68 @@ def test_pydantic_422_formatted_as_nene2() -> None:
122
122
  def test_raises_type_error_for_non_starlette_app() -> None:
123
123
  with pytest.raises(TypeError, match="Starlette/FastAPI"):
124
124
  setup_middlewares(object())
125
+
126
+
127
+ def test_cors_allowed_origin_returns_access_control_header() -> None:
128
+ app = _make_app(cors_allowed_origins=["https://app.example.com"])
129
+ client = TestClient(app, raise_server_exceptions=False)
130
+ r = client.get("/ok", headers={"Origin": "https://app.example.com"})
131
+ assert r.headers.get("access-control-allow-origin") == "https://app.example.com"
132
+
133
+
134
+ def test_cors_disallowed_origin_no_header() -> None:
135
+ app = _make_app(cors_allowed_origins=["https://app.example.com"])
136
+ client = TestClient(app, raise_server_exceptions=False)
137
+ r = client.get("/ok", headers={"Origin": "https://evil.example.com"})
138
+ assert "access-control-allow-origin" not in r.headers
139
+
140
+
141
+ def test_cors_preflight_options_returns_200() -> None:
142
+ app = _make_app(cors_allowed_origins=["https://app.example.com"])
143
+ client = TestClient(app, raise_server_exceptions=False)
144
+ r = client.options(
145
+ "/ok",
146
+ headers={
147
+ "Origin": "https://app.example.com",
148
+ "Access-Control-Request-Method": "GET",
149
+ },
150
+ )
151
+ assert r.headers.get("access-control-allow-origin") == "https://app.example.com"
152
+
153
+
154
+ def test_cors_wildcard_origin_raises_value_error() -> None:
155
+ with pytest.raises(ValueError, match="wildcard"):
156
+ _make_app(cors_allowed_origins=["*"])
157
+
158
+
159
+ def test_cors_none_means_no_cors_middleware() -> None:
160
+ app = _make_app(cors_allowed_origins=None)
161
+ client = TestClient(app, raise_server_exceptions=False)
162
+ r = client.get("/ok", headers={"Origin": "https://app.example.com"})
163
+ assert "access-control-allow-origin" not in r.headers
164
+
165
+
166
+ def test_cors_credentials_can_be_enabled() -> None:
167
+ app = _make_app(
168
+ cors_allowed_origins=["https://app.example.com"],
169
+ cors_allow_credentials=True,
170
+ )
171
+ client = TestClient(app, raise_server_exceptions=False)
172
+ r = client.get("/ok", headers={"Origin": "https://app.example.com"})
173
+ assert r.headers.get("access-control-allow-credentials") == "true"
174
+
175
+
176
+ def test_cors_request_id_still_present() -> None:
177
+ """CORS ミドルウェアと X-Request-Id が共存する。"""
178
+ app = _make_app(cors_allowed_origins=["https://app.example.com"])
179
+ client = TestClient(app, raise_server_exceptions=False)
180
+ r = client.get("/ok", headers={"Origin": "https://app.example.com"})
181
+ assert "x-request-id" in r.headers
182
+
183
+
184
+ def test_cors_security_headers_still_present() -> None:
185
+ """CORS ミドルウェアとセキュリティヘッダーが共存する。"""
186
+ app = _make_app(cors_allowed_origins=["https://app.example.com"])
187
+ client = TestClient(app, raise_server_exceptions=False)
188
+ r = client.get("/ok", headers={"Origin": "https://app.example.com"})
189
+ assert r.headers.get("x-content-type-options") == "nosniff"
@@ -925,7 +925,7 @@ wheels = [
925
925
 
926
926
  [[package]]
927
927
  name = "nene2-python"
928
- version = "1.8.26"
928
+ version = "1.8.27"
929
929
  source = { editable = "." }
930
930
  dependencies = [
931
931
  { name = "alembic" },
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes