Skillpedia
الأمان41k · #6674

auth-implementation-patterns

ما الذي تفعله

تساعد هذه المهارة على فهم وتنفيذ طرق آمنة للتحقق من هوية المستخدم (التوثيق) وتحديد ما يحق له فعله في النظام (التفويض). وتغطي طرقًا مثل كلمات المرور وتسجيل الدخول عبر حسابات التواصل والتحكم في الوصول بحسب المجموعات.

متى تستخدمها

  • ✓عندما تنشئ نظام تسجيل دخول لموقع أو تطبيق.
  • ✓عندما تريد حماية الوصول إلى البيانات أو الميزات.
  • ✓عندما تحاول فهم سبب عدم تمكن مستخدم من الوصول إلى شيء ما.

رابط المهارة

https://github.com/wshobson/agents/blob/main/plugins/developer-essentials/skills/auth-implementation-patterns/SKILL.md

انسخه والصقه في الذكاء الاصطناعي الذي تستخدمه (Claude أو ChatGPT أو Cursor) واطلب منه اتباع التعليمات.

طريقة الاستخدام

أسهل طريقة: انسخ الرسالة والصقها في الذكاء الاصطناعي الذي تستخدمه. سيقرأ المهارة وينفّذ تعليماتها.

رسالة جاهزة للصق

استخدم هذه المهارة لمساعدتي: https://github.com/wshobson/agents/blob/main/plugins/developer-essentials/skills/auth-implementation-patterns/SKILL.md اقرأ ملف SKILL.md في هذا الرابط ونفّذ تعليماته لمهمتي.
تريد أن يجد الذكاء الاصطناعي مهارات مثل هذه بنفسه؟ثبّت خادم Skillpedia MCP المجاني: سطر واحد، ويبحث في 15,000+ مهارة قبل كل مهمة.ثبّته في دقيقة واحدة →

مثال على ما تطلبه من الذكاء الاصطناعي

“كيف أجعل تقارير معينة تظهر للمسؤولين فقط؟”

5 مهارات جديدة كل أسبوع. قراءة في دقيقة واحدة.

كيف تعمل

تشرح هذه المهارة مفاهيم مثل التوثيق (من أنت) والتفويض (ما الذي يحق لك فعله). وتعلّم أنماطًا مثل استخدام الرموز (JWT) أو الجلسات لإدارة الوصول، وتقدم نصائح أمنية.

المحتوى التقني (ملف SKILL.md الأصلي)

النص الأصلي من المؤلف، مباشرة من GitHub.

Authentication & Authorization Implementation Patterns

Build secure, scalable authentication and authorization systems using industry-standard patterns and modern best practices.

When to Use This Skill

  • Implementing user authentication systems
  • Securing REST or GraphQL APIs
  • Adding OAuth2/social login
  • Implementing role-based access control (RBAC)
  • Designing session management
  • Migrating authentication systems
  • Debugging auth issues
  • Implementing SSO or multi-tenancy

Core Concepts

1. Authentication vs Authorization

Authentication (AuthN): Who are you?

  • Verifying identity (username/password, OAuth, biometrics)
  • Issuing credentials (sessions, tokens)
  • Managing login/logout

Authorization (AuthZ): What can you do?

  • Permission checking
  • Role-based access control (RBAC)
  • Resource ownership validation
  • Policy enforcement

2. Authentication Strategies

Session-Based:

  • Server stores session state
  • Session ID in cookie
  • Traditional, simple, stateful

Token-Based (JWT):

  • Stateless, self-contained
  • Scales horizontally
  • Can store claims

OAuth2/OpenID Connect:

  • Delegate authentication
  • Social login (Google, GitHub)
  • Enterprise SSO

Detailed patterns and worked examples

Detailed pattern documentation lives in references/details.md. Read that file when the navigation tier above is insufficient.

Best Practices

  1. Never Store Plain Passwords: Always hash with bcrypt/argon2
  2. Use HTTPS: Encrypt data in transit
  3. Short-Lived Access Tokens: 15-30 minutes max
  4. Secure Cookies: httpOnly, secure, sameSite flags
  5. Validate All Input: Email format, password strength
  6. Rate Limit Auth Endpoints: Prevent brute force attacks
  7. Implement CSRF Protection: For session-based auth
  8. Rotate Secrets Regularly: JWT secrets, session secrets
  9. Log Security Events: Login attempts, failed auth
  10. Use MFA When Possible: Extra security layer

Common Pitfalls

  • Weak Passwords: Enforce strong password policies
  • JWT in localStorage: Vulnerable to XSS, use httpOnly cookies
  • No Token Expiration: Tokens should expire
  • Client-Side Auth Checks Only: Always validate server-side
  • Insecure Password Reset: Use secure tokens with expiration
  • No Rate Limiting: Vulnerable to brute force
  • Trusting Client Data: Always validate on server
الأسئلة الشائعة

ما الفرق بين التوثيق والتفويض؟

التوثيق هو إثبات من تكون (مثل اسم المستخدم وكلمة المرور). أما التفويض فهو ما يحق لك فعله بعد إثبات هويتك (مثل عرض شيء أو تعديله).

ما هو JWT؟

JWT (JSON Web Token) طريقة آمنة لإرسال المعلومات بين الأطراف، وهو مثل تصريح يحصل عليه المستخدم بعد تسجيل الدخول، ويستخدمه النظام ليعرف هويته دون الرجوع إلى قاعدة البيانات في كل مرة.

لماذا لا أحفظ كلمات المرور كنص عادي؟

حفظها كنص عادي خطير جدًا، لأنه إذا اختُرق النظام فسيحصل المهاجم على كل كلمات المرور. ويجب «تشفيرها» (hashing) لتصبح غير قابلة للقراءة.

التفاصيل

الوصف الأصلي من المؤلف

Master authentication and authorization patterns including JWT, OAuth2, session management, and RBAC to build secure, scalable access control systems. Use when implementing auth systems, securing APIs, or debugging security issues.

repo: wshobson/agents

الشعبية

نجوم GitHub
41k
الترتيب
#6674
الترخيص
MIT
آخر تحديث
15‏/10‏/2026

هل هذه المهارة مفيدة؟

0

سجّل الدخول للتصويت.

التعليقات

  • …

المزيد من المهارات من هذا المستودع

مهارات مشابهة