- /api/payment/orders/{id}/pay requires the short-lived signature that paymentUrl carries;
without it (or with another order's) it is the same 404 as an unknown order
- Session.refresh_token stores the SHA-256 of the token; migration accounts.0007 hashes the
existing rows so tokens clients already hold keep working
- /api/leaderboard requires a token (guests have one); names of children were scrapable
- RAG mock only for `manage.py test`, not any command with an argument named "test"
- tools/loadtest: user factory, load generator, fake GapGPT+Qdrant, with method notes
- security-before-production.md lists only open items; closed ones become a guards table
with the tests that hold them. Comments describe current behaviour, not history
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
29 lines
1.2 KiB
Python
29 lines
1.2 KiB
Python
"""
|
|
Session.refresh_token از این به بعد هشِ SHA-256 است (accounts/models.py، hash_refresh_token).
|
|
ردیفهای موجود هش میشوند تا توکنهایی که کلاینتها در دست دارند همچنان کار کنند. از هش نمیشود
|
|
خودِ توکن را ساخت؛ برگرداندنِ این migration هشها را سرِ جایشان میگذارد و کدِ قبلی آنها را
|
|
نمیشناسد، یعنی هر کاربر یک بار دوباره وارد میشود.
|
|
"""
|
|
import hashlib
|
|
|
|
from django.db import migrations
|
|
|
|
|
|
def hash_existing(apps, schema_editor):
|
|
Session = apps.get_model('accounts', 'Session')
|
|
# اول مادی کردن، بعد نوشتن: کرسرِ بازِ SQLite وسطِ حلقهی نوشتن قفل میسازد (CLAUDE.md).
|
|
rows = list(Session.objects.values_list('id', 'refresh_token'))
|
|
for pk, raw in rows:
|
|
Session.objects.filter(pk=pk).update(refresh_token=hashlib.sha256(raw.encode()).hexdigest())
|
|
|
|
|
|
class Migration(migrations.Migration):
|
|
|
|
dependencies = [
|
|
('accounts', '0006_profile_birth_date_drop_parent_phone'),
|
|
]
|
|
|
|
operations = [
|
|
migrations.RunPython(hash_existing, migrations.RunPython.noop),
|
|
]
|