fix(security): require auth token on partner & admin endpoints - #2
Open
devin-ai-integration[bot] wants to merge 1 commit into
Open
fix(security): require auth token on partner & admin endpoints#2devin-ai-integration[bot] wants to merge 1 commit into
devin-ai-integration[bot] wants to merge 1 commit into
Conversation
Adds fail-closed token auth (ADMIN_TOKEN / PARTNER_TOKEN via headers) to privileged endpoints that were fully unauthenticated: admin stats/orders/ refund and partner box-create/orders/redeem. Previously anyone could read all customer PII, issue refunds, and redeem codes. Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>
Author
🤖 Devin AI EngineerI'll be helping with this pull request! Here's what you should know: ✅ I will automatically:
Note: I can only respond to comments from users who have write access to this repository. ⚙️ Control Options:
|
wpalish
pushed a commit
that referenced
this pull request
Jul 16, 2026
…арточка); +контраст футера По UX-ревью: - #1 localStorage-нотис был плавающей центр-карточкой (читалось как «глюк» поверх секций) → тонкая полоса во всю ширину, приклеена к низу (над bottom-nav на мобиле, к краю на десктопе). Показ один раз (флаг ym_cookies уже был). - #6 контраст копирайта/FAQ-текста в футере поднят (.6→.78, .7→.82 opacity) — запас под WCAG AA. Уже было в коде: #4 срочность («🔥 осталось N» + окно выдачи), #7 соцсети на светлом --on-ink (не бледные). Требуют ассетов (отдельно): #2 превью карты, #3 логотипы партнёров/отзывы, #5 лого-марка, #8 PWA-бейджи. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Security scan of the codebase. The one critical issue was broken access control: every partner and admin endpoint was completely unauthenticated. Anyone on the internet could read all customer PII (name + phone) via
GET /admin/ordersandGET /partners/{id}/orders, issue arbitrary refunds viaPOST /admin/refund/{id}, mark orders redeemed viaPOST /redeem, and publish boxes as any partner viaPOST /boxes.This PR adds fail-closed, token-based auth to those endpoints. The customer-facing storefront (catalog, booking, payment, "my orders") stays public.
What changed
New
app/auth.pywith two header-based dependencies backed by env vars:Wired as
dependencies=[Depends(require_partner|require_admin)]on:POST /boxes,GET /partners/{id}/orders,POST /redeemGET /admin/stats,GET /admin/orders,POST /admin/refund/{id}Frontend (
index.html) prompts for the token when switching to the Partner/Admin tab, stores it inlocalStorage, and sends it as a header on every request (clears it on401).render.yamlgetsgenerateValue: truefor both tokens so prod is secure by default; README documents the scheme.Uses
secrets.compare_digest(constant-time) and fail-closed defaults so a misconfigured deploy denies rather than exposes.Scan results for the rest
db.pyare parameterized.esc(); QR SVG is server-generated.CORSMiddlewareconfigured, so default same-origin; not misconfigured.POST /admin/seedwas already gated bylocal_only.Follow-ups (not in this PR)
PARTNER_TOKENcurrently grants access to any partner's data; real per-partner credentials are a follow-up.>=ranges — consider pinning for supply-chain safety.Testing
tests/test_auth.py(addedhttpxforTestClient): storefront stays public; admin/partner endpoints return503when the env token is unset,401on missing/wrong token,200with the correct token.pytest— 13 passed.Link to Devin session: https://app.devin.ai/sessions/fe1a1300a37e40c2b18cc8f1793426c8
Requested by: @wpalish