auth-implementation-patterns

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.

Author

Install

Hot:9

Download and extract to your skills directory

Copy command and send to OpenClaw for auto-install:

Download and install this skill https://openskills.cc/api/download?slug=sickn33-skills-auth-implementation-patterns&locale=en&source=copy

Authentication and Authorization Implementation Patterns Skill

Skill Overview


Master industry-standard implementation patterns for authentication and authorization, including JWT, OAuth2, session management, and RBAC, to help developers build secure and scalable access control systems.

Applicable Scenarios

1. Implementing User Authentication Systems


Use when you need to add complete user login, registration, and authentication features to an application. Supports scenarios ranging from simple username/password login to complex multi-factor authentication and social account logins.

2. Securing APIs


When developing REST or GraphQL APIs, used to design and implement secure authentication and authorization mechanisms to prevent unauthorized access and protect sensitive data and business logic.

3. Designing Permission Management Systems


Use when an application requires fine-grained access control; supports complex permission requirements such as role-based access control (RBAC), multi-tenant isolation, and resource-level permissions.

Core Features

Authentication Strategy Design and Implementation


Choose and implement appropriate authentication schemes based on business requirements: Sessions are suitable for traditional web applications, JWTs are suitable for stateless APIs, and OAuth2/OIDC are suitable for third-party login and single sign-on scenarios. Covers the full lifecycle including user registration, login, logout, and password reset.

Authorization Model Architecture Design


Design scalable authorization models that support various permission strategies such as role-based (RBAC) and attribute-based (ABAC). Clearly define permission checkpoints and where policies are enforced to ensure authorization logic is consistent and maintainable.

Security Best Practices and Troubleshooting


Guidance on key security practices such as secure key storage, token lifecycle management, and session security configuration. Helps diagnose and resolve common authentication and authorization issues, such as token expiration, permission denials, and cross-origin authentication.

Frequently Asked Questions

Which authentication method should be chosen: JWT or Sessions?


JWTs are suitable for stateless distributed systems and mobile apps; they do not require server-side storage but cannot be proactively revoked. Sessions are suitable for traditional web applications; state is managed on the server and can be invalidated proactively, but require shared storage. In real projects, choose based on factors such as the need for immediate revocation, system complexity, and team experience.

How to implement secure OAuth2 third-party login?


Recommend using the Authorization Code flow. The complete process includes: redirect the user to the authorization server → after the user consents, obtain an authorization code → the backend service exchanges the code for an access token → use the token to fetch user information. Important security points: use the state parameter to prevent CSRF, use the PKCE extension to prevent interception, store tokens securely, and refresh them regularly.

How to design an RBAC permission model to support complex business requirements?


The core is to decouple the user-role and role-permission relationships. Recommended design: users can have multiple roles, role inheritance supports hierarchical structures, and permissions are broken down into operations (create, read, update, delete) + resources (data scope). Use the strategy pattern to support different resource permission checking logic and leave extension points to support more complex ABAC needs in the future.