workos 0.3.3 → 0.5.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 (152) hide show
  1. package/dist/bin.js +57 -9
  2. package/dist/bin.js.map +1 -1
  3. package/dist/commands/doctor.d.ts +10 -0
  4. package/dist/commands/doctor.js +30 -0
  5. package/dist/commands/doctor.js.map +1 -0
  6. package/dist/commands/login.js +21 -1
  7. package/dist/commands/login.js.map +1 -1
  8. package/dist/doctor/checks/connectivity.d.ts +2 -0
  9. package/dist/doctor/checks/connectivity.js +35 -0
  10. package/dist/doctor/checks/connectivity.js.map +1 -0
  11. package/dist/doctor/checks/dashboard.d.ts +3 -0
  12. package/dist/doctor/checks/dashboard.js +123 -0
  13. package/dist/doctor/checks/dashboard.js.map +1 -0
  14. package/dist/doctor/checks/environment.d.ts +2 -0
  15. package/dist/doctor/checks/environment.js +68 -0
  16. package/dist/doctor/checks/environment.js.map +1 -0
  17. package/dist/doctor/checks/framework.d.ts +2 -0
  18. package/dist/doctor/checks/framework.js +75 -0
  19. package/dist/doctor/checks/framework.js.map +1 -0
  20. package/dist/doctor/checks/runtime.d.ts +2 -0
  21. package/dist/doctor/checks/runtime.js +20 -0
  22. package/dist/doctor/checks/runtime.js.map +1 -0
  23. package/dist/doctor/checks/sdk.d.ts +2 -0
  24. package/dist/doctor/checks/sdk.js +111 -0
  25. package/dist/doctor/checks/sdk.js.map +1 -0
  26. package/dist/doctor/clipboard.d.ts +1 -0
  27. package/dist/doctor/clipboard.js +43 -0
  28. package/dist/doctor/clipboard.js.map +1 -0
  29. package/dist/doctor/index.d.ts +6 -0
  30. package/dist/doctor/index.js +94 -0
  31. package/dist/doctor/index.js.map +1 -0
  32. package/dist/doctor/issues.d.ts +58 -0
  33. package/dist/doctor/issues.js +134 -0
  34. package/dist/doctor/issues.js.map +1 -0
  35. package/dist/doctor/json-output.d.ts +2 -0
  36. package/dist/doctor/json-output.js +4 -0
  37. package/dist/doctor/json-output.js.map +1 -0
  38. package/dist/doctor/output.d.ts +5 -0
  39. package/dist/doctor/output.js +149 -0
  40. package/dist/doctor/output.js.map +1 -0
  41. package/dist/doctor/types.d.ts +105 -0
  42. package/dist/doctor/types.js +2 -0
  43. package/dist/doctor/types.js.map +1 -0
  44. package/dist/integrations/dotnet/index.d.ts +8 -0
  45. package/dist/integrations/dotnet/index.js +163 -0
  46. package/dist/integrations/dotnet/index.js.map +1 -0
  47. package/dist/integrations/elixir/index.d.ts +8 -0
  48. package/dist/integrations/elixir/index.js +152 -0
  49. package/dist/integrations/elixir/index.js.map +1 -0
  50. package/dist/integrations/go/index.d.ts +11 -0
  51. package/dist/integrations/go/index.js +220 -0
  52. package/dist/integrations/go/index.js.map +1 -0
  53. package/dist/integrations/kotlin/index.d.ts +4 -0
  54. package/dist/integrations/kotlin/index.js +53 -0
  55. package/dist/integrations/kotlin/index.js.map +1 -0
  56. package/dist/integrations/nextjs/index.d.ts +4 -0
  57. package/dist/integrations/nextjs/index.js +90 -0
  58. package/dist/integrations/nextjs/index.js.map +1 -0
  59. package/dist/integrations/nextjs/utils.d.ts +8 -0
  60. package/dist/integrations/nextjs/utils.js +53 -0
  61. package/dist/integrations/nextjs/utils.js.map +1 -0
  62. package/dist/integrations/node/index.d.ts +4 -0
  63. package/dist/integrations/node/index.js +52 -0
  64. package/dist/integrations/node/index.js.map +1 -0
  65. package/dist/integrations/php/index.d.ts +4 -0
  66. package/dist/integrations/php/index.js +51 -0
  67. package/dist/integrations/php/index.js.map +1 -0
  68. package/dist/integrations/php-laravel/index.d.ts +4 -0
  69. package/dist/integrations/php-laravel/index.js +51 -0
  70. package/dist/integrations/php-laravel/index.js.map +1 -0
  71. package/dist/integrations/python/index.d.ts +9 -0
  72. package/dist/integrations/python/index.js +254 -0
  73. package/dist/integrations/python/index.js.map +1 -0
  74. package/dist/integrations/react/index.d.ts +4 -0
  75. package/dist/integrations/react/index.js +49 -0
  76. package/dist/integrations/react/index.js.map +1 -0
  77. package/dist/integrations/react-router/index.d.ts +4 -0
  78. package/dist/integrations/react-router/index.js +94 -0
  79. package/dist/integrations/react-router/index.js.map +1 -0
  80. package/dist/integrations/react-router/utils.d.ts +10 -0
  81. package/dist/integrations/react-router/utils.js +146 -0
  82. package/dist/integrations/react-router/utils.js.map +1 -0
  83. package/dist/integrations/ruby/index.d.ts +8 -0
  84. package/dist/integrations/ruby/index.js +142 -0
  85. package/dist/integrations/ruby/index.js.map +1 -0
  86. package/dist/integrations/sveltekit/index.d.ts +4 -0
  87. package/dist/integrations/sveltekit/index.js +50 -0
  88. package/dist/integrations/sveltekit/index.js.map +1 -0
  89. package/dist/integrations/tanstack-start/index.d.ts +4 -0
  90. package/dist/integrations/tanstack-start/index.js +51 -0
  91. package/dist/integrations/tanstack-start/index.js.map +1 -0
  92. package/dist/integrations/vanilla-js/index.d.ts +4 -0
  93. package/dist/integrations/vanilla-js/index.js +49 -0
  94. package/dist/integrations/vanilla-js/index.js.map +1 -0
  95. package/dist/lib/agent-interface.js +66 -1
  96. package/dist/lib/agent-interface.js.map +1 -1
  97. package/dist/lib/config.d.ts +32 -58
  98. package/dist/lib/config.js +19 -70
  99. package/dist/lib/config.js.map +1 -1
  100. package/dist/lib/constants.d.ts +17 -14
  101. package/dist/lib/constants.js +12 -31
  102. package/dist/lib/constants.js.map +1 -1
  103. package/dist/lib/credential-store.d.ts +28 -0
  104. package/dist/lib/credential-store.js +150 -0
  105. package/dist/lib/credential-store.js.map +1 -0
  106. package/dist/lib/credentials.d.ts +3 -37
  107. package/dist/lib/credentials.js +2 -85
  108. package/dist/lib/credentials.js.map +1 -1
  109. package/dist/lib/framework-config.d.ts +13 -4
  110. package/dist/lib/framework-config.js.map +1 -1
  111. package/dist/lib/language-detection.d.ts +20 -0
  112. package/dist/lib/language-detection.js +96 -0
  113. package/dist/lib/language-detection.js.map +1 -0
  114. package/dist/lib/port-detection.js +4 -2
  115. package/dist/lib/port-detection.js.map +1 -1
  116. package/dist/lib/registry.d.ts +43 -0
  117. package/dist/lib/registry.js +96 -0
  118. package/dist/lib/registry.js.map +1 -0
  119. package/dist/lib/run-with-core.js +70 -26
  120. package/dist/lib/run-with-core.js.map +1 -1
  121. package/dist/nextjs/nextjs-installer-agent.d.ts +3 -4
  122. package/dist/nextjs/nextjs-installer-agent.js +3 -94
  123. package/dist/nextjs/nextjs-installer-agent.js.map +1 -1
  124. package/dist/nextjs/utils.d.ts +4 -8
  125. package/dist/nextjs/utils.js +4 -52
  126. package/dist/nextjs/utils.js.map +1 -1
  127. package/dist/react/react-installer-agent.d.ts +4 -2
  128. package/dist/react/react-installer-agent.js +4 -46
  129. package/dist/react/react-installer-agent.js.map +1 -1
  130. package/dist/react-router/react-router-installer-agent.d.ts +2 -4
  131. package/dist/react-router/react-router-installer-agent.js +2 -100
  132. package/dist/react-router/react-router-installer-agent.js.map +1 -1
  133. package/dist/react-router/utils.d.ts +2 -17
  134. package/dist/react-router/utils.js +2 -207
  135. package/dist/react-router/utils.js.map +1 -1
  136. package/dist/tanstack-start/tanstack-start-installer-agent.d.ts +4 -2
  137. package/dist/tanstack-start/tanstack-start-installer-agent.js +4 -48
  138. package/dist/tanstack-start/tanstack-start-installer-agent.js.map +1 -1
  139. package/dist/vanilla-js/vanilla-js-installer-agent.d.ts +4 -2
  140. package/dist/vanilla-js/vanilla-js-installer-agent.js +4 -46
  141. package/dist/vanilla-js/vanilla-js-installer-agent.js.map +1 -1
  142. package/package.json +9 -6
  143. package/skills/workos-authkit-sveltekit/SKILL.md +160 -0
  144. package/skills/workos-dotnet/SKILL.md +163 -0
  145. package/skills/workos-elixir/SKILL.md +194 -0
  146. package/skills/workos-go/SKILL.md +191 -0
  147. package/skills/workos-kotlin/SKILL.md +161 -0
  148. package/skills/workos-node/SKILL.md +164 -0
  149. package/skills/workos-php/SKILL.md +127 -0
  150. package/skills/workos-php-laravel/SKILL.md +147 -0
  151. package/skills/workos-python/SKILL.md +159 -0
  152. package/skills/workos-ruby/SKILL.md +163 -0
@@ -0,0 +1,164 @@
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`.
@@ -0,0 +1,127 @@
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`
@@ -0,0 +1,147 @@
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
@@ -0,0 +1,159 @@
1
+ ---
2
+ name: workos-python
3
+ description: Integrate WorkOS AuthKit with Python applications. Adapts to Django, Flask, FastAPI, or vanilla Python. Server-side authentication with redirect-based OAuth flow.
4
+ ---
5
+
6
+ # WorkOS AuthKit for Python
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-python/main/README.md`
13
+
14
+ Also fetch the AuthKit quickstart for reference:
15
+ WebFetch: `https://workos.com/docs/authkit/vanilla/python`
16
+
17
+ The README is the source of truth for SDK API usage. If this skill conflicts with README, follow README.
18
+
19
+ ## Step 2: Detect Framework
20
+
21
+ Examine the project to determine which Python web framework is in use:
22
+
23
+ ```
24
+ manage.py exists? → Django
25
+ settings.py has django imports? → Confirmed Django
26
+
27
+ Gemfile/requirements has 'fastapi'? → FastAPI
28
+ main.py has FastAPI() instance? → Confirmed FastAPI
29
+
30
+ requirements has 'flask'? → Flask
31
+ server.py/app.py has Flask() instance? → Confirmed Flask
32
+
33
+ None of the above? → Vanilla Python (use Flask quickstart pattern)
34
+ ```
35
+
36
+ **Adapt all subsequent steps to the detected framework.** Do not force one framework onto another.
37
+
38
+ ## Step 3: Pre-Flight Validation
39
+
40
+ ### Package Manager Detection
41
+
42
+ ```
43
+ uv.lock exists? → uv add
44
+ pyproject.toml has [tool.poetry]? → poetry add
45
+ Pipfile exists? → pipenv install
46
+ requirements.txt exists? → pip install (+ append to requirements.txt)
47
+ else → pip install
48
+ ```
49
+
50
+ ### Environment Variables
51
+
52
+ Check `.env` for:
53
+
54
+ - `WORKOS_API_KEY` - starts with `sk_`
55
+ - `WORKOS_CLIENT_ID` - starts with `client_`
56
+
57
+ ## Step 4: Install SDK
58
+
59
+ Install using the detected package manager:
60
+
61
+ ```bash
62
+ # uv
63
+ uv add workos python-dotenv
64
+
65
+ # poetry
66
+ poetry add workos python-dotenv
67
+
68
+ # pip
69
+ pip install workos python-dotenv
70
+ ```
71
+
72
+ If using `requirements.txt`, also append `workos` and `python-dotenv` to it.
73
+
74
+ **Verify:** `python -c "import workos; print('OK')"`
75
+
76
+ ## Step 5: Integrate Authentication
77
+
78
+ ### If Django
79
+
80
+ 1. **Configure settings.py** — add `import os` + `from dotenv import load_dotenv` + `load_dotenv()` at top. Add `WORKOS_API_KEY` and `WORKOS_CLIENT_ID` from `os.environ.get()`.
81
+ 2. **Create auth views** — create `auth_views.py` (or add to existing views):
82
+ - `login_view`: call SDK's `get_authorization_url()` with `provider='authkit'`, redirect
83
+ - `callback_view`: call `authenticate_with_code()` with the code param, store user in `request.session`
84
+ - `logout_view`: flush session, redirect
85
+ 3. **Add URL patterns** — add `auth/login/`, `auth/callback/`, `auth/logout/` to `urls.py`
86
+ 4. **Update templates** — add login/logout links using `{% url %}` tags
87
+
88
+ ### If Flask
89
+
90
+ Follow the quickstart pattern exactly:
91
+
92
+ 1. **Initialize WorkOS client** in `server.py` / `app.py`:
93
+ ```python
94
+ from workos import WorkOSClient
95
+ workos = WorkOSClient(api_key=os.getenv("WORKOS_API_KEY"), client_id=os.getenv("WORKOS_CLIENT_ID"))
96
+ ```
97
+ 2. **Create `/login` route** — call `workos.user_management.get_authorization_url(provider="authkit", redirect_uri="...")`, redirect
98
+ 3. **Create `/callback` route** — call `workos.user_management.authenticate_with_code(code=code)`, set session cookie
99
+ 4. **Create `/logout` route** — clear session, redirect
100
+ 5. **Update home route** — show user info if session exists
101
+
102
+ ### If FastAPI
103
+
104
+ 1. **Initialize WorkOS client** in main app file
105
+ 2. **Create `/login` endpoint** — generate auth URL, return `RedirectResponse`
106
+ 3. **Create `/callback` endpoint** — exchange code, store in session/cookie
107
+ 4. **Create `/logout` endpoint** — clear session
108
+ 5. Use `Depends()` for auth middleware on protected routes
109
+
110
+ ### If Vanilla Python (no framework detected)
111
+
112
+ Install Flask and follow the Flask pattern above. This matches the official quickstart.
113
+
114
+ ## Step 6: Environment Setup
115
+
116
+ Create/update `.env` with WorkOS credentials. Do NOT overwrite existing values.
117
+
118
+ ```
119
+ WORKOS_API_KEY=sk_...
120
+ WORKOS_CLIENT_ID=client_...
121
+ ```
122
+
123
+ ## Step 7: Verification Checklist
124
+
125
+ ```bash
126
+ # 1. SDK importable
127
+ python -c "import workos; print('OK')"
128
+
129
+ # 2. Credentials configured
130
+ python -c "
131
+ from dotenv import load_dotenv; import os; load_dotenv()
132
+ assert os.environ.get('WORKOS_API_KEY','').startswith('sk_'), 'Missing WORKOS_API_KEY'
133
+ assert os.environ.get('WORKOS_CLIENT_ID','').startswith('client_'), 'Missing WORKOS_CLIENT_ID'
134
+ print('Credentials OK')
135
+ "
136
+
137
+ # 3. Framework-specific check
138
+ # Django: python manage.py check
139
+ # Flask: python -m py_compile server.py
140
+ # FastAPI: python -m py_compile main.py
141
+ ```
142
+
143
+ ## Error Recovery
144
+
145
+ ### "ModuleNotFoundError: No module named 'workos'"
146
+
147
+ Re-run the install command for the detected package manager.
148
+
149
+ ### Django: "CSRF verification failed"
150
+
151
+ Auth callback receives GET requests from WorkOS. Ensure callback view uses GET, not POST. Or add `@csrf_exempt`.
152
+
153
+ ### Flask: Session not persisting
154
+
155
+ Ensure `app.secret_key` is set (required for Flask sessions).
156
+
157
+ ### Virtual environment not active
158
+
159
+ Check for `.venv/`, `venv/`, or poetry-managed environments. Activate before running install.