workos 0.8.2 → 0.10.0

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 (70) hide show
  1. package/README.md +10 -8
  2. package/dist/bin.js +62 -27
  3. package/dist/bin.js.map +1 -1
  4. package/dist/commands/auth-status.d.ts +1 -0
  5. package/dist/commands/auth-status.js +56 -0
  6. package/dist/commands/auth-status.js.map +1 -0
  7. package/dist/commands/install-skill.d.ts +0 -1
  8. package/dist/commands/install-skill.js +2 -10
  9. package/dist/commands/install-skill.js.map +1 -1
  10. package/dist/commands/list-skills.d.ts +4 -0
  11. package/dist/commands/list-skills.js +52 -0
  12. package/dist/commands/list-skills.js.map +1 -0
  13. package/dist/commands/login.js +5 -4
  14. package/dist/commands/login.js.map +1 -1
  15. package/dist/commands/uninstall-skill.d.ts +11 -0
  16. package/dist/commands/uninstall-skill.js +116 -0
  17. package/dist/commands/uninstall-skill.js.map +1 -0
  18. package/dist/doctor/checks/ai-analysis.js +3 -3
  19. package/dist/doctor/checks/ai-analysis.js.map +1 -1
  20. package/dist/integrations/dotnet/index.js +7 -12
  21. package/dist/integrations/dotnet/index.js.map +1 -1
  22. package/dist/integrations/elixir/index.js +7 -13
  23. package/dist/integrations/elixir/index.js.map +1 -1
  24. package/dist/integrations/go/index.js +5 -11
  25. package/dist/integrations/go/index.js.map +1 -1
  26. package/dist/integrations/python/index.js +7 -13
  27. package/dist/integrations/python/index.js.map +1 -1
  28. package/dist/integrations/ruby/index.js +9 -14
  29. package/dist/integrations/ruby/index.js.map +1 -1
  30. package/dist/lib/adapters/cli-adapter.js +1 -1
  31. package/dist/lib/adapters/cli-adapter.js.map +1 -1
  32. package/dist/lib/agent-interface.js +10 -9
  33. package/dist/lib/agent-interface.js.map +1 -1
  34. package/dist/lib/agent-runner.js +24 -19
  35. package/dist/lib/agent-runner.js.map +1 -1
  36. package/dist/lib/credential-proxy.js +1 -1
  37. package/dist/lib/credential-proxy.js.map +1 -1
  38. package/dist/lib/ensure-auth.js +3 -3
  39. package/dist/lib/ensure-auth.js.map +1 -1
  40. package/dist/lib/run-with-core.js +1 -1
  41. package/dist/lib/run-with-core.js.map +1 -1
  42. package/dist/lib/token-refresh-client.js +1 -1
  43. package/dist/lib/token-refresh-client.js.map +1 -1
  44. package/dist/lib/token-refresh.js +1 -1
  45. package/dist/lib/token-refresh.js.map +1 -1
  46. package/dist/lib/version-check.js +2 -1
  47. package/dist/lib/version-check.js.map +1 -1
  48. package/dist/utils/exit-codes.js +1 -1
  49. package/dist/utils/exit-codes.js.map +1 -1
  50. package/dist/utils/help-json.js +62 -23
  51. package/dist/utils/help-json.js.map +1 -1
  52. package/package.json +2 -3
  53. package/.claude-plugin/plugin.json +0 -13
  54. package/skills/workos-authkit-base/SKILL.md +0 -123
  55. package/skills/workos-authkit-nextjs/SKILL.md +0 -247
  56. package/skills/workos-authkit-react/SKILL.md +0 -91
  57. package/skills/workos-authkit-react-router/SKILL.md +0 -107
  58. package/skills/workos-authkit-sveltekit/SKILL.md +0 -160
  59. package/skills/workos-authkit-tanstack-start/SKILL.md +0 -300
  60. package/skills/workos-authkit-vanilla-js/SKILL.md +0 -83
  61. package/skills/workos-dotnet/SKILL.md +0 -163
  62. package/skills/workos-elixir/SKILL.md +0 -194
  63. package/skills/workos-go/SKILL.md +0 -191
  64. package/skills/workos-kotlin/SKILL.md +0 -161
  65. package/skills/workos-management/SKILL.md +0 -250
  66. package/skills/workos-node/SKILL.md +0 -164
  67. package/skills/workos-php/SKILL.md +0 -127
  68. package/skills/workos-php-laravel/SKILL.md +0 -147
  69. package/skills/workos-python/SKILL.md +0 -159
  70. package/skills/workos-ruby/SKILL.md +0 -163
@@ -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 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,164 +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 3: Install SDK
40
-
41
- ```
42
- pnpm-lock.yaml → pnpm add @workos-inc/node dotenv cookie-parser
43
- yarn.lock → yarn add @workos-inc/node dotenv cookie-parser
44
- bun.lockb → bun add @workos-inc/node dotenv cookie-parser
45
- else → npm install @workos-inc/node dotenv cookie-parser
46
- ```
47
-
48
- For TypeScript, also install types: `pnpm add -D @types/cookie-parser`
49
-
50
- **Verify:** `@workos-inc/node` in package.json dependencies
51
-
52
- ## Step 4: Initialize WorkOS Client
53
-
54
- Adapt to detected module system (ESM vs CJS):
55
-
56
- **ESM/TypeScript:**
57
-
58
- ```typescript
59
- import { WorkOS } from '@workos-inc/node';
60
- const workos = new WorkOS(process.env.WORKOS_API_KEY, {
61
- clientId: process.env.WORKOS_CLIENT_ID,
62
- });
63
- ```
64
-
65
- **CJS:**
66
-
67
- ```javascript
68
- const { WorkOS } = require('@workos-inc/node');
69
- const workos = new WorkOS(process.env.WORKOS_API_KEY, {
70
- clientId: process.env.WORKOS_CLIENT_ID,
71
- });
72
- ```
73
-
74
- ## Step 5: Integrate Authentication
75
-
76
- ### If Express
77
-
78
- Follow the quickstart pattern:
79
-
80
- 1. **`/login` route** — call `workos.userManagement.getAuthorizationUrl({ provider: 'authkit', redirectUri: ..., clientId: ... })`, redirect
81
- 2. **`/callback` route** — call `workos.userManagement.authenticateWithCode({ code, clientId })`, store session via sealed session or express-session
82
- 3. **`/logout` route** — clear session cookie, redirect
83
- 4. **Cookie middleware** — `app.use(cookieParser())`
84
- 5. **Session-aware home route** — read session, display user info
85
-
86
- **Session handling options (pick one):**
87
-
88
- - **Sealed sessions** (recommended, from quickstart): use `sealSession: true` in authenticateWithCode, store sealed cookie, use `loadSealedSession` for verification
89
- - **express-session**: install `express-session`, configure middleware before routes, store user in `req.session`
90
-
91
- ### If Fastify
92
-
93
- 1. Register `@fastify/cookie` plugin
94
- 2. Create `/login`, `/callback`, `/logout` routes using Fastify route syntax
95
- 3. Use `reply.redirect()` for redirects
96
- 4. Store session in signed cookie
97
-
98
- ### If Hono
99
-
100
- 1. Create `/login`, `/callback`, `/logout` routes using Hono router
101
- 2. Use `c.redirect()` for redirects
102
- 3. Use Hono's cookie helpers for session
103
-
104
- ### If Koa
105
-
106
- 1. Install `koa-router` if not present
107
- 2. Create auth routes on router
108
- 3. Use `ctx.redirect()` for redirects
109
- 4. Use `koa-session` for session management
110
-
111
- ### If Vanilla Node.js (no framework detected)
112
-
113
- Install Express and follow the Express pattern above. This matches the official quickstart.
114
-
115
- ## Step 6: Environment Setup
116
-
117
- Create `.env` if it doesn't exist. Do NOT overwrite existing values:
118
-
119
- ```
120
- WORKOS_API_KEY=sk_...
121
- WORKOS_CLIENT_ID=client_...
122
- WORKOS_REDIRECT_URI=http://localhost:3000/callback
123
- WORKOS_COOKIE_PASSWORD=<generate with openssl rand -base64 32>
124
- ```
125
-
126
- Ensure `.env` is in `.gitignore`.
127
-
128
- ## Step 7: Verification
129
-
130
- **TypeScript:** `npx tsc --noEmit`
131
- **JavaScript:** `node --check <entry-file>`
132
-
133
- ### Checklist
134
-
135
- - [ ] SDK installed (`@workos-inc/node` in package.json)
136
- - [ ] WorkOS client initialized
137
- - [ ] Login route redirects to AuthKit
138
- - [ ] Callback route exchanges code for user
139
- - [ ] Logout route clears session
140
- - [ ] `.env` has required variables
141
- - [ ] Build/syntax check passes
142
-
143
- ## Error Recovery
144
-
145
- ### Module not found: @workos-inc/node
146
-
147
- Re-run install for detected package manager.
148
-
149
- ### Session not persisting
150
-
151
- If using express-session: ensure middleware registered BEFORE routes.
152
- If using sealed sessions: ensure cookie is being set with correct options (httpOnly, secure in prod, sameSite: 'lax').
153
-
154
- ### Callback returns 404
155
-
156
- Route path must match WORKOS_REDIRECT_URI exactly.
157
-
158
- ### ESM/CJS mismatch
159
-
160
- Check `"type"` field in package.json — `"module"` = ESM (import/export), absent = CJS (require).
161
-
162
- ### TypeScript errors
163
-
164
- Install missing types: `@types/express`, `@types/cookie-parser`, `@types/express-session`.
@@ -1,127 +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://github.com/workos/workos-php/blob/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 3: Install SDK
34
-
35
- ```bash
36
- composer require workos/workos-php
37
- ```
38
-
39
- **Verify:** Check `composer.json` contains `workos/workos-php` in require section.
40
-
41
- Also install a dotenv library if not present:
42
-
43
- ```bash
44
- composer require vlucas/phpdotenv
45
- ```
46
-
47
- ## Step 4: Create Bootstrap File
48
-
49
- Create a bootstrap or config file (e.g., `config.php` or `bootstrap.php`) that:
50
-
51
- 1. Requires Composer autoloader: `require_once __DIR__ . '/vendor/autoload.php';`
52
- 2. Loads `.env` using phpdotenv
53
- 3. Initializes the WorkOS SDK client with API key
54
-
55
- Use SDK initialization from README. Do NOT hardcode credentials.
56
-
57
- ## Step 5: Create Auth Endpoint Files
58
-
59
- ### `login.php`
60
-
61
- - Initialize WorkOS client (include bootstrap)
62
- - Generate authorization URL using SDK
63
- - Redirect user to WorkOS AuthKit
64
-
65
- ### `callback.php`
66
-
67
- - Initialize WorkOS client (include bootstrap)
68
- - Exchange authorization code from `$_GET['code']` for user profile using SDK
69
- - Start session, store user data
70
- - Redirect to home/dashboard
71
-
72
- ### `logout.php`
73
-
74
- - Destroy session
75
- - Redirect to home page
76
-
77
- Use SDK methods from README for all WorkOS API calls. Do NOT construct OAuth URLs manually.
78
-
79
- ## Step 6: Create Home Page
80
-
81
- Create or update `index.php` to show:
82
-
83
- - Sign in link (`login.php`) when no session
84
- - User info and sign out link (`logout.php`) when session exists
85
-
86
- ## Verification Checklist (ALL MUST PASS)
87
-
88
- ```bash
89
- # 1. SDK installed
90
- composer show workos/workos-php
91
-
92
- # 2. Auth files exist
93
- ls login.php callback.php logout.php
94
-
95
- # 3. No syntax errors
96
- php -l login.php
97
- php -l callback.php
98
- php -l logout.php
99
- php -l index.php
100
-
101
- # 4. Autoloader exists
102
- ls vendor/autoload.php
103
- ```
104
-
105
- ## Error Recovery
106
-
107
- ### "Class WorkOS\WorkOS not found"
108
-
109
- - Verify `composer require` completed successfully
110
- - Check `vendor/autoload.php` is required in bootstrap
111
- - Run `composer dump-autoload`
112
-
113
- ### Session issues
114
-
115
- - Ensure `session_start()` is called before any session access
116
- - Check PHP session configuration (`session.save_path`)
117
-
118
- ### Redirect URI mismatch
119
-
120
- - Compare callback file path to `WORKOS_REDIRECT_URI` in `.env`
121
- - URLs must match exactly (including trailing slash)
122
-
123
- ### Environment variables not loading
124
-
125
- - Verify `.env` file exists in project root
126
- - Verify phpdotenv is installed and loaded in bootstrap
127
- - Check file permissions on `.env`
@@ -1,147 +0,0 @@
1
- ---
2
- name: workos-php-laravel
3
- description: Integrate WorkOS AuthKit with Laravel applications. Uses the dedicated workos-php-laravel SDK with service provider, middleware, and config publishing.
4
- ---
5
-
6
- # WorkOS AuthKit for Laravel
7
-
8
- ## Step 1: Fetch SDK Documentation (BLOCKING)
9
-
10
- **STOP. Do not proceed until complete.**
11
-
12
- WebFetch: `https://github.com/workos/workos-php-laravel/blob/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 `artisan` file exists at project root
21
- - Confirm `composer.json` contains `laravel/framework` dependency
22
- - Confirm `app/` and `routes/` directories exist
23
-
24
- ### Environment Variables
25
-
26
- Check `.env` for:
27
-
28
- - `WORKOS_API_KEY` - starts with `sk_`
29
- - `WORKOS_CLIENT_ID` - starts with `client_`
30
- - `WORKOS_REDIRECT_URI` - valid callback URL (e.g., `http://localhost:8000/auth/callback`)
31
-
32
- If `.env` exists but is missing these variables, append them. If `.env` doesn't exist, copy `.env.example` and add them.
33
-
34
- ## Step 3: Install SDK
35
-
36
- ```bash
37
- composer require workos/workos-php-laravel
38
- ```
39
-
40
- **Verify:** Check `composer.json` contains `workos/workos-php-laravel` in require section before continuing.
41
-
42
- ## Step 4: Publish Configuration
43
-
44
- ```bash
45
- php artisan vendor:publish --provider="WorkOS\Laravel\WorkOSServiceProvider"
46
- ```
47
-
48
- This creates `config/workos.php`. Verify the file exists after publishing.
49
-
50
- If the artisan command fails, check README for the correct provider class name — it may differ.
51
-
52
- ## Step 5: Configure Environment
53
-
54
- Ensure `.env` contains:
55
-
56
- ```
57
- WORKOS_API_KEY=sk_...
58
- WORKOS_CLIENT_ID=client_...
59
- WORKOS_REDIRECT_URI=http://localhost:8000/auth/callback
60
- ```
61
-
62
- Also ensure `config/workos.php` reads these env vars correctly. Check README for exact config structure.
63
-
64
- ## Step 6: Create Auth Controller
65
-
66
- Create `app/Http/Controllers/AuthController.php` with methods for:
67
-
68
- - `login()` — Redirect to WorkOS AuthKit authorization URL
69
- - `callback()` — Handle OAuth callback, exchange code for user profile
70
- - `logout()` — Clear session and redirect
71
-
72
- Use SDK methods from README. Do NOT construct OAuth URLs manually.
73
-
74
- ## Step 7: Add Routes
75
-
76
- Add to `routes/web.php`:
77
-
78
- ```php
79
- use App\Http\Controllers\AuthController;
80
-
81
- Route::get('/login', [AuthController::class, 'login'])->name('login');
82
- Route::get('/auth/callback', [AuthController::class, 'callback']);
83
- Route::get('/logout', [AuthController::class, 'logout'])->name('logout');
84
- ```
85
-
86
- Ensure the callback route path matches `WORKOS_REDIRECT_URI`.
87
-
88
- ## Step 8: Add Middleware (if applicable)
89
-
90
- Check README for any authentication middleware the SDK provides. If available:
91
-
92
- 1. Register middleware in `app/Http/Kernel.php` or `bootstrap/app.php` (Laravel 11+)
93
- 2. Apply to routes that require authentication
94
-
95
- For Laravel 11+, middleware is registered in `bootstrap/app.php` instead of `Kernel.php`.
96
-
97
- ## Step 9: Add UI Integration
98
-
99
- Update the home page or dashboard view to show:
100
-
101
- - Sign in link when user is not authenticated
102
- - User info and sign out link when authenticated
103
-
104
- Use Blade directives or SDK helpers from README.
105
-
106
- ## Verification Checklist (ALL MUST PASS)
107
-
108
- ```bash
109
- # 1. Config file exists
110
- ls config/workos.php
111
-
112
- # 2. Controller exists
113
- ls app/Http/Controllers/AuthController.php
114
-
115
- # 3. Routes registered
116
- php artisan route:list | grep -E "login|callback|logout"
117
-
118
- # 4. SDK installed
119
- composer show workos/workos-php-laravel
120
-
121
- # 5. Lint check
122
- php -l app/Http/Controllers/AuthController.php
123
- ```
124
-
125
- ## Error Recovery
126
-
127
- ### "Class WorkOS\Laravel\WorkOSServiceProvider not found"
128
-
129
- - Verify `composer require` completed successfully
130
- - Run `composer dump-autoload`
131
- - Check `vendor/workos/` directory exists
132
-
133
- ### "Route not defined"
134
-
135
- - Verify routes are in `routes/web.php`
136
- - Run `php artisan route:clear && php artisan route:cache`
137
-
138
- ### Config not loading
139
-
140
- - Verify `config/workos.php` exists
141
- - Run `php artisan config:clear`
142
- - Check `.env` variables match config keys
143
-
144
- ### Middleware issues (Laravel 11+)
145
-
146
- - Laravel 11 removed `Kernel.php` — register middleware in `bootstrap/app.php`
147
- - Check README for Laravel version-specific instructions