- Admin: refund/cancel/mark-resolved/Bazaar-link actions need change permission; question and curriculum import need add/delete; content browser needs view_question; guest device ids are shown to superusers only. - Accounts: registering a guest's phone revokes the guest's earlier sessions; self-deletion keeps Redemption, UserOffer and the phone's OTP rows; the public demo guest cannot be deleted (DEMO_GUEST_DEVICE_IDS); display-name contact filter covers any separator and social handles. - Payment: callback without Authority is 400; a second Bazaar purchase on a paid order is 409; orders snapshot credits/hearts/days at creation (payment.0011). - Assistant: a broken diagram no longer makes a streamed answer free; a late off-topic marker refuses the answer (not stored, not cached); a disconnect saves the partial answer; only KNOWN_COLLECTIONS are searched. - Infra: secret-key file is created atomically (workers no longer split keys); no default INTERNAL_SERVICE_KEY; Kavenegar key and Bazaar token kept out of error logs; Swagger/ReDoc pinned; schema throttled; docker compose bound to 127.0.0.1; non-ASCII digit ids are 400; ticket text capped at 5000. - docs/security-before-production.md: remaining open items 24-31 and the guard tests. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2.0 KiB
2.0 KiB
استکِ محلیِ Docker
docker-compose.yml اپ را بههمراه یک استکِ لاگِ متمرکز اجرا میکند
(Loki + Grafana Alloy + Grafana).
این یک تنظیمِ توسعه/محلی است، نه دیپلویِ پروداکشن: سرویسِ
djangoهمچنانrunserverرا اجرا میکند، نه یک سرورِ WSGI. پروداکشنِ واقعی رویgunicornبا systemd بالا میآید —operations.mdرا ببینید.
cp .env.example .env # اختیاری — بدونش از پیشفرضهای dev استفاده میکند
docker compose up --build
| سرویس | آدرس | توضیح |
|---|---|---|
| اپ Django | http://localhost:8000 |
|
| Grafana | http://localhost:3000 |
دسترسیِ anonymous فقط با نقشِ Viewer، فقط روی خودِ لپتاپ (127.0.0.1) |
| Loki | http://localhost:3100 |
ذخیرهسازیِ لاگ، در معرضِ کاربر نیست |
| Alloy | http://localhost:12345 |
رابطِ دیباگِ اختیاری |
ترتیبِ بالا آمدن
Compose خودش مدیریتش میکند:
- اول
loki. alloyوgrafanaبعد از آن (depends_on).djangoهیچ وابستگیای به استکِ لاگ ندارد — خودشmigrateو بعدrunserverرا اجرا میکند و منتظرِ هیچکدام نمیماند.
اجرای فرمانها داخلِ کانتینر
اگر فقط از Docker استفاده میکنید (بدونِ venv محلی)، python manage.py ... را
روی سیستمِ خودتان اجرا نکنید — باید داخلِ کانتینرِ django اجرا شود:
docker compose exec django python manage.py createsuperuser
docker compose exec django python manage.py seed_test_data
docker compose exec django python manage.py test
migrate استثناست: طبقِ بالا خودکار پیش از runserver اجرا میشود.