Chuyển đến nội dung
Skillpedia
Bảo mật41k · #6674

auth-implementation-patterns

Skill này làm gì

Công cụ này giúp bạn hiểu và triển khai các cách an toàn để xác minh người dùng là ai (xác thực) và họ được làm gì trong hệ thống (phân quyền). Nội dung bao gồm mật khẩu, đăng nhập qua mạng xã hội và kiểm soát truy cập theo nhóm.

Khi nào nên dùng

  • ✓Khi bạn tạo hệ thống đăng nhập cho một website hoặc ứng dụng.
  • ✓Khi bạn cần bảo vệ quyền truy cập vào dữ liệu hoặc tính năng.
  • ✓Khi bạn muốn hiểu vì sao một người dùng không truy cập được một thứ gì đó.

Liên kết skill

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

Sao chép rồi dán vào AI của bạn (Claude, ChatGPT hoặc Cursor) và nhờ nó làm theo hướng dẫn.

Cách dùng

Cách dễ nhất: sao chép tin nhắn và dán vào AI của bạn. AI sẽ đọc skill và làm theo hướng dẫn.

Tin nhắn có sẵn để dán

Hãy dùng skill này để giúp tôi: https://github.com/wshobson/agents/blob/main/plugins/developer-essentials/skills/auth-implementation-patterns/SKILL.md Đọc tệp SKILL.md tại liên kết đó và làm theo hướng dẫn cho việc của tôi.
Bạn muốn AI tự tìm những skill như thế này?Cài MCP Skillpedia miễn phí: chỉ một dòng, và AI sẽ tìm trong 15.000+ skill trước mỗi việc.Cài đặt trong 1 phút →

Ví dụ cách nhờ AI

“Làm thế nào để chỉ quản trị viên mới xem được một số báo cáo nhất định?”

5 skill mới mỗi tuần. Đọc chỉ 1 phút.

Cách hoạt động

Công cụ giải thích các khái niệm như xác thực (bạn là ai) và phân quyền (bạn được làm gì). Nó hướng dẫn các mẫu như dùng token (JWT) hoặc session để quản lý quyền truy cập và đưa ra các lưu ý bảo mật.

Nội dung kỹ thuật (SKILL.md gốc)

Lấy nguyên văn từ GitHub, do tác giả viết bằng tiếng Anh.

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
Câu hỏi thường gặp

Sự khác nhau giữa xác thực và phân quyền là gì?

Xác thực là chứng minh bạn là ai (ví dụ bằng tên người dùng và mật khẩu). Phân quyền là những gì bạn được phép làm sau khi đã chứng minh danh tính (ví dụ xem hoặc chỉnh sửa một thứ gì đó).

JWT là gì?

JWT (JSON Web Token) là cách gửi thông tin an toàn giữa các bên, giống như một “thẻ thông hành” mà người dùng nhận sau khi đăng nhập. Hệ thống dùng thẻ này để biết người dùng là ai mà không cần kiểm tra cơ sở dữ liệu mỗi lần.

Tại sao không nên lưu mật khẩu dạng văn bản thường?

Lưu mật khẩu dạng văn bản thường rất nguy hiểm. Nếu có kẻ xâm nhập hệ thống, chúng sẽ có toàn bộ mật khẩu. Mật khẩu cần được “băm” (hash) để không thể đọc được.

Chi tiết

Mô tả gốc của tác giả

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

Độ phổ biến

Sao GitHub
41k
Vị trí xếp hạng
#6674
Giấy phép
MIT
Cập nhật
15/10/2026

Skill này có hữu ích không?

0

Đăng nhập để bình chọn.

Bình luận

  • …

Thêm skill từ kho mã này

Skill tương tự