auth-implementation-patterns – skill Lập trình cho agent AI
Nắm vững các mẫu xác thực và phân quyền gồm JWT, OAuth2, quản lý session và RBAC để xây dựng hệ thống kiểm soát truy cập an toàn, có khả năng mở rộng. Dùng khi triển khai hệ thống auth, bảo vệ API hoặc gỡ lỗi vấn đề bảo mật.
Cài skill auth-implementation-patterns bằng một lệnh
Chọn công cụ bạn đang dùng, copy lệnh và dán vào terminal. Skill sẽ nằm trong thư mục skills của công cụ đó và sẵn sàng dùng ở phiên làm việc tiếp theo.
Claude Code
mkdir -p ~/.claude/skills && curl -fsSL https://skill.dn1nguoi.com/z/auth-implementation-patterns-c7225.tgz | tar xz -C ~/.claude/skills
Gọi trong Claude Code: /auth-implementation-patterns – rồi mô tả công việc bạn muốn làm.
Codex
mkdir -p ~/.codex/skills && curl -fsSL https://skill.dn1nguoi.com/z/auth-implementation-patterns-c7225.tgz | tar xz -C ~/.codex/skills
Gọi trong Codex: $auth-implementation-patterns – rồi mô tả công việc bạn muốn làm.
Hermes Agent
mkdir -p ~/.hermes/skills && curl -fsSL https://skill.dn1nguoi.com/z/auth-implementation-patterns-c7225.tgz | tar xz -C ~/.hermes/skills
Gọi trong Hermes Agent: /auth-implementation-patterns – rồi mô tả công việc bạn muốn làm.
DeepSeek
mkdir -p ~/.deepcode/skills && curl -fsSL https://skill.dn1nguoi.com/z/auth-implementation-patterns-c7225.tgz | tar xz -C ~/.deepcode/skills
Gọi trong DeepSeek: /auth-implementation-patterns – rồi mô tả công việc bạn muốn làm.
Nội dung SKILL.md
Nội dung SKILL.md gốc 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
Skill liên quan
- gh-address-comments – Hỗ trợ xử lý các comment review/issue trên PR GitHub đang mở của nhánh hiện tại bằng gh…
- ai-decision-authority – Phân loại quyết định marketing và GTM vào ba vùng quản trị AI (AI-Primary…
- gh-fix-ci – Dùng khi người dùng yêu cầu gỡ lỗi hoặc sửa các PR check thất bại chạy trên GitHub…
- debugging-and-error-recovery – Hướng dẫn gỡ lỗi có hệ thống để tìm nguyên nhân gốc. Dùng khi test thất bại, build hỏng…
- agentflow – Điều phối pipeline phát triển AI tự động qua bảng Kanban (Asana, GitHub Projects…
- agentic-actions-auditor – Kiểm toán workflow GitHub Actions về lỗ hổng bảo mật trong tích hợp AI agent, gồm Claude…
- agentic-test-audit – Kiểm toán bộ test pytest: mutant sống sót và code chưa được test, test flaky, test phụ…
- agentic-verify – Kiểm tra xem thay đổi Python có được test bắt được không: chạy mọi mutant của các dòng…