Skip to content
Back to skills

Workos

ASecurity

> **Verification Tier:** `code_example_tested` | **Last Verified:** 2026-11-18 > **Official Docs:** https://workos.com/docs/user-management

  • 13 stars
  • 0 votes
  • 0 copies
  • 0 views
  • Added December 2, 2026
ai-agentsrustbashnextjsnodegitapisecurity

Works with

  • cli
  • api

Security analysis

A92/100
  • mediumInstalls packages at runtime which could introduce malicious dependencies
  • mediumInstalls packages at runtime which could introduce malicious dependencies

Pro scans all 2 files and shows the line behind each finding

Scanned December 2, 2026

npx -y skills add ashish7802/awesome-api-skills --skill workos --agent claude-code

Installs into .claude/skills of the current project.

Are you the author of Workos?

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

Security grade badge for Workos
[![Security: A — Skills Directory](https://www.skillsdirectory.com/api/skills/ashish7802-workos/badge)](https://www.skillsdirectory.com/skills/ashish7802-workos)

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
# WorkOS API & SDK Skill

> **Verification Tier:** `code_example_tested` | **Last Verified:** 2026-11-18  
> **Official Docs:** https://workos.com/docs/user-management

## Overview
WorkOS provides enterprise-ready authentication (AuthKit), SAML/OIDC Single Sign-On, SCIM Directory Sync, Fine-Grained Authorization (FGA), and Audit Logs.

## Installation
```bash
npm install @workos-inc/node
pip install workos
```

## Authentication
Configure `WORKOS_API_KEY` (`sk_live_...` / `sk_test_...`), `WORKOS_CLIENT_ID` (`client_...`), and `WORKOS_COOKIE_PASSWORD` (at least 32 characters for sealed session cookies) via environment variables.

## Core Concepts
- **AuthKit Authorization Flow**: Redirect users via `workos.userManagement.getAuthorizationUrl({ provider: "authkit", redirectUri, clientId, state })` (or `getAuthorizationUrlWithPKCE` for public clients) and exchange the callback `code` via `workos.userManagement.authenticateWithCode({ code, clientId })`.
- **JWT Verification**: Verify access tokens server-side against WorkOS JWKS rather than trusting decoded unverified JWT claims.
- **Webhooks**: Verify Directory Sync and User Management webhooks with `workos.webhooks.constructEvent({ payload, sigHeader, secret })` using the raw request body.

## Error Handling & Rate Limits
- Handle `401` (expired/revoked session -> refresh via refresh token), `422` (invalid authorization code or mismatched `redirectUri`), and `429` rate-limit responses with backoff.
- Always validate the CSRF `state` parameter on OAuth callback routes before calling `authenticateWithCode`.

## Security Best Practices
- Store session tokens in `HttpOnly`, `Secure`, `SameSite=Lax` encrypted cookies—never in `localStorage`.
- Always pass the raw unparsed request body string to `workos.webhooks.constructEvent`.
- Enforce organization membership checks (`organizationId`) on every multi-tenant API route.

## AI Pitfalls
- Skipping OAuth `state` validation on the callback handler (CSRF/login-fixation risk).
- Parsing JSON before verifying WorkOS webhook signatures.
- Confusing `WORKOS_CLIENT_ID` (safe identifier) with `WORKOS_API_KEY` (strictly server-side secret).

## Production Checklist
- [ ] `WORKOS_API_KEY` and `WORKOS_COOKIE_PASSWORD` loaded from env vars only
- [ ] OAuth callback validates cryptographic `state` nonce
- [ ] Session cookies set `HttpOnly`, `Secure`, `SameSite=Lax`
- [ ] Webhook handler verifies `workos-signature` against raw body

## References
- [WorkOS User Management Docs](https://workos.com/docs/user-management)
- [WorkOS Node SDK](https://github.com/workos/workos-node)

## Related skills
- [`clerk`](../clerk/SKILL.md) — alternative to
- [`auth0`](../auth0/SKILL.md) — alternative to
- [`nextjs`](../nextjs/SKILL.md) — integrates with

Files in this skill

  • SKILL.md2.7 KB
  • examples/quickstart.ts722 B

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.

View all in ai-agents →

Comments

Loading comments…

Newsletter

Get the weekly list of safe new skills, and the ones we pulled.