Skip to content
Back to skills

Authentication Authorization Skill

ASecurity

Implement authentication and authorization — OAuth2/OIDC, JWT, sessions, RBAC/ABAC, NextAuth/Auth.js, Passport.js, password hashing, CSRF.

  • 6 stars
  • 0 votes
  • 0 copies
  • 2 views
  • Added September 20, 2026
securitygonextjsfastapiapisecurity

Works with

  • api

Security analysis

A100/100

Scanned September 28, 2026

npx -y skills add darellchua2/opencode-config-template --skill authentication-authorization-skill --agent claude-code

Installs into .claude/skills of the current project.

Are you the author of Authentication Authorization Skill?

Add the live security badge to your README. It updates with every re-scan.

Security grade badge for Authentication Authorization Skill
[![Security: A — Skills Directory](https://www.skillsdirectory.com/api/skills/darellchua2-authentication-authorization-skill/badge)](https://www.skillsdirectory.com/skills/darellchua2-authentication-authorization-skill)

More formats (shields.io, HTML) on the badges page. Keep it an A: scan every change in CI with Pro.

Download with Pro
SKILL.md
---
name: authentication-authorization-skill
description: >-
  Implement authentication and authorization — OAuth2/OIDC, JWT, sessions,
  RBAC/ABAC, NextAuth/Auth.js, Passport.js, password hashing, CSRF.
license: Apache-2.0
compatibility: opencode
category: Security
---

## What I do

Implement authn/authz: OAuth2/OIDC flows, JWT lifecycle, sessions, RBAC/ABAC, framework integration, password hashing, CSRF. (This skill *implements*; `security-audit-skill` *audits*.)

## When to use me

Login/signup flows, OAuth social login, RBAC design, JWT management, NextAuth/Passport integration, API auth middleware, CSRF hardening, MFA.

**Related:** `security-audit-skill` (auditing/detection) · `civiltekk-api-spec-skill` `author` route (endpoint design) · `civiltekk-nextjs-skill` (route `scaffold` — scaffolding incl. auth).

## House patterns

**two-layer-keycloak-authorization** — Keycloak defense-in-depth: Layer 1 = coarse Policy Enforcer (route-level `/admin/*` requires role, method-level DELETE scopes); Layer 2 = fine-grained app-layer composite roles (ownership `user.ownOrg === resource.orgId`, tenant scoping). Layer 2 runs EVEN IF Layer 1 passes — the Policy Enforcer cannot enforce data-level authorization.

**one-policy-per-role-type** (provenance: betekk-keycloak/LEARNINGS) — in Keycloak Authorization Services, one policy per role type (`admin-policy`, `editor-policy`, …), composed at the permission level via `ALL`/`ANY`. If a policy condition checks more than one role type, split it — collapsed policies resist audits and grant unintended access when roles change.

**stateless-cookie-cache-maxage-match-session** — with JWE cookies, `cookieCache.maxAge` MUST be `>= session.cookie.maxAge`. If the decryption cache expires first, `findSession()` returns null and silently deletes the session — users logged out mid-session with no error. The cache is an optimization and must never terminate a session.

**chunked-cookie-secure-prefix-mismatch** — always use one shared cookie utility for set/get; never hand-roll `__Secure-`/`__Host-` prefix logic per module. Browsers silently drop `__Secure-` cookies without `Secure` (or over HTTP) and `__Host-` without `Path=/`+no Domain; one module writing `__Secure-session` while another reads `session` = session loss / CSRF mismatch.

**cookie-only-proxy-with-server-rbac** — in stateless mode the middleware's ONLY job is "does a session cookie exist?" (local check). Token refresh → `customSession`/JWT callback (once per session); RBAC → per-route server layouts or resolver guards (only when that route renders). Any `await fetch` in middleware adds 50–500 ms to EVERY navigation.
Detection: `rg 'export\s+(async\s+)?function\s+middleware' --type ts -A 30 | rg 'await|fetch|http'`

> Removed 2026-09: OAuth flow tables and NextAuth/Passport/FastAPI code walkthroughs, JWT structure/rotation scripts, RBAC middleware examples, password-policy tables, CSRF/session/cookie tutorial steps — standard auth knowledge the model carries; the five house patterns above are what this config actually learned (Keycloak layering, JWE cache lifetime, cookie prefixes, middleware budget).

Attribution

Is this your skill, or is something wrong with this listing? Request removal or report an issue. Author removals are honored within 72 hours.

Comments

Loading comments…