
تدقيق المصالحة لتكامل Alliance Auth مع Discord: يجد أعضاء الخادم الذين يحملون أدوارًا مُدارة بواسطة AA لم يمنحها Auth، ويقوم بإزالتها أو طردهم وفق سياسة يتحكم بها المشغل. تطبيق Django مستقل للمجتمع.
تدقيق تسوية لتكامل Discord في Alliance Auth. يقارن تعيينات الأدوار الفعلية في خادم Discord المُهيَّأ مقابل الحالة المعبَّر عنها في Alliance Auth (المجموعات + الحالة لكل مستخدم) ويسدّ الثغرة التي يمكن من خلالها للمشرفين تعيين أدوار تحمل اسم AA يدويًا لمستخدمين لا يعرفهم AA.
الحالة: ألفا (
0.1.x). قد تظل واجهة البرمجة العامة والإعدادات عرضة للتغيير قبل1.0.
التدقيق آمن افتراضيًا:
InitialAuditAcknowledgement (للمشرف أو عبر shell فقط).report لكل فئة — الإجراءات التدميرية
اختيارية.AuditRun، AuditFinding، AuditInvocation،
ConfigChangeLog) للإضافة فقط على مستوى المدير والنسخة؛
عمليات update() / bulk_update() الجماعية محظورة.يُصنَّف كل عضو في الخادم ضمن فئة واحدة:
| الفئة | المعنى |
|---|---|
unknown_guest | عضو Discord لا يعرف عنه AA شيئًا |
linked_no_perm | الهوية معروفة لـ AA لكنها تفتقر إلى discord.access_discord |
bot_filtered | بوت مُدرَج أو مُعلَّم من Discord - لا يُتخذ أي إجراء بحقه |
يُسند المشغّل كل فئة إلى إجراء واحد:
| الإجراء | السلوك |
|---|---|
report | تسجيل النتيجة؛ دون أي تغيير على جانب Discord |
strip | إزالة الأدوار المُدارة بواسطة AA |
strip_kick | إزالة الأدوار المُدارة بواسطة AA، ثم الطرد من الخادم |
يطرد strip_kick فقط الأعضاء المرتبطين بمستخدم AA (linked_no_perm).
لا يملك unknown_guest مستخدم AA لتسليم الطرد إليه: تُزال أدواره
المُدارة بواسطة AA ويبقى العضو في الخادم.
التعيين هو إعداد AA_DISCORD_AUDIT_POLICY؛ التجاوزات لكل مجموعة
ولكل حالة تتفرّع داخل كل فئة.
allianceauth.services.modules.discord) مثبَّتة ومُهيَّأة
(bot token + guild)pip install aa-discord-audit
في ملف local.py الخاص بـ Auth لديك:
# `aa_discord_audit` must appear AFTER
# `allianceauth.services.modules.discord` so the discord module's
# models load first; `apps.ready()` raises `ImproperlyConfigured`
# otherwise.
INSTALLED_APPS += ["aa_discord_audit"]
MIDDLEWARE += [
"aa_discord_audit.current_user.CurrentUserMiddleware",
]
ثم شغّل عمليات الترحيل:
python manage.py migrate aa_discord_audit
CurrentUserMiddleware إلزامي — يرفع apps.ready() استثناء
ImproperlyConfigured إذا كان مفقودًا. فهو ما يسمح لمعالج إشارة
ConfigChangeLog بنسبة تعديلات المشرفين إلى مستخدم حقيقي
بدلاً من <system>.
امنح aa_discord_audit.run_audit لدور المشغّل الذي يشغّل
عمليات التدقيق.
شغّل تدقيقًا تجريبيًا:
python manage.py audit_discord_roles --action report
راجع النتائج ضمن Discord Audit → Audit runs في لوحة تحكم Auth.
حرّر قفل التشغيل الأول — إما بإنشاء صف
InitialAuditAcknowledgement عبر لوحة الإدارة، أو بتشغيل
python manage.py audit_acknowledge_initial. يتطلب كلاهما
aa_discord_audit.run_audit و
aa_discord_audit.acknowledge_initial_audit.
أعد التشغيل باستخدام الإجراء التدميري الذي تختاره عندما تكون مستعدًا.
| الاسم الرمزي | يتحكم في |
|---|---|
aa_discord_audit.run_audit | أمر الإدارة، مهمة beat، حذف التشغيل |
aa_discord_audit.run_audit_destructive | بوابة الإطلاق عبر الويب لـ strip / strip_kick (منفصلة عن run_audit) |
aa_discord_audit.acknowledge_initial_audit | تحرير قفل التشغيل التجريبي الأول |
aa_discord_audit.manage_discord_identity | لوحة إدارة DiscordIdentity |
aa_discord_audit.manage_role_exception | لوحة إدارة ManagedRoleException |
aa_discord_audit.manage_protected_member | لوحة إدارة ProtectedDiscordMember |
aa_discord_audit.manage_bot_account_uid | لوحة إدارة BotAccountUid |
aa_discord_audit.manage_finding_override | لوحة إدارة FindingActionOverride |
aa_discord_audit.view_auditrun (وما شابهها) | سجل تدقيق للقراءة فقط في لوحة تحكم Auth |
أسماء manage_* الرمزية مقسّمة حسب نطاق التأثير بحيث لا يستطيع موظف مبتدئ يملك
manage_bot_account_uid أن يعطّل التدقيق أيضًا عبر تعديل
ManagedRoleException.
جميع الإعدادات اختيارية. القيم الافتراضية آمنة.
# Action policy. Bare-string form below is shorthand for
# {"default": "<action>"}; use the nested form for per-group / per-state
# overrides keyed by AA group name and state name.
AA_DISCORD_AUDIT_POLICY = {
"unknown_guest": "report",
"linked_no_perm": "report",
# "strip" is rejected at startup for linked_no_perm (it conflicts with
# AA's update_groups task); use "strip_kick" instead.
# "linked_no_perm": {
# "default": "strip_kick",
# "by_state": {"Guest": "report"},
# "by_group": {"Directors": "report"},
# },
}
# AA-notify fan-out to permission holders.
AA_DISCORD_AUDIT_NOTIFY_ADMINS = True
# Discord webhook for run summaries. Treat as a credential.
AA_DISCORD_AUDIT_WEBHOOK_URL = None
# uids skipped as bot accounts (in addition to the BotAccountUid admin
# table).
AA_DISCORD_AUDIT_BOT_UIDS = []
# Auto-discover bot accounts by Discord nickname heuristics. Reserved
# for v2; not implemented in the MVP. The startup validator raises
# ImproperlyConfigured if set to True — keep this False and use the
# explicit BotAccountUid admin table instead.
AA_DISCORD_AUDIT_AUTO_DISCOVER_BY_NICKNAME = False
# Retention. 0 disables pruning; the validator refuses 0 unless the
# acknowledged flag below is also set.
AA_DISCORD_AUDIT_RUN_RETENTION_DAYS = 180
AA_DISCORD_AUDIT_RETENTION_OPT_OUT_ACKNOWLEDGED = False
# Idempotency-key TTL. When positive, prune_audit_runs releases
# AuditRun.idempotency_key on rows older than the cutoff while the
# row itself stays for RUN_RETENTION_DAYS. 0 (default) disables the
# expiry; the key dies with the row.
AA_DISCORD_AUDIT_IDEMPOTENCY_KEY_TTL_DAYS = 0
# Per-run deadline. The Celery task's soft_time_limit follows. Sizing
# against the Discord rate limit: see "Run deadline and the Discord
# rate limit" below.
AA_DISCORD_AUDIT_RUN_DEADLINE_MINUTES = 60