workos 0.9.0 → 0.10.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (50) hide show
  1. package/README.md +5 -6
  2. package/dist/bin.js +39 -14
  3. package/dist/bin.js.map +1 -1
  4. package/dist/commands/install-skill.d.ts +0 -1
  5. package/dist/commands/install-skill.js +2 -10
  6. package/dist/commands/install-skill.js.map +1 -1
  7. package/dist/commands/list-skills.d.ts +4 -0
  8. package/dist/commands/list-skills.js +52 -0
  9. package/dist/commands/list-skills.js.map +1 -0
  10. package/dist/commands/login.d.ts +8 -0
  11. package/dist/commands/login.js +41 -1
  12. package/dist/commands/login.js.map +1 -1
  13. package/dist/commands/uninstall-skill.d.ts +11 -0
  14. package/dist/commands/uninstall-skill.js +116 -0
  15. package/dist/commands/uninstall-skill.js.map +1 -0
  16. package/dist/integrations/dotnet/index.js +7 -12
  17. package/dist/integrations/dotnet/index.js.map +1 -1
  18. package/dist/integrations/elixir/index.js +7 -13
  19. package/dist/integrations/elixir/index.js.map +1 -1
  20. package/dist/integrations/go/index.js +5 -11
  21. package/dist/integrations/go/index.js.map +1 -1
  22. package/dist/integrations/python/index.js +7 -13
  23. package/dist/integrations/python/index.js.map +1 -1
  24. package/dist/integrations/ruby/index.js +9 -14
  25. package/dist/integrations/ruby/index.js.map +1 -1
  26. package/dist/lib/agent-interface.js +5 -4
  27. package/dist/lib/agent-interface.js.map +1 -1
  28. package/dist/lib/agent-runner.js +24 -19
  29. package/dist/lib/agent-runner.js.map +1 -1
  30. package/dist/utils/help-json.js +55 -21
  31. package/dist/utils/help-json.js.map +1 -1
  32. package/package.json +2 -3
  33. package/.claude-plugin/plugin.json +0 -13
  34. package/skills/workos-authkit-base/SKILL.md +0 -123
  35. package/skills/workos-authkit-nextjs/SKILL.md +0 -247
  36. package/skills/workos-authkit-react/SKILL.md +0 -100
  37. package/skills/workos-authkit-react-router/SKILL.md +0 -117
  38. package/skills/workos-authkit-sveltekit/SKILL.md +0 -208
  39. package/skills/workos-authkit-tanstack-start/SKILL.md +0 -314
  40. package/skills/workos-authkit-vanilla-js/SKILL.md +0 -92
  41. package/skills/workos-dotnet/SKILL.md +0 -163
  42. package/skills/workos-elixir/SKILL.md +0 -231
  43. package/skills/workos-go/SKILL.md +0 -226
  44. package/skills/workos-kotlin/SKILL.md +0 -195
  45. package/skills/workos-management/SKILL.md +0 -250
  46. package/skills/workos-node/SKILL.md +0 -197
  47. package/skills/workos-php/SKILL.md +0 -160
  48. package/skills/workos-php-laravel/SKILL.md +0 -182
  49. package/skills/workos-python/SKILL.md +0 -193
  50. package/skills/workos-ruby/SKILL.md +0 -198
@@ -1,250 +0,0 @@
1
- ---
2
- name: workos-management
3
- description: Manage WorkOS resources (orgs, users, roles, SSO, directories, webhooks, audit logs) via CLI. Use when configuring RBAC, onboarding orgs/users, debugging SSO/DSync, or managing WorkOS settings.
4
- ---
5
-
6
- # WorkOS Management Commands
7
-
8
- Use these commands to manage WorkOS resources directly from the terminal. The CLI must be authenticated via `workos auth login` or `WORKOS_API_KEY` env var.
9
-
10
- All commands support `--json` for structured output. Use `--json` when you need to parse output (e.g., extract an ID).
11
-
12
- ## Quick Reference
13
-
14
- | Task | Command |
15
- | ---------------------- | ---------------------------------------------------------------------------- |
16
- | List organizations | `workos organization list` |
17
- | Create organization | `workos organization create "Acme Corp" acme.com:verified` |
18
- | List users | `workos user list --email=alice@acme.com` |
19
- | Create permission | `workos permission create --slug=read-users --name="Read Users"` |
20
- | Create role | `workos role create --slug=admin --name=Admin` |
21
- | Assign perms to role | `workos role set-permissions admin --permissions=read-users,write-users` |
22
- | Create org-scoped role | `workos role create --slug=admin --name=Admin --org=org_xxx` |
23
- | Add user to org | `workos membership create --org=org_xxx --user=user_xxx` |
24
- | Send invitation | `workos invitation send --email=alice@acme.com --org=org_xxx` |
25
- | Revoke session | `workos session revoke <sessionId>` |
26
- | Add redirect URI | `workos config redirect add http://localhost:3000/callback` |
27
- | Add CORS origin | `workos config cors add http://localhost:3000` |
28
- | Set homepage URL | `workos config homepage-url set http://localhost:3000` |
29
- | Create webhook | `workos webhook create --url=https://example.com/hook --events=user.created` |
30
- | List SSO connections | `workos connection list --org=org_xxx` |
31
- | List directories | `workos directory list` |
32
- | Toggle feature flag | `workos feature-flag enable my-flag` |
33
- | Store a secret | `workos vault create --name=api-secret --value=sk_xxx --org=org_xxx` |
34
- | Generate portal link | `workos portal generate-link --intent=sso --org=org_xxx` |
35
- | Seed environment | `workos seed --file=workos-seed.yml` |
36
- | Debug SSO | `workos debug-sso conn_xxx` |
37
- | Debug directory sync | `workos debug-sync directory_xxx` |
38
- | Set up an org | `workos setup-org "Acme Corp" --domain=acme.com --roles=admin,viewer` |
39
- | Onboard a user | `workos onboard-user alice@acme.com --org=org_xxx --role=admin` |
40
-
41
- ## Workflows
42
-
43
- ### Setting up RBAC
44
-
45
- When you see permission checks in the codebase (e.g., `hasPermission('read-users')`), create the matching WorkOS resources:
46
-
47
- ```bash
48
- workos permission create --slug=read-users --name="Read Users"
49
- workos permission create --slug=write-users --name="Write Users"
50
- workos role create --slug=admin --name=Admin
51
- workos role set-permissions admin --permissions=read-users,write-users
52
- workos role create --slug=viewer --name=Viewer
53
- workos role set-permissions viewer --permissions=read-users
54
- ```
55
-
56
- For organization-scoped roles, add `--org=org_xxx` to role commands.
57
-
58
- ### Organization Onboarding
59
-
60
- One-shot setup with the compound command:
61
-
62
- ```bash
63
- workos setup-org "Acme Corp" --domain=acme.com --roles=admin,viewer
64
- ```
65
-
66
- Or step by step:
67
-
68
- ```bash
69
- ORG_ID=$(workos organization create "Acme Corp" --json | jq -r '.data.id')
70
- workos org-domain create acme.com --org=$ORG_ID
71
- workos role create --slug=admin --name=Admin --org=$ORG_ID
72
- workos portal generate-link --intent=sso --org=$ORG_ID
73
- ```
74
-
75
- ### User Onboarding
76
-
77
- ```bash
78
- workos onboard-user alice@acme.com --org=org_xxx --role=admin
79
- ```
80
-
81
- Or step by step:
82
-
83
- ```bash
84
- workos invitation send --email=alice@acme.com --org=org_xxx --role=admin
85
- workos membership create --org=org_xxx --user=user_xxx --role=admin
86
- ```
87
-
88
- ### Local Development Setup
89
-
90
- Configure WorkOS for local development:
91
-
92
- ```bash
93
- workos config redirect add http://localhost:3000/callback
94
- workos config cors add http://localhost:3000
95
- workos config homepage-url set http://localhost:3000
96
- ```
97
-
98
- ### Environment Seeding
99
-
100
- Create a `workos-seed.yml` file in your repo:
101
-
102
- ```yaml
103
- permissions:
104
- - name: 'Read Users'
105
- slug: 'read-users'
106
- - name: 'Write Users'
107
- slug: 'write-users'
108
-
109
- roles:
110
- - name: 'Admin'
111
- slug: 'admin'
112
- permissions: ['read-users', 'write-users']
113
- - name: 'Viewer'
114
- slug: 'viewer'
115
- permissions: ['read-users']
116
-
117
- organizations:
118
- - name: 'Test Org'
119
- domains: ['test.com']
120
-
121
- config:
122
- redirect_uris: ['http://localhost:3000/callback']
123
- cors_origins: ['http://localhost:3000']
124
- homepage_url: 'http://localhost:3000'
125
- ```
126
-
127
- Then run:
128
-
129
- ```bash
130
- workos seed --file=workos-seed.yml # Create resources
131
- workos seed --clean # Tear down seeded resources
132
- ```
133
-
134
- ### Debugging SSO
135
-
136
- ```bash
137
- workos debug-sso conn_xxx
138
- ```
139
-
140
- Shows: connection type/state, organization binding, recent auth events, and common issues (inactive connection, org mismatch).
141
-
142
- ### Debugging Directory Sync
143
-
144
- ```bash
145
- workos debug-sync directory_xxx
146
- ```
147
-
148
- Shows: directory type/state, user/group counts, recent sync events, and stall detection.
149
-
150
- ### Webhook Management
151
-
152
- ```bash
153
- workos webhook list
154
- workos webhook create --url=https://example.com/hook --events=user.created,dsync.user.created
155
- workos webhook delete we_xxx
156
- ```
157
-
158
- ### Audit Logs
159
-
160
- ```bash
161
- workos audit-log create-event --org=org_xxx --action=user.login --actor-type=user --actor-id=user_xxx
162
- workos audit-log list-actions
163
- workos audit-log get-schema user.login
164
- workos audit-log export --org=org_xxx --range-start=2024-01-01 --range-end=2024-02-01
165
- workos audit-log get-retention --org=org_xxx
166
- ```
167
-
168
- ## Using --json for Structured Output
169
-
170
- All commands support `--json` for machine-readable output. Use this when you need to extract values:
171
-
172
- ```bash
173
- # Get an organization ID
174
- workos organization list --json | jq '.data[0].id'
175
-
176
- # Get a connection's state
177
- workos connection get conn_xxx --json | jq '.state'
178
-
179
- # List all role slugs
180
- workos role list --json | jq '.data[].slug'
181
-
182
- # Chain commands: create org then add domain
183
- ORG_ID=$(workos organization create "Acme" --json | jq -r '.data.id')
184
- workos org-domain create acme.com --org=$ORG_ID
185
- ```
186
-
187
- JSON output format:
188
-
189
- - **List commands**: `{ "data": [...], "listMetadata": { "before": null, "after": "cursor" } }`
190
- - **Get commands**: Raw object (no wrapper)
191
- - **Create/Update/Delete**: `{ "status": "ok", "message": "...", "data": {...} }`
192
- - **Errors**: `{ "error": { "code": "...", "message": "..." } }` on stderr
193
-
194
- ## Command Reference
195
-
196
- ### Resource Commands
197
-
198
- | Command | Subcommands |
199
- | --------------------- | ----------------------------------------------------------------------------------------------------- |
200
- | `workos organization` | `list`, `get`, `create`, `update`, `delete` |
201
- | `workos user` | `list`, `get`, `update`, `delete` |
202
- | `workos role` | `list`, `get`, `create`, `update`, `delete`, `set-permissions`, `add-permission`, `remove-permission` |
203
- | `workos permission` | `list`, `get`, `create`, `update`, `delete` |
204
- | `workos membership` | `list`, `get`, `create`, `update`, `delete`, `deactivate`, `reactivate` |
205
- | `workos invitation` | `list`, `get`, `send`, `revoke`, `resend` |
206
- | `workos session` | `list`, `revoke` |
207
- | `workos connection` | `list`, `get`, `delete` |
208
- | `workos directory` | `list`, `get`, `delete`, `list-users`, `list-groups` |
209
- | `workos event` | `list` (requires `--events` flag) |
210
- | `workos audit-log` | `create-event`, `export`, `list-actions`, `get-schema`, `create-schema`, `get-retention` |
211
- | `workos feature-flag` | `list`, `get`, `enable`, `disable`, `add-target`, `remove-target` |
212
- | `workos webhook` | `list`, `create`, `delete` |
213
- | `workos config` | `redirect add`, `cors add`, `homepage-url set` |
214
- | `workos portal` | `generate-link` |
215
- | `workos vault` | `list`, `get`, `get-by-name`, `create`, `update`, `delete`, `describe`, `list-versions` |
216
- | `workos api-key` | `list`, `create`, `validate`, `delete` |
217
- | `workos org-domain` | `get`, `create`, `verify`, `delete` |
218
-
219
- ### Workflow Commands
220
-
221
- | Command | Purpose |
222
- | ----------------------------- | ------------------------------------------- |
223
- | `workos seed --file=<yaml>` | Declarative resource provisioning from YAML |
224
- | `workos seed --clean` | Tear down seeded resources |
225
- | `workos setup-org <name>` | One-shot org onboarding |
226
- | `workos onboard-user <email>` | Send invitation + optional wait |
227
- | `workos debug-sso <connId>` | SSO connection diagnostics |
228
- | `workos debug-sync <dirId>` | Directory sync diagnostics |
229
-
230
- ### Common Flags
231
-
232
- | Flag | Purpose | Scope |
233
- | ------------------------------------------- | ------------------------ | --------------------------------------------------- |
234
- | `--json` | Structured JSON output | All commands |
235
- | `--api-key` | Override API key | Resource commands |
236
- | `--org` | Organization scope | role, membership, invitation, api-key, feature-flag |
237
- | `--force` | Skip confirmation prompt | connection delete, directory delete |
238
- | `--limit`, `--before`, `--after`, `--order` | Pagination | All list commands |
239
-
240
- ## Dashboard-Only Operations
241
-
242
- These CANNOT be done from the CLI — tell the user to visit the WorkOS Dashboard:
243
-
244
- - **Enable/disable auth methods** — Dashboard > Authentication
245
- - **Configure session lifetime** — Dashboard > Authentication > Sessions
246
- - **Set up social login providers** (Google, GitHub, etc.) — Dashboard > Authentication > Social
247
- - **Create feature flags** — Dashboard > Feature Flags (toggle/target operations work via CLI)
248
- - **Configure branding** (logos, colors) — Dashboard > Branding
249
- - **Set up email templates** — Dashboard > Email
250
- - **Manage billing/plan** — Dashboard > Settings > Billing
@@ -1,197 +0,0 @@
1
- ---
2
- name: workos-node
3
- description: Integrate WorkOS AuthKit with Node.js backend applications. Adapts to Express, Fastify, Hono, Koa, or vanilla Node.js http. Server-side authentication with redirect-based OAuth flow.
4
- ---
5
-
6
- # WorkOS AuthKit for Node.js
7
-
8
- ## Step 1: Fetch SDK Documentation (BLOCKING)
9
-
10
- **STOP - Do not proceed until complete.**
11
-
12
- WebFetch: `https://raw.githubusercontent.com/workos/workos-node/main/README.md`
13
-
14
- Also fetch the AuthKit quickstart for reference:
15
- WebFetch: `https://workos.com/docs/authkit/vanilla/nodejs`
16
-
17
- README is the source of truth for all SDK patterns. **README overrides this skill if conflict.**
18
-
19
- ## Step 2: Detect Framework & Project Structure
20
-
21
- ```
22
- package.json has 'express'? → Express
23
- package.json has 'fastify'? → Fastify
24
- package.json has 'hono'? → Hono
25
- package.json has 'koa'? → Koa
26
- None of the above? → Vanilla Node.js http (use Express quickstart pattern)
27
-
28
- tsconfig.json exists? → TypeScript (.ts files)
29
- "type": "module" in package.json? → ESM (import/export)
30
- else → CJS (require/module.exports)
31
- ```
32
-
33
- Detect entry point: `src/index.ts`, `src/app.ts`, `app.js`, `server.js`, `index.js`
34
-
35
- Detect package manager: `pnpm-lock.yaml` → `yarn.lock` → `bun.lockb` → npm
36
-
37
- **Adapt all subsequent steps to the detected framework and module system.**
38
-
39
- ## Step 2b: Partial Install Recovery
40
-
41
- Before creating new files, check if a previous AuthKit attempt exists:
42
-
43
- 1. Check if `@workos-inc/node` is already in `package.json`
44
- 2. Check for incomplete auth files — routes/handlers that import `@workos-inc/node` but are non-functional (TODO comments, 501 responses, empty handlers)
45
- 3. If partial install detected:
46
- - Do NOT reinstall the SDK (it's already there)
47
- - Read existing auth files to understand what's done vs missing
48
- - Complete the integration by filling gaps rather than starting fresh
49
- - Preserve any working code — only fix what's broken
50
- - Check for a missing `/callback` route (most common gap)
51
-
52
- ## Step 2c: Existing Auth System Detection
53
-
54
- Check for existing authentication before integrating:
55
-
56
- ```
57
- package.json has 'passport'? → Passport.js auth
58
- package.json has 'express-openid-connect'? → Auth0 / OIDC
59
- package.json has 'express-session'? → Session-based auth may exist
60
- *.js/*.ts files have 'jsonwebtoken'? → JWT-based auth
61
- ```
62
-
63
- If existing auth detected:
64
-
65
- - Do NOT remove or disable it
66
- - Add WorkOS AuthKit alongside the existing system
67
- - If `express-session` is already configured, reuse it for WorkOS session storage (don't create a second session middleware)
68
- - Create separate route paths for WorkOS auth (e.g., `/auth/workos/login` if `/login` is taken)
69
- - Ensure existing auth routes continue to work unchanged
70
- - Document in code comments how to migrate fully to WorkOS later
71
-
72
- ## Step 3: Install SDK
73
-
74
- ```
75
- pnpm-lock.yaml → pnpm add @workos-inc/node dotenv cookie-parser
76
- yarn.lock → yarn add @workos-inc/node dotenv cookie-parser
77
- bun.lockb → bun add @workos-inc/node dotenv cookie-parser
78
- else → npm install @workos-inc/node dotenv cookie-parser
79
- ```
80
-
81
- For TypeScript, also install types: `pnpm add -D @types/cookie-parser`
82
-
83
- **Verify:** `@workos-inc/node` in package.json dependencies
84
-
85
- ## Step 4: Initialize WorkOS Client
86
-
87
- Adapt to detected module system (ESM vs CJS):
88
-
89
- **ESM/TypeScript:**
90
-
91
- ```typescript
92
- import { WorkOS } from '@workos-inc/node';
93
- const workos = new WorkOS(process.env.WORKOS_API_KEY, {
94
- clientId: process.env.WORKOS_CLIENT_ID,
95
- });
96
- ```
97
-
98
- **CJS:**
99
-
100
- ```javascript
101
- const { WorkOS } = require('@workos-inc/node');
102
- const workos = new WorkOS(process.env.WORKOS_API_KEY, {
103
- clientId: process.env.WORKOS_CLIENT_ID,
104
- });
105
- ```
106
-
107
- ## Step 5: Integrate Authentication
108
-
109
- ### If Express
110
-
111
- Follow the quickstart pattern:
112
-
113
- 1. **`/login` route** — call `workos.userManagement.getAuthorizationUrl({ provider: 'authkit', redirectUri: ..., clientId: ... })`, redirect
114
- 2. **`/callback` route** — call `workos.userManagement.authenticateWithCode({ code, clientId })`, store session via sealed session or express-session
115
- 3. **`/logout` route** — clear session cookie, redirect
116
- 4. **Cookie middleware** — `app.use(cookieParser())`
117
- 5. **Session-aware home route** — read session, display user info
118
-
119
- **Session handling options (pick one):**
120
-
121
- - **Sealed sessions** (recommended, from quickstart): use `sealSession: true` in authenticateWithCode, store sealed cookie, use `loadSealedSession` for verification
122
- - **express-session**: install `express-session`, configure middleware before routes, store user in `req.session`
123
-
124
- ### If Fastify
125
-
126
- 1. Register `@fastify/cookie` plugin
127
- 2. Create `/login`, `/callback`, `/logout` routes using Fastify route syntax
128
- 3. Use `reply.redirect()` for redirects
129
- 4. Store session in signed cookie
130
-
131
- ### If Hono
132
-
133
- 1. Create `/login`, `/callback`, `/logout` routes using Hono router
134
- 2. Use `c.redirect()` for redirects
135
- 3. Use Hono's cookie helpers for session
136
-
137
- ### If Koa
138
-
139
- 1. Install `koa-router` if not present
140
- 2. Create auth routes on router
141
- 3. Use `ctx.redirect()` for redirects
142
- 4. Use `koa-session` for session management
143
-
144
- ### If Vanilla Node.js (no framework detected)
145
-
146
- Install Express and follow the Express pattern above. This matches the official quickstart.
147
-
148
- ## Step 6: Environment Setup
149
-
150
- Create `.env` if it doesn't exist. Do NOT overwrite existing values:
151
-
152
- ```
153
- WORKOS_API_KEY=sk_...
154
- WORKOS_CLIENT_ID=client_...
155
- WORKOS_REDIRECT_URI=http://localhost:3000/callback
156
- WORKOS_COOKIE_PASSWORD=<generate with openssl rand -base64 32>
157
- ```
158
-
159
- Ensure `.env` is in `.gitignore`.
160
-
161
- ## Step 7: Verification
162
-
163
- **TypeScript:** `npx tsc --noEmit`
164
- **JavaScript:** `node --check <entry-file>`
165
-
166
- ### Checklist
167
-
168
- - [ ] SDK installed (`@workos-inc/node` in package.json)
169
- - [ ] WorkOS client initialized
170
- - [ ] Login route redirects to AuthKit
171
- - [ ] Callback route exchanges code for user
172
- - [ ] Logout route clears session
173
- - [ ] `.env` has required variables
174
- - [ ] Build/syntax check passes
175
-
176
- ## Error Recovery
177
-
178
- ### Module not found: @workos-inc/node
179
-
180
- Re-run install for detected package manager.
181
-
182
- ### Session not persisting
183
-
184
- If using express-session: ensure middleware registered BEFORE routes.
185
- If using sealed sessions: ensure cookie is being set with correct options (httpOnly, secure in prod, sameSite: 'lax').
186
-
187
- ### Callback returns 404
188
-
189
- Route path must match WORKOS_REDIRECT_URI exactly.
190
-
191
- ### ESM/CJS mismatch
192
-
193
- Check `"type"` field in package.json — `"module"` = ESM (import/export), absent = CJS (require).
194
-
195
- ### TypeScript errors
196
-
197
- Install missing types: `@types/express`, `@types/cookie-parser`, `@types/express-session`.
@@ -1,160 +0,0 @@
1
- ---
2
- name: workos-php
3
- description: Integrate WorkOS AuthKit with generic PHP applications. Uses the workos-php SDK directly with standalone auth endpoint files.
4
- ---
5
-
6
- # WorkOS AuthKit for PHP
7
-
8
- ## Step 1: Fetch SDK Documentation (BLOCKING)
9
-
10
- **STOP. Do not proceed until complete.**
11
-
12
- WebFetch: `https://raw.githubusercontent.com/workos/workos-php/main/README.md`
13
-
14
- The README is the source of truth. If this skill conflicts with README, follow README.
15
-
16
- ## Step 2: Pre-Flight Validation
17
-
18
- ### Project Structure
19
-
20
- - Confirm `composer.json` exists at project root
21
- - If `composer.json` doesn't exist, create a minimal one with `composer init --no-interaction`
22
-
23
- ### Environment Variables
24
-
25
- Check for `.env` file with:
26
-
27
- - `WORKOS_API_KEY` - starts with `sk_`
28
- - `WORKOS_CLIENT_ID` - starts with `client_`
29
- - `WORKOS_REDIRECT_URI` - valid callback URL (e.g., `http://localhost:8000/callback.php`)
30
-
31
- If `.env` doesn't exist, create it with the required variables.
32
-
33
- ## Step 2b: Partial Install Recovery
34
-
35
- Before creating new files, check if a previous AuthKit attempt exists:
36
-
37
- 1. Check if `workos/workos-php` is already in `composer.json`
38
- 2. Check for incomplete auth files — `login.php` or `callback.php` that import WorkOS but are non-functional (TODO comments, 501 responses, empty handlers)
39
- 3. If partial install detected:
40
- - Do NOT reinstall the SDK (it's already there)
41
- - Read existing auth files to understand what's done vs missing
42
- - Complete the integration by filling gaps rather than starting fresh
43
- - Preserve any working code — only fix what's broken
44
- - Check for a missing `callback.php` (most common gap)
45
-
46
- ## Step 2c: Existing Auth System Detection
47
-
48
- Check for existing authentication before integrating:
49
-
50
- ```
51
- *.php files have 'session_start()' + '$_SESSION'? → Native PHP session auth
52
- *.php files have 'password_verify'? → Password-based auth
53
- *.php files have form POST to '/login'? → Form-based auth
54
- composer.json has auth libraries? → Third-party auth
55
- ```
56
-
57
- If existing auth detected:
58
-
59
- - Do NOT remove or disable it
60
- - Add WorkOS AuthKit alongside the existing system
61
- - If `session_start()` is already used, reuse the session for WorkOS (don't create a second session mechanism)
62
- - Create separate file paths for WorkOS auth (e.g., `workos-login.php` if `login.php` is taken)
63
- - Ensure existing auth routes continue to work unchanged
64
- - Document in code comments how to migrate fully to WorkOS later
65
-
66
- ## Step 3: Install SDK
67
-
68
- ```bash
69
- composer require workos/workos-php
70
- ```
71
-
72
- **Verify:** Check `composer.json` contains `workos/workos-php` in require section.
73
-
74
- Also install a dotenv library if not present:
75
-
76
- ```bash
77
- composer require vlucas/phpdotenv
78
- ```
79
-
80
- ## Step 4: Create Bootstrap File
81
-
82
- Create a bootstrap or config file (e.g., `config.php` or `bootstrap.php`) that:
83
-
84
- 1. Requires Composer autoloader: `require_once __DIR__ . '/vendor/autoload.php';`
85
- 2. Loads `.env` using phpdotenv
86
- 3. Initializes the WorkOS SDK client with API key
87
-
88
- Use SDK initialization from README. Do NOT hardcode credentials.
89
-
90
- ## Step 5: Create Auth Endpoint Files
91
-
92
- ### `login.php`
93
-
94
- - Initialize WorkOS client (include bootstrap)
95
- - Generate authorization URL using SDK
96
- - Redirect user to WorkOS AuthKit
97
-
98
- ### `callback.php`
99
-
100
- - Initialize WorkOS client (include bootstrap)
101
- - Exchange authorization code from `$_GET['code']` for user profile using SDK
102
- - Start session, store user data
103
- - Redirect to home/dashboard
104
-
105
- ### `logout.php`
106
-
107
- - Destroy session
108
- - Redirect to home page
109
-
110
- Use SDK methods from README for all WorkOS API calls. Do NOT construct OAuth URLs manually.
111
-
112
- ## Step 6: Create Home Page
113
-
114
- Create or update `index.php` to show:
115
-
116
- - Sign in link (`login.php`) when no session
117
- - User info and sign out link (`logout.php`) when session exists
118
-
119
- ## Verification Checklist (ALL MUST PASS)
120
-
121
- ```bash
122
- # 1. SDK installed
123
- composer show workos/workos-php
124
-
125
- # 2. Auth files exist
126
- ls login.php callback.php logout.php
127
-
128
- # 3. No syntax errors
129
- php -l login.php
130
- php -l callback.php
131
- php -l logout.php
132
- php -l index.php
133
-
134
- # 4. Autoloader exists
135
- ls vendor/autoload.php
136
- ```
137
-
138
- ## Error Recovery
139
-
140
- ### "Class WorkOS\WorkOS not found"
141
-
142
- - Verify `composer require` completed successfully
143
- - Check `vendor/autoload.php` is required in bootstrap
144
- - Run `composer dump-autoload`
145
-
146
- ### Session issues
147
-
148
- - Ensure `session_start()` is called before any session access
149
- - Check PHP session configuration (`session.save_path`)
150
-
151
- ### Redirect URI mismatch
152
-
153
- - Compare callback file path to `WORKOS_REDIRECT_URI` in `.env`
154
- - URLs must match exactly (including trailing slash)
155
-
156
- ### Environment variables not loading
157
-
158
- - Verify `.env` file exists in project root
159
- - Verify phpdotenv is installed and loaded in bootstrap
160
- - Check file permissions on `.env`