areas/software/security/skills/auth-patterns/SKILL.md
# Skill: Authentication & Authorization Patterns ## When to load When implementing login, token management, OAuth integration, RBAC, or reviewing auth code. ## JWT Best Practices ```python def create_access_token(user_id: str) -> str: return jwt.encode( payload={ "sub": user_id, "iat": datetime.utcnow(), "exp": datetime.utcnow() + timedelta(minutes=15), # Short expiry "jti": str(uuid.uuid4()), # Unique ID for revocation
npx skillsauth add sawrus/agent-guides areas/software/security/skills/auth-patternsInstall this skill globally with one command. Works with Claude Code, Cursor, and Windsurf.
3 of 9 scanners reported clean
Some scanners were skipped, did not run, or reported a non-clean status. Review each row below.
When implementing login, token management, OAuth integration, RBAC, or reviewing auth code.
def create_access_token(user_id: str) -> str:
return jwt.encode(
payload={
"sub": user_id,
"iat": datetime.utcnow(),
"exp": datetime.utcnow() + timedelta(minutes=15), # Short expiry
"jti": str(uuid.uuid4()), # Unique ID for revocation
"type": "access", # Prevent refresh token as access token
},
key=settings.JWT_PRIVATE_KEY,
algorithm="RS256", # Asymmetric. Never HS256 in distributed systems.
)
Anti-patterns: No exp claim; storing JWT in localStorage; using alg: none; sensitive data in payload.
PERMISSIONS = {
"invoices:read": ["viewer", "editor", "admin"],
"invoices:create": ["editor", "admin"],
"invoices:delete": ["admin"],
}
def require_permission(permission: str):
def dependency(current_user: User = Depends(get_current_user)):
allowed_roles = PERMISSIONS.get(permission, [])
if current_user.role not in allowed_roles:
raise HTTPException(status_code=403)
return current_user
return dependency
testing
QA Expert for writing E2E tests, test scenarios, test plans, and ensuring test coverage quality.
development
Expert UI/UX design intelligence for creating distinctive, high-craft, and mobile-first interfaces. Focuses on premium aesthetics, touch-first ergonomics, and Flutter performance.
development
Code Review Expert for static analysis, security auditing, architecture review, and ensuring code quality standards.
development
Babysit a GitHub pull request after creation by continuously polling review comments, CI checks/workflow runs, and mergeability state until the PR is merged/closed or user help is required. Diagnose failures, retry likely flaky failures up to 3 times, auto-fix/push branch-related issues when appropriate, and keep watching open PRs so fresh review feedback is surfaced promptly. Use when the user asks Codex to monitor a PR, watch CI, handle review comments, or keep an eye on failures and feedback on an open PR.