auth

Implement authentication and authorization with OAuth2, JWT, and RBAC/ABAC.

53|1|Updated Dec 18, 2025
One-click install
npx skills add https://github.com/cosmix/claude-code-setup --skill auth-cosmix
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: auth
Source: https://github.com/cosmix/claude-code-setup/tree/main/skills/auth
Command: npx skills add https://github.com/cosmix/claude-code-setup --skill auth-cosmix

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

This Skill covers OAuth2, JWT, RBAC/ABAC, session management, API keys, password hashing, and MFA patterns for secure access control.

Core Features & Use Cases

  • Token & Session Management: Access/refresh tokens, session lifecycles.
  • RBAC/ABAC: Role-based and attribute-based access controls.
  • MFA & Password Security: MFA setup and secure password handling.

Quick Start

Implement a JWT-based login flow with refresh tokens and a role-based access check on a protected endpoint.

Frequently Asked Questions about auth

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I implement JWT-based authentication with refresh tokens?

JWT authentication uses digitally signed tokens to verify user identity. Issue a short-lived access token and a longer-lived refresh token on login; validate the access token on each request and use the refresh token to issue new access tokens when the original expires. This approach works across web, mobile, and API contexts without server-side session storage.

What's the difference between OAuth2 and session-based authentication?

OAuth2 is a delegated authorization standard where users authenticate via a third-party provider and receive tokens; session-based authentication stores user state server-side after login. OAuth2 suits multi-service architectures and third-party integrations, while sessions work well for single-application authentication.

How do I set up role-based access control on API endpoints?

Role-based access control (RBAC) assigns permissions to user roles and checks roles before allowing endpoint access. After authentication, extract the user's role from the token or session, verify it against required permissions for that endpoint, and return 403 Forbidden if unauthorized. This pattern scales to attribute-based control (ABAC) by checking multiple user attributes.

Do I need multi-factor authentication for all users?

MFA adds security by requiring a second verification factor beyond the password, such as a time-based code or hardware key. Implement MFA as optional for standard users and mandatory for privileged accounts. Most applications support MFA on login or sensitive operations to balance security and user friction.

How do I securely handle password storage and API keys?

Hash passwords using a modern algorithm like bcrypt or Argon2; never store plaintext passwords. For API keys, generate cryptographically secure random strings, hash them on storage, and transmit only over HTTPS. Rotate keys regularly and revoke compromised keys immediately to limit exposure.

What's PKCE and when do I need it for OAuth2?

PKCE (Proof Key for Code Exchange) prevents authorization code interception in public clients like mobile apps and single-page applications. The client generates a code verifier, derives a challenge, and sends both during the OAuth2 flow to ensure only the legitimate client can exchange the code for tokens.