fix: accept civitai.red as an allowed CivitAI host#436
Conversation
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Organization UI Review profile: ASSERTIVE Plan: Pro Run ID: 📒 Files selected for processing (3)
📝 WalkthroughWalkthroughExtends Civitai URL validation to accept configured hostnames (adds Changes
🚥 Pre-merge checks | ✅ 2✅ Passed checks (2 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
✨ Simplify code
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
civitai.red is an official Civitai domain (NSFW-inclusive front door to the same accounts, database, and REST API as civitai.com). Previously the host allowlist only matched civitai.com, so the configured CivitAI API token was never attached to civitai.red downloads and gated content failed with 401. Lift the allowed hosts to a single CIVITAI_ALLOWED_HOSTS constant in constants.py and use it for both exact-match and subdomain-suffix checks. Adding future Civitai TLDs is now a one-line change. Anti-spoofing semantics (e.g. evilcivitai.red, civitai.red.evil.com) are preserved. Signed-off-by: Alexander Piskun <bigcat88@icloud.com>
fd6a468 to
9d832a1
Compare
Codecov Report✅ All modified and coverable lines are covered by tests. @@ Coverage Diff @@
## main #436 +/- ##
==========================================
+ Coverage 78.01% 78.02% +0.01%
==========================================
Files 35 35
Lines 4317 4319 +2
==========================================
+ Hits 3368 3370 +2
Misses 949 949
🚀 New features to boost your workflow:
|
Fixes #435
Summary
civitai.redis an official Civitai domain — the NSFW-inclusive front door that shares accounts, database, and REST API withcivitai.com(per Civitai's April 2026 announcement, Two Front Doors).check_civitai_url()hardcoded acivitai.com-only host allowlist, so the configured CivitAI API token was never attached tocivitai.reddownloads and gated content failed with 401.CIVITAI_ALLOWED_HOSTSconstant inconstants.pyand rewired the host check to use it for both exact-match and subdomain-suffix checks. Adding a future Civitai TLD is now a one-line change. Anti-spoofing semantics are preserved (evilcivitai.red,civitai.red.evil.com, etc. still rejected).The hardcoded
https://civitai.com/api/v1/...REST API URLs are intentionally left alone — Civitai's announcement states "the REST API continues to live on civitai.com and will also be accessible through civitai.red", so civitai.red users' tokens resolve correctly through the civitai.com API.Test plan
civitai.comcoverage oncivitai.red: web URL,/api/download/models/...,/api/v1/model-versions/...,www.subdomain, plus anti-spoof rejections forevilcivitai.redandcivitai.red.evil.com.civitai.com.evil.red,civitaired.com, uppercase hosts, deep subdomains) — all expected outcomes.pytest tests/comfy_cli/— 674 passed, 6 skipped, no regressions.ruff check .andruff format --check .— clean.