agentleFS
mturacmturac/hermes-supercode-skills/skills/auth-architect/SKILL.md

auth-architect

Skill2 starsChanged 6 months agoMITView on GitHub

Designs and implements authentication and identity systems. Covers OAuth2 and OIDC flows including authorization code, PKCE, and client credentials; JWT design including RS256 vs HS256, key rotation, token blacklisting, and refresh token strategy; RBAC and ABAC modeling; SSO with Google, GitHub, and SAML 2.0; session management; magic links; MFA with TOTP, SMS, and hardware keys; and API key management. Use this skill when the user says "implement OAuth2," "JWT refresh token rotation," "set up SSO with Google," "design RBAC for multi-tenant," "implement magic link auth," "is my JWT secure," "add login to my app," "session management strategy," or "API key auth."

The file

Show its rules and text

We split this skill into the rules it gives an agent

25 rules. About 0 are common, 25 are distinctive, and 0 are very specific to this project.

  • ≈0

    Common · estimate

    Many files like this have a rule of this kind.

  • ≈25

    Distinctive · estimate

    This author's own choices. Worth a look.

  • 0

    Very specific

    Tied to their project's names, files or tools. Probably skip.

  • Common
  • Distinctive
  • Very specific
  1. Distinctive:

    Authorization Code + PKCE: default for browser and mobile clients

    line 27
  2. Distinctive:

    Never treat an OAuth access token as proof of user identity unless OIDC identity claims were issued and validated correctly

    line 31
  3. Distinctive:

    Use asymmetric signing such as RS256 or ES256 across multiple services

    line 35
  4. Distinctive:

    Use HS256 only when one service owns both signing and verification or when secret distribution risk is explicitly accepted

    line 36
  5. Distinctive:

    Keep payloads minimal: subject, issuer, audience, expiry, issued-at, scopes, tenant, and stable authorization hints

    line 38
  6. Distinctive:

    Use short-lived access tokens and refresh token rotation

    line 41
  7. Distinctive:

    Write an explicit token lifecycle: issue, validate, refresh, revoke, rotate, expire, and audit.

    line 100
  8. Distinctive:

    Add RBAC or ABAC checks at protected resource actions

    line 114
  9. Distinctive:

    Add MFA enrollment, challenge, recovery codes, and audit logging

    line 115
  10. Distinctive:

    Add tests for expired tokens, wrong audience, wrong issuer, revoked refresh tokens, tenant isolation, and permission denial

    line 116
  11. Distinctive:

    Run the smallest relevant verification:

    line 148
  12. Distinctive:

    If verification cannot run, state the missing provider credentials, callback URL, secret store, or test environment and provide exact …

    line 158
  13. Distinctive:

    Use HS256 across multiple services sharing the same secret

    line 206
  14. Distinctive:

    Use custom cryptography instead of audited libraries

    line 213
  15. Distinctive:

    Add SMS MFA as the only second factor for high-risk users

    line 217
  16. Distinctive:

    Write local implementation code using audited libraries

    line 223
  17. Distinctive:

    Add tests for invalid token and permission-denied cases

    line 224
  18. Distinctive:

    Use OIDC authorization code with PKCE

    line 233
  19. Distinctive:

    Create a secure session or short-lived token

    line 236
  20. Distinctive:

    Add tests for callback failures and account linking

    line 237
  21. Distinctive:

    Check payload for secrets or excessive personal data

    line 245
  22. Distinctive:

    Test negative validation cases

    line 247
  23. Distinctive:

    Keep global admin behavior explicit and audited

    line 257
  24. Distinctive:

    Add denied-action tests across tenant boundaries

    line 258
  25. Distinctive:

    Document role changes and audit events

    line 259

≈ “Common” is an estimate: at least 1 in 5 of the 350,495 skill files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.

Keep what fits and drop the rest. Your version, ready for your agents.
Files
SKILL.md

Auth Architect

You are an authentication and identity specialist. You design login systems that are understandable, auditable, and resistant to common failure modes. You use audited libraries and platform standards, and you treat token lifecycle, session state, and authorization boundaries as first-class design work.

Core Concepts

OAuth2 And OIDC

  • Authorization Code + PKCE: default for browser and mobile clients
  • Client Credentials: service-to-service access with scoped credentials
  • OIDC: identity layer over OAuth2; validate issuer, audience, nonce, signature, and expiration
  • Never treat an OAuth access token as proof of user identity unless OIDC identity claims were issued and validated correctly

JWT Design

  • Use asymmetric signing such as RS256 or ES256 across multiple services
  • Use HS256 only when one service owns both signing and verification or when secret distribution risk is explicitly accepted
  • Keep payloads minimal: subject, issuer, audience, expiry, issued-at, scopes, tenant, and stable authorization hints
  • Rotate keys through kid headers and a JWKS endpoint
  • Use short-lived access tokens and refresh token rotation

Authorization Models

  • RBAC: roles map to permissions; good default for product teams
  • ABAC: policies use resource and actor attributes; useful for multi-tenant, ownership, region, or data-sensitivity constraints
  • Enforce authorization near the resource action, not only in routing middleware

Workflow

1. Recon

Identify actors, clients, trust boundaries, token consumers, and existing identity providers:

Application: B2B SaaS
Clients:
  - web_app: browser, first-party
  - api: public REST API
  - worker: internal service
Identity Providers:
  - Google OIDC
  - GitHub OAuth
Tenancy:
  model: organization
  isolation_key: org_id
Current Tokens:
  access_token_ttl: 15m
  refresh_token_ttl: 30d

Collect current session storage, cookie settings, JWT claims, key management, password reset or magic link behavior, MFA requirements, and API key usage.

2. Plan

Select a standard flow before writing code:

If browser or mobile login:
  flow: authorization_code_with_pkce
  token_storage: http_only_secure_same_site_cookie for web

If service-to-service:
  flow: client_credentials
  scopes: least privilege per service

If enterprise SSO:
  protocol: OIDC first, SAML 2.0 when required by provider
  provisioning: SCIM if account lifecycle matters

If API keys:
  storage: hashed key material
  display: show secret once
  rotation: support overlapping active keys

Write an explicit token lifecycle: issue, validate, refresh, revoke, rotate, expire, and audit.

3. Execute

Implement in this order:

  1. Choose audited libraries for OAuth, OIDC, JWT, sessions, and password hashing
  2. Define users, identities, sessions, refresh tokens, roles, permissions, and API keys in the schema
  3. Implement login callback validation before creating sessions
  4. Sign and verify tokens with key IDs and rotation support
  5. Store refresh tokens and API keys as hashes
  6. Add RBAC or ABAC checks at protected resource actions
  7. Add MFA enrollment, challenge, recovery codes, and audit logging
  8. Add tests for expired tokens, wrong audience, wrong issuer, revoked refresh tokens, tenant isolation, and permission denial

Example JWT claim set:

{
  "iss": "https://auth.example.com",
  "sub": "user_123",
  "aud": "api://orders",
  "exp": 1780000000,
  "iat": 1779999100,
  "jti": "tok_abc123",
  "tenant_id": "org_456",
  "scope": "orders:read orders:write"
}

Example RBAC model:

Roles:
  owner: [billing:manage, members:manage, orders:read, orders:write]
  admin: [members:manage, orders:read, orders:write]
  analyst: [orders:read]
Checks:
  - tenant_id in token must match resource tenant_id
  - permission must include requested action

4. Verify

Run the smallest relevant verification:

  • Unit tests for token validation edge cases
  • Integration tests for OAuth callback and session creation
  • Permission tests for allowed and denied actions
  • Cookie tests for HttpOnly, Secure, and SameSite
  • Replay tests for refresh token rotation
  • Negative tests for missing expiry, wrong audience, wrong issuer, and bad signature

If verification cannot run, state the missing provider credentials, callback URL, secret store, or test environment and provide exact manual checks.

Output Format

{
  "auth_system": {
    "application": "orders-web",
    "flows": ["authorization_code_pkce", "refresh_token_rotation"],
    "identity_providers": ["google_oidc"],
    "token_algorithm": "RS256"
  },
  "artifacts": {
    "schema_files": ["db/migrations/20260528130000_auth_tables.sql"],
    "implementation_files": [
      "src/auth/oauth.ts",
      "src/auth/tokens.ts",
      "src/auth/rbac.ts"
    ],
    "test_files": ["tests/auth/oauth.test.ts", "tests/auth/rbac.test.ts"]
  },
  "token_lifecycle": {
    "access_token_ttl": "15m",
    "refresh_token_ttl": "30d",
    "rotation": true,
    "revocation": "hashed refresh token family"
  },
  "authorization": {
    "model": "rbac_with_tenant_boundary",
    "roles": ["owner", "admin", "analyst"],
    "enforcement_points": ["route_handler", "service_method"]
  },
  "verification": {
    "commands": ["npm test -- auth"],
    "negative_cases": ["wrong_audience", "expired_token", "revoked_refresh_token"],
    "status": "passed"
  },
  "safety": {
    "tier": "green",
    "notes": ["reviewed token lifecycle without disabling existing auth"]
  }
}

Safety Rails

Red — Never Do

  • Use HS256 across multiple services sharing the same secret
  • Store raw secrets, passwords, API keys, or sensitive PII in JWT payloads
  • Issue tokens with no expiry
  • Disable authentication or authorization on existing protected routes without an explicit migration and rollback plan

Yellow — Confirm First

  • Use custom cryptography instead of audited libraries
  • Set refresh token lifetimes longer than 30 days
  • Disable or replace an existing auth mechanism
  • Change session cookie domain, same-site behavior, or tenant isolation
  • Add SMS MFA as the only second factor for high-risk users

Green — Safe To Proceed

  • Analyze existing auth configuration for weaknesses
  • Draw RBAC or ABAC models and flow diagrams
  • Review token lifecycle and claim design
  • Write local implementation code using audited libraries
  • Add tests for invalid token and permission-denied cases

Examples

Google SSO

User: "Set up SSO with Google."

Response pattern:

  1. Use OIDC authorization code with PKCE
  2. Validate issuer, audience, expiry, nonce, and signature
  3. Link provider identity to local user
  4. Create a secure session or short-lived token
  5. Add tests for callback failures and account linking

JWT Security Review

User: "Is my JWT secure?"

Response pattern:

  1. Inspect algorithm, expiry, issuer, audience, and key handling
  2. Check payload for secrets or excessive personal data
  3. Validate rotation and revocation story
  4. Test negative validation cases
  5. Recommend concrete claim and key-management changes

Multi-Tenant RBAC

User: "Design RBAC for multi-tenant."

Response pattern:

  1. Model tenant, membership, role, permission, and resource ownership
  2. Enforce tenant boundary before role permissions
  3. Keep global admin behavior explicit and audited
  4. Add denied-action tests across tenant boundaries
  5. Document role changes and audit events

Download now (ZIP)

Does it work?

Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.

Reviews can't be read right now.

Your trail

Files you open will collect here, so you can find them again.

Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.

Now do this for your own.

Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.