Skip to content

[FIX, TEMPLATE, CICD] harden generated secrets and auth, add Windows support (v1.5.2) - #93

Merged
bnbong merged 2 commits into
mainfrom
dev
Dec 1, 2026
Merged

bnbong merged 2 commits into
mainfrom
dev

Conversation

@bnbong

@bnbong bnbong commented Dec 1, 2026

Copy link
Copy Markdown
Owner

Requesting Merging

Description

v1.5.2 patch. Fixes security defaults in generated projects, makes fastkit init --config usable in CI, and adds Windows support with a windows-latest CI job.

A review of all 12 templates found that 11 generated projects did not git-ignore .env, three shipped a fixed public SECRET_KEY, and the fastapi-mcp MCP endpoint had no authentication. A follow-up audit for Windows found crashes on non-UTF-8 consoles and locales, and several commands that assumed POSIX paths.

Type of Change

  • BUG FIX
  • ADDING NEW TEMPLATE
  • FEATURE ADDED/UPDATED
  • HOTFIX
  • DELETING UNNECESSARY FEATURES
  • DOCUMENTATION & DEVOPS
  • Etc..

Test Environment

  • macOS (Apple Silicon), Python 3.12
  • pytest -m "not extended": 1790 passed, 13 skipped
  • Full suite with EncodingWarning from fastapi_fastkit as errors: 1878 passed, 13 skipped
  • C locale (LC_ALL=C, PYTHONUTF8=0): 1790 passed, 13 skipped
  • Simulated Windows (POSIX-only os / signal attributes removed): 1870 passed, 21 skipped
  • mypy src, black --check, isort --check: clean
  • Generated projects installed with uv and run end to end: 4 presets × 3 SQL databases × Alembic on/off (24 combinations), and 13 all-feature projects (startup, /metrics, CORS, production secret guard, generated tests, ruff 0.9.6)
  • mkdocs build: no warnings

Not verified on real Windows. test.yml runs on pull requests only, so the windows-latest job runs for the first time on this PR. Failures there are expected to need follow-up commits.

Major Changes

Security

  • Templates ship .env.example; init and startdemo create .env with a unique SECRET_KEY. Every template git-ignores .env and .env.*.
  • fastapi-mcp: the MCP endpoint now requires MCP_API_KEY or a JWT. Demo accounts are off unless ENABLE_DEMO_USERS=true.
  • fastapi-auth-jwt: refresh-token rotation is one transaction, so a token is usable once under concurrent requests.
  • Five templates and the generated auth modules (JWT, OAuth2, Session) refuse an example SECRET_KEY in production.
  • Generated CORS no longer allows every origin with credentials.

CLI

  • init --config never prompts, always creates ./<project_name>/, and exits 1 on failure. init exits 1 on an invalid name, an existing directory, or a generation failure.
  • uv, PDM and Poetry keep the template's pyproject.toml (requires-python >=3.12, [tool.*] tables) instead of replacing it.
  • Fixed generated projects that failed to start: Prometheus (minimal, single-module) and SQL databases without greenlet (now sqlalchemy[asyncio]).
  • Pagination no longer shadows the template's items list in classic-layered and domain-starter.
  • Generated pre-commit and ruff configs pass on a fresh project.

Windows / portability

  • Explicit UTF-8 and LF for all file I/O; console output no longer crashes on cp1252 / cp949.
  • deleteproject, runserver, package-manager calls and the template inspector handle Windows paths, read-only files and .cmd shims.
  • Templates ship .gitattributes; uvloop is skipped on Windows.

CI

  • test.yml: adds windows-latest (Python 3.12, 3.14) and an encoding-guard job.
  • template-security-scan.yml: reports Scanned: ok/total and fails when a scan did not complete.

Docs

  • CHANGELOG condensed for every version; upgrade notes for existing projects added.
  • English docs updated. The six translated locales are not re-synced; reference/translation-status lists the pages.

Screenshots (optional)

N/A

Etc

  • Required checks need renaming. Job names are now test (ubuntu-latest, py3.12) etc., plus encoding-guard. Update branch protection before merging if it lists the old names.
  • Behaviour changes that can affect scripts: init exit codes, --config always creating a new folder, in-place deployment refusing to overwrite without a terminal unless --yes is given.
  • startdemo exit codes are unchanged (still 0 on failure); planned for v1.6.0.
  • Version is not bumped in this PR.

@bnbong bnbong self-assigned this Dec 1, 2026
@bnbong bnbong added bug Something isn't working enhancement New feature or request template Add or editing a FastAPI template fix Fix or improve source codes labels Dec 1, 2026
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Dec 1, 2026 •

Copy link
Copy Markdown
Codex Review Summary: ✅ Completed

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-12-01T07:15:02.139834Z 38fdf8a PR opened
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@github-actions

github-actions Bot commented Dec 1, 2026 •

Copy link
Copy Markdown
Contributor

✅ Template Inspection Passed

All changed templates have been validated successfully.


Last updated: 2026-12-01T08:12:47.382Z

@codecov

codecov Bot commented Dec 1, 2026 •

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 99.22879% with 9 lines in your changes missing coverage. Please review.

Files with missing lines Patch % Lines
...tapi_fastkit/backend/package_managers/pyproject.py 98.63% 5 Missing ⚠️
src/fastapi_fastkit/backend/main.py 98.59% 3 Missing ⚠️
...fastapi_fastkit/fragments/main/setup/prometheus.j2 0.00% 1 Missing ⚠️

📢 Thoughts on this report? Let us know!

@bnbong
bnbong merged commit fb099a0 into main Dec 1, 2026
15 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working enhancement New feature or request fix Fix or improve source codes template Add or editing a FastAPI template

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant