clerk-sessions-webhooks-security
БесплатноБез исполняемых скриптовНе проверенUse for Clerk sessions, tokens, webhooks, orgs, and security. PROACTIVELY activate for session tokens, JWT templates, getToken(), custom claims, pending…
от JosiahSiegel★ 67 звёзд на GitHubОб этом скилле
Clerk Sessions, Webhooks, and Security
Overview
Use this skill for Clerk's security-sensitive surfaces: sessions, JWTs, token retrieval, organizations and authorization, webhook synchronization, environment separation, and production hardening. Prioritize trust boundaries and replay-safe design.
Sessions and Tokens
Distinguish the token or session type before writing code:
| Surface | Use |
|---|---|
| Session token | Authenticates a signed-in user session |
| Custom JWT template | Supplies custom claims for an external service integration |
| API key | Authenticates an application/user-created key where Clerk supports API keys |
| OAuth token | Authenticates OAuth access flows where enabled |
| Machine-to-machine token | Authenticates service-to-service requests |
Use getToken() from the relevant Clerk auth object or hook to retrieve a session token or custom JWT template where supported. Always await it. Do not store tokens in localStorage, log them, embed them in URLs, or send them to origins that do not need them.
Treat pending sessions deliberately. Some Clerk APIs treat pending sessions as signed out by default (treatPendingAsSignedOut defaults to true in relevant server APIs). If a flow includes session tasks, MFA, verification, or other pending states, design UI and server behavior for “not fully signed in yet.”
Custom JWT Templates
Use custom JWT templates when an external service needs a token with particular claims, audience, or shape. Keep templates minimal. Include only claims the recipient needs, and avoid duplicating sensitive profile fields.
On the consuming service, validate according to Clerk's current docs and the service's expectations:
- Signature/JWKS.
- Issuer.
- Audience.
- Expiration/nbf.
- Token type/template.
- Organization context where relevant.
When a custom JWT contains organization or role context, ensure the active organization at token issuance matches the resource being accessed. Avoid long-lived authorization decisions based solely on stale claims when roles, memberships, plans, or permissions can change.
Token Time Claims and Clock Skew
Clerk session tokens and custom JWT templates include iat, nbf, and exp. Verifiers reject tokens with reason token-not-active-yet when nbf is in the future, and token-expired when exp has passed. These failures are usually clock skew on the verifier, not real token problems. For full coverage (nbf/iat/exp semantics, Clerk's clockSkewInMs default of 5000 ms in verifyToken/authenticateRequest, multi-language leeway settings, container/WSL2/Docker Desktop time fix recipes, and a clock-skew-vs-real-expiry decision tree) load the dedicated clerk-clock-skew-jwt skill.
Organizations, Roles, Permissions, Features, and Plans
Authorization must be explicit and organization-scoped where relevant. A signed-in user is not automatically authorized for every organization resource.
Recommended defaults:
- Require an active organization for organization resources.
- Check resource organization ownership against authenticated org context.
- Use roles or custom permissions for admin actions.
- Use plan/feature checks only where product entitlements are configured and enforce them server-side.
- Default-deny missing roles, unknown permissions, inactive memberships, unsupported plans, and absent organization context.
- Treat client-rendered role/plan/metadata data as advisory; enforce on the server.
Important nuance: server-side has() works for Custom Permissions. Clerk System Permissions are not in session token claims, so check the user's Role where Clerk requires it. Do not assume every Dashboard permission string is valid in every server-side check.
Metadata Trust Boundaries
Clerk user data can include multiple metadata categories. Define source of truth before syncing or authorizing:
- Public metadata: visible to the frontend; do not store secrets.
- Private metadata: server-side privileged metadata; still avoid using it as the only source for high-risk authorization when freshness matters.
- Unsafe metadata: user-writable; treat as untrusted input.
- Application database fields: often best for app-specific profiles, audit state, and denormalized search/indexing.
Do not grant admin access from user-controlled metadata. For role and org authorization, use Clerk organization membership/role/permission state or trusted application records.
Webhook Verification
Clerk webhooks are delivered through Svix. Treat every incoming webhook as forged until verification succeeds. Use Clerk's verifyWebhook() helper or Svix verification libraries as documented for the runtime.
Webhook rules:
- Make the webhook route public with respect to user-session middleware; webhooks do not carry a user session.
- Preserve the signed request payload in the form required by the verification helper/library.
- Verify the Svix signature before parsing or trusting event data.
- Reject missing or invalid
Установить clerk-sessions-webhooks-security в Claude Code и Claude Desktop
Зарегайся, чтобы установить скилл
Создай бесплатный аккаунт, чтобы открыть команду установки и сохранить скилл в библиотеку.
- Открой команду установки в одну строку
- Сохраняй скиллы в синхронизируемую библиотеку
- Уведомления, когда скиллы обновляются
Разрешённые инструменты
Инструменты, которые скиллу разрешено вызывать.
Без ограничений — скилл может использовать любой инструмент.
FAQ
Что делает скилл clerk-sessions-webhooks-security?
Use for Clerk sessions, tokens, webhooks, orgs, and security. PROACTIVELY activate for session tokens, JWT templates, getToken(), custom claims, pending sessions, multi-session UX, organizations, roles, permissions, system vs custom permissions, features/plans, MFA/passkeys/password policy/bot protection, Clerk webhooks, Svix signatures, verifyWebhook(), user/org sync, retries/replays, environment variables, custom domains, secret rotation, logs, and auth security reviews. Provides token semantics, webhook idempotency, authorization defaults, and hardening checklist.
Как установить скилл clerk-sessions-webhooks-security?
Скопируй папку скилла в ~/.claude/skills (вкладка Claude Code выше делает это одной командой), либо поставь как плагин.
Скилл clerk-sessions-webhooks-security запускает скрипты?
Нет, скилл состоит только из инструкций (SKILL.md), без исполняемых скриптов.
Похожие скиллы
frontend-design
Guidance for distinctive, intentional visual design when building new UI or reshaping an existing one. Helps with aesthetic direction, typography, and making…
от Anthropicwebapp-testing
Toolkit for interacting with and testing local web applications using Playwright. Supports verifying frontend functionality, debugging UI behavior, capturing…
от Anthropicbrand-guidelines
Applies Anthropic's official brand colors and typography to any sort of artifact that may benefit from having Anthropic's look-and-feel. Use it when brand…
от Anthropicweb-artifacts-builder
Suite of tools for creating elaborate, multi-component claude.ai HTML artifacts using modern frontend web technologies (React, Tailwind CSS, shadcn/ui). Use…
от Anthropic