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.
- package/README.md +5 -6
- package/dist/bin.js +39 -14
- package/dist/bin.js.map +1 -1
- package/dist/commands/install-skill.d.ts +0 -1
- package/dist/commands/install-skill.js +2 -10
- package/dist/commands/install-skill.js.map +1 -1
- package/dist/commands/list-skills.d.ts +4 -0
- package/dist/commands/list-skills.js +52 -0
- package/dist/commands/list-skills.js.map +1 -0
- package/dist/commands/login.d.ts +8 -0
- package/dist/commands/login.js +41 -1
- package/dist/commands/login.js.map +1 -1
- package/dist/commands/uninstall-skill.d.ts +11 -0
- package/dist/commands/uninstall-skill.js +116 -0
- package/dist/commands/uninstall-skill.js.map +1 -0
- package/dist/integrations/dotnet/index.js +7 -12
- package/dist/integrations/dotnet/index.js.map +1 -1
- package/dist/integrations/elixir/index.js +7 -13
- package/dist/integrations/elixir/index.js.map +1 -1
- package/dist/integrations/go/index.js +5 -11
- package/dist/integrations/go/index.js.map +1 -1
- package/dist/integrations/python/index.js +7 -13
- package/dist/integrations/python/index.js.map +1 -1
- package/dist/integrations/ruby/index.js +9 -14
- package/dist/integrations/ruby/index.js.map +1 -1
- package/dist/lib/agent-interface.js +5 -4
- package/dist/lib/agent-interface.js.map +1 -1
- package/dist/lib/agent-runner.js +24 -19
- package/dist/lib/agent-runner.js.map +1 -1
- package/dist/utils/help-json.js +55 -21
- package/dist/utils/help-json.js.map +1 -1
- package/package.json +2 -3
- package/.claude-plugin/plugin.json +0 -13
- package/skills/workos-authkit-base/SKILL.md +0 -123
- package/skills/workos-authkit-nextjs/SKILL.md +0 -247
- package/skills/workos-authkit-react/SKILL.md +0 -100
- package/skills/workos-authkit-react-router/SKILL.md +0 -117
- package/skills/workos-authkit-sveltekit/SKILL.md +0 -208
- package/skills/workos-authkit-tanstack-start/SKILL.md +0 -314
- package/skills/workos-authkit-vanilla-js/SKILL.md +0 -92
- package/skills/workos-dotnet/SKILL.md +0 -163
- package/skills/workos-elixir/SKILL.md +0 -231
- package/skills/workos-go/SKILL.md +0 -226
- package/skills/workos-kotlin/SKILL.md +0 -195
- package/skills/workos-management/SKILL.md +0 -250
- package/skills/workos-node/SKILL.md +0 -197
- package/skills/workos-php/SKILL.md +0 -160
- package/skills/workos-php-laravel/SKILL.md +0 -182
- package/skills/workos-python/SKILL.md +0 -193
- package/skills/workos-ruby/SKILL.md +0 -198
|
@@ -1,182 +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://raw.githubusercontent.com/workos/workos-php-laravel/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 2b: Partial Install Recovery
|
|
35
|
-
|
|
36
|
-
Before creating new files, check if a previous AuthKit attempt exists:
|
|
37
|
-
|
|
38
|
-
1. Check if `workos/workos-php-laravel` is already in `composer.json`
|
|
39
|
-
2. Check if `config/workos.php` exists but no auth controller or routes are wired
|
|
40
|
-
3. If partial install detected:
|
|
41
|
-
- Do NOT reinstall the SDK (it's already there)
|
|
42
|
-
- Do NOT re-publish config if `config/workos.php` already exists
|
|
43
|
-
- Read existing files to understand what's done vs missing
|
|
44
|
-
- Complete the integration by filling gaps (controller, routes, middleware)
|
|
45
|
-
- Preserve any working code — only fix what's broken
|
|
46
|
-
- Check for missing auth controller or routes (most common gap)
|
|
47
|
-
|
|
48
|
-
## Step 2c: Existing Auth System Detection
|
|
49
|
-
|
|
50
|
-
Check for existing authentication before integrating:
|
|
51
|
-
|
|
52
|
-
```
|
|
53
|
-
composer.json has 'laravel/breeze'? → Breeze auth scaffolding
|
|
54
|
-
composer.json has 'laravel/jetstream'? → Jetstream auth
|
|
55
|
-
composer.json has 'laravel/fortify'? → Fortify auth backend
|
|
56
|
-
app/Http/Controllers/Auth/ exists? → Auth controllers present
|
|
57
|
-
routes/auth.php exists? → Auth routes file
|
|
58
|
-
```
|
|
59
|
-
|
|
60
|
-
If existing auth detected:
|
|
61
|
-
|
|
62
|
-
- Do NOT remove or disable it
|
|
63
|
-
- Add WorkOS AuthKit alongside the existing system
|
|
64
|
-
- If Laravel session is already configured, reuse it for WorkOS
|
|
65
|
-
- Create separate route paths for WorkOS auth (e.g., `/auth/workos/login` if `/login` is taken)
|
|
66
|
-
- Ensure existing auth routes continue to work unchanged
|
|
67
|
-
- Document in code comments how to migrate fully to WorkOS later
|
|
68
|
-
|
|
69
|
-
## Step 3: Install SDK
|
|
70
|
-
|
|
71
|
-
```bash
|
|
72
|
-
composer require workos/workos-php-laravel
|
|
73
|
-
```
|
|
74
|
-
|
|
75
|
-
**Verify:** Check `composer.json` contains `workos/workos-php-laravel` in require section before continuing.
|
|
76
|
-
|
|
77
|
-
## Step 4: Publish Configuration
|
|
78
|
-
|
|
79
|
-
```bash
|
|
80
|
-
php artisan vendor:publish --provider="WorkOS\Laravel\WorkOSServiceProvider"
|
|
81
|
-
```
|
|
82
|
-
|
|
83
|
-
This creates `config/workos.php`. Verify the file exists after publishing.
|
|
84
|
-
|
|
85
|
-
If the artisan command fails, check README for the correct provider class name — it may differ.
|
|
86
|
-
|
|
87
|
-
## Step 5: Configure Environment
|
|
88
|
-
|
|
89
|
-
Ensure `.env` contains:
|
|
90
|
-
|
|
91
|
-
```
|
|
92
|
-
WORKOS_API_KEY=sk_...
|
|
93
|
-
WORKOS_CLIENT_ID=client_...
|
|
94
|
-
WORKOS_REDIRECT_URI=http://localhost:8000/auth/callback
|
|
95
|
-
```
|
|
96
|
-
|
|
97
|
-
Also ensure `config/workos.php` reads these env vars correctly. Check README for exact config structure.
|
|
98
|
-
|
|
99
|
-
## Step 6: Create Auth Controller
|
|
100
|
-
|
|
101
|
-
Create `app/Http/Controllers/AuthController.php` with methods for:
|
|
102
|
-
|
|
103
|
-
- `login()` — Redirect to WorkOS AuthKit authorization URL
|
|
104
|
-
- `callback()` — Handle OAuth callback, exchange code for user profile
|
|
105
|
-
- `logout()` — Clear session and redirect
|
|
106
|
-
|
|
107
|
-
Use SDK methods from README. Do NOT construct OAuth URLs manually.
|
|
108
|
-
|
|
109
|
-
## Step 7: Add Routes
|
|
110
|
-
|
|
111
|
-
Add to `routes/web.php`:
|
|
112
|
-
|
|
113
|
-
```php
|
|
114
|
-
use App\Http\Controllers\AuthController;
|
|
115
|
-
|
|
116
|
-
Route::get('/login', [AuthController::class, 'login'])->name('login');
|
|
117
|
-
Route::get('/auth/callback', [AuthController::class, 'callback']);
|
|
118
|
-
Route::get('/logout', [AuthController::class, 'logout'])->name('logout');
|
|
119
|
-
```
|
|
120
|
-
|
|
121
|
-
Ensure the callback route path matches `WORKOS_REDIRECT_URI`.
|
|
122
|
-
|
|
123
|
-
## Step 8: Add Middleware (if applicable)
|
|
124
|
-
|
|
125
|
-
Check README for any authentication middleware the SDK provides. If available:
|
|
126
|
-
|
|
127
|
-
1. Register middleware in `app/Http/Kernel.php` or `bootstrap/app.php` (Laravel 11+)
|
|
128
|
-
2. Apply to routes that require authentication
|
|
129
|
-
|
|
130
|
-
For Laravel 11+, middleware is registered in `bootstrap/app.php` instead of `Kernel.php`.
|
|
131
|
-
|
|
132
|
-
## Step 9: Add UI Integration
|
|
133
|
-
|
|
134
|
-
Update the home page or dashboard view to show:
|
|
135
|
-
|
|
136
|
-
- Sign in link when user is not authenticated
|
|
137
|
-
- User info and sign out link when authenticated
|
|
138
|
-
|
|
139
|
-
Use Blade directives or SDK helpers from README.
|
|
140
|
-
|
|
141
|
-
## Verification Checklist (ALL MUST PASS)
|
|
142
|
-
|
|
143
|
-
```bash
|
|
144
|
-
# 1. Config file exists
|
|
145
|
-
ls config/workos.php
|
|
146
|
-
|
|
147
|
-
# 2. Controller exists
|
|
148
|
-
ls app/Http/Controllers/AuthController.php
|
|
149
|
-
|
|
150
|
-
# 3. Routes registered
|
|
151
|
-
php artisan route:list | grep -E "login|callback|logout"
|
|
152
|
-
|
|
153
|
-
# 4. SDK installed
|
|
154
|
-
composer show workos/workos-php-laravel
|
|
155
|
-
|
|
156
|
-
# 5. Lint check
|
|
157
|
-
php -l app/Http/Controllers/AuthController.php
|
|
158
|
-
```
|
|
159
|
-
|
|
160
|
-
## Error Recovery
|
|
161
|
-
|
|
162
|
-
### "Class WorkOS\Laravel\WorkOSServiceProvider not found"
|
|
163
|
-
|
|
164
|
-
- Verify `composer require` completed successfully
|
|
165
|
-
- Run `composer dump-autoload`
|
|
166
|
-
- Check `vendor/workos/` directory exists
|
|
167
|
-
|
|
168
|
-
### "Route not defined"
|
|
169
|
-
|
|
170
|
-
- Verify routes are in `routes/web.php`
|
|
171
|
-
- Run `php artisan route:clear && php artisan route:cache`
|
|
172
|
-
|
|
173
|
-
### Config not loading
|
|
174
|
-
|
|
175
|
-
- Verify `config/workos.php` exists
|
|
176
|
-
- Run `php artisan config:clear`
|
|
177
|
-
- Check `.env` variables match config keys
|
|
178
|
-
|
|
179
|
-
### Middleware issues (Laravel 11+)
|
|
180
|
-
|
|
181
|
-
- Laravel 11 removed `Kernel.php` — register middleware in `bootstrap/app.php`
|
|
182
|
-
- Check README for Laravel version-specific instructions
|
|
@@ -1,193 +0,0 @@
|
|
|
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 2b: Partial Install Recovery
|
|
39
|
-
|
|
40
|
-
Before creating new files, check if a previous AuthKit attempt exists:
|
|
41
|
-
|
|
42
|
-
1. Check if `workos` is already in `requirements.txt` or `pyproject.toml`
|
|
43
|
-
2. Check for incomplete auth files — files that import `workos` but have non-functional routes (TODO comments, commented-out code, empty handlers)
|
|
44
|
-
3. If partial install detected:
|
|
45
|
-
- Do NOT reinstall the SDK (it's already there)
|
|
46
|
-
- Read existing auth files to understand what's done vs missing
|
|
47
|
-
- Complete the integration by filling gaps rather than starting fresh
|
|
48
|
-
- Preserve any working code — only fix what's broken
|
|
49
|
-
- Check for a missing `/callback` route (most common gap)
|
|
50
|
-
|
|
51
|
-
## Step 2c: Existing Auth System Detection
|
|
52
|
-
|
|
53
|
-
Check for existing authentication before integrating:
|
|
54
|
-
|
|
55
|
-
```
|
|
56
|
-
requirements.txt has 'flask-login'? → Flask-Login auth
|
|
57
|
-
requirements.txt has 'authlib'? → OAuth/OIDC auth (e.g., Auth0)
|
|
58
|
-
requirements.txt has 'django-allauth'? → Django allauth
|
|
59
|
-
manage.py exists + 'django.contrib.auth'? → Django built-in auth
|
|
60
|
-
*.py files have 'flask_login'? → Flask-Login in use
|
|
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 `flask-login` is present, use Flask-Login's session infrastructure (`login_user()`) for WorkOS auth too, rather than raw session management
|
|
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: Pre-Flight Validation
|
|
73
|
-
|
|
74
|
-
### Package Manager Detection
|
|
75
|
-
|
|
76
|
-
```
|
|
77
|
-
uv.lock exists? → uv add
|
|
78
|
-
pyproject.toml has [tool.poetry]? → poetry add
|
|
79
|
-
Pipfile exists? → pipenv install
|
|
80
|
-
requirements.txt exists? → pip install (+ append to requirements.txt)
|
|
81
|
-
else → pip install
|
|
82
|
-
```
|
|
83
|
-
|
|
84
|
-
### Environment Variables
|
|
85
|
-
|
|
86
|
-
Check `.env` for:
|
|
87
|
-
|
|
88
|
-
- `WORKOS_API_KEY` - starts with `sk_`
|
|
89
|
-
- `WORKOS_CLIENT_ID` - starts with `client_`
|
|
90
|
-
|
|
91
|
-
## Step 4: Install SDK
|
|
92
|
-
|
|
93
|
-
Install using the detected package manager:
|
|
94
|
-
|
|
95
|
-
```bash
|
|
96
|
-
# uv
|
|
97
|
-
uv add workos python-dotenv
|
|
98
|
-
|
|
99
|
-
# poetry
|
|
100
|
-
poetry add workos python-dotenv
|
|
101
|
-
|
|
102
|
-
# pip
|
|
103
|
-
pip install workos python-dotenv
|
|
104
|
-
```
|
|
105
|
-
|
|
106
|
-
If using `requirements.txt`, also append `workos` and `python-dotenv` to it.
|
|
107
|
-
|
|
108
|
-
**Verify:** `python -c "import workos; print('OK')"`
|
|
109
|
-
|
|
110
|
-
## Step 5: Integrate Authentication
|
|
111
|
-
|
|
112
|
-
### If Django
|
|
113
|
-
|
|
114
|
-
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()`.
|
|
115
|
-
2. **Create auth views** — create `auth_views.py` (or add to existing views):
|
|
116
|
-
- `login_view`: call SDK's `get_authorization_url()` with `provider='authkit'`, redirect
|
|
117
|
-
- `callback_view`: call `authenticate_with_code()` with the code param, store user in `request.session`
|
|
118
|
-
- `logout_view`: flush session, redirect
|
|
119
|
-
3. **Add URL patterns** — add `auth/login/`, `auth/callback/`, `auth/logout/` to `urls.py`
|
|
120
|
-
4. **Update templates** — add login/logout links using `{% url %}` tags
|
|
121
|
-
|
|
122
|
-
### If Flask
|
|
123
|
-
|
|
124
|
-
Follow the quickstart pattern exactly:
|
|
125
|
-
|
|
126
|
-
1. **Initialize WorkOS client** in `server.py` / `app.py`:
|
|
127
|
-
```python
|
|
128
|
-
from workos import WorkOSClient
|
|
129
|
-
workos = WorkOSClient(api_key=os.getenv("WORKOS_API_KEY"), client_id=os.getenv("WORKOS_CLIENT_ID"))
|
|
130
|
-
```
|
|
131
|
-
2. **Create `/login` route** — call `workos.user_management.get_authorization_url(provider="authkit", redirect_uri="...")`, redirect
|
|
132
|
-
3. **Create `/callback` route** — call `workos.user_management.authenticate_with_code(code=code)`, set session cookie
|
|
133
|
-
4. **Create `/logout` route** — clear session, redirect
|
|
134
|
-
5. **Update home route** — show user info if session exists
|
|
135
|
-
|
|
136
|
-
### If FastAPI
|
|
137
|
-
|
|
138
|
-
1. **Initialize WorkOS client** in main app file
|
|
139
|
-
2. **Create `/login` endpoint** — generate auth URL, return `RedirectResponse`
|
|
140
|
-
3. **Create `/callback` endpoint** — exchange code, store in session/cookie
|
|
141
|
-
4. **Create `/logout` endpoint** — clear session
|
|
142
|
-
5. Use `Depends()` for auth middleware on protected routes
|
|
143
|
-
|
|
144
|
-
### If Vanilla Python (no framework detected)
|
|
145
|
-
|
|
146
|
-
Install Flask and follow the Flask pattern above. This matches the official quickstart.
|
|
147
|
-
|
|
148
|
-
## Step 6: Environment Setup
|
|
149
|
-
|
|
150
|
-
Create/update `.env` with WorkOS credentials. Do NOT overwrite existing values.
|
|
151
|
-
|
|
152
|
-
```
|
|
153
|
-
WORKOS_API_KEY=sk_...
|
|
154
|
-
WORKOS_CLIENT_ID=client_...
|
|
155
|
-
```
|
|
156
|
-
|
|
157
|
-
## Step 7: Verification Checklist
|
|
158
|
-
|
|
159
|
-
```bash
|
|
160
|
-
# 1. SDK importable
|
|
161
|
-
python -c "import workos; print('OK')"
|
|
162
|
-
|
|
163
|
-
# 2. Credentials configured
|
|
164
|
-
python -c "
|
|
165
|
-
from dotenv import load_dotenv; import os; load_dotenv()
|
|
166
|
-
assert os.environ.get('WORKOS_API_KEY','').startswith('sk_'), 'Missing WORKOS_API_KEY'
|
|
167
|
-
assert os.environ.get('WORKOS_CLIENT_ID','').startswith('client_'), 'Missing WORKOS_CLIENT_ID'
|
|
168
|
-
print('Credentials OK')
|
|
169
|
-
"
|
|
170
|
-
|
|
171
|
-
# 3. Framework-specific check
|
|
172
|
-
# Django: python manage.py check
|
|
173
|
-
# Flask: python -m py_compile server.py
|
|
174
|
-
# FastAPI: python -m py_compile main.py
|
|
175
|
-
```
|
|
176
|
-
|
|
177
|
-
## Error Recovery
|
|
178
|
-
|
|
179
|
-
### "ModuleNotFoundError: No module named 'workos'"
|
|
180
|
-
|
|
181
|
-
Re-run the install command for the detected package manager.
|
|
182
|
-
|
|
183
|
-
### Django: "CSRF verification failed"
|
|
184
|
-
|
|
185
|
-
Auth callback receives GET requests from WorkOS. Ensure callback view uses GET, not POST. Or add `@csrf_exempt`.
|
|
186
|
-
|
|
187
|
-
### Flask: Session not persisting
|
|
188
|
-
|
|
189
|
-
Ensure `app.secret_key` is set (required for Flask sessions).
|
|
190
|
-
|
|
191
|
-
### Virtual environment not active
|
|
192
|
-
|
|
193
|
-
Check for `.venv/`, `venv/`, or poetry-managed environments. Activate before running install.
|
|
@@ -1,198 +0,0 @@
|
|
|
1
|
-
---
|
|
2
|
-
name: workos-ruby
|
|
3
|
-
description: Integrate WorkOS AuthKit with Ruby applications. Adapts to Rails, Sinatra, or vanilla Ruby. Server-side authentication with redirect-based OAuth flow.
|
|
4
|
-
---
|
|
5
|
-
|
|
6
|
-
# WorkOS AuthKit for Ruby
|
|
7
|
-
|
|
8
|
-
## Step 1: Fetch SDK Documentation (BLOCKING)
|
|
9
|
-
|
|
10
|
-
**STOP — Do not proceed until this fetch is complete.**
|
|
11
|
-
|
|
12
|
-
WebFetch: `https://raw.githubusercontent.com/workos/workos-ruby/main/README.md`
|
|
13
|
-
|
|
14
|
-
Also fetch the AuthKit quickstart for reference:
|
|
15
|
-
WebFetch: `https://workos.com/docs/authkit/vanilla/ruby`
|
|
16
|
-
|
|
17
|
-
The README is the **source of truth** for gem API usage. If this skill conflicts with the README, **follow the README**.
|
|
18
|
-
|
|
19
|
-
## Step 2: Detect Framework
|
|
20
|
-
|
|
21
|
-
Examine the project to determine which Ruby web framework is in use:
|
|
22
|
-
|
|
23
|
-
```
|
|
24
|
-
config/routes.rb exists? → Rails
|
|
25
|
-
Gemfile has 'rails' gem? → Confirmed Rails
|
|
26
|
-
|
|
27
|
-
Gemfile has 'sinatra' gem? → Sinatra
|
|
28
|
-
server.rb/app.rb has Sinatra routes? → Confirmed Sinatra
|
|
29
|
-
|
|
30
|
-
None of the above? → Vanilla Ruby (use Sinatra quickstart pattern)
|
|
31
|
-
```
|
|
32
|
-
|
|
33
|
-
**Adapt all subsequent steps to the detected framework.** Do not force Rails on a Sinatra project or vice versa.
|
|
34
|
-
|
|
35
|
-
## Step 2b: Partial Install Recovery
|
|
36
|
-
|
|
37
|
-
Before creating new files, check if a previous AuthKit attempt exists:
|
|
38
|
-
|
|
39
|
-
1. Check if `workos` is already in `Gemfile`
|
|
40
|
-
2. Check for incomplete auth files — files that `require "workos"` but have non-functional routes (TODO comments, 501 responses, empty handlers)
|
|
41
|
-
3. If partial install detected:
|
|
42
|
-
- Do NOT reinstall the gem (it's already there)
|
|
43
|
-
- Read existing auth files to understand what's done vs missing
|
|
44
|
-
- Complete the integration by filling gaps rather than starting fresh
|
|
45
|
-
- Preserve any working code — only fix what's broken
|
|
46
|
-
- Run `bundle install` (not `bundle update`) to avoid unexpected gem upgrades
|
|
47
|
-
|
|
48
|
-
## Step 2c: Existing Auth System Detection
|
|
49
|
-
|
|
50
|
-
Check for existing authentication before integrating:
|
|
51
|
-
|
|
52
|
-
```
|
|
53
|
-
Gemfile has 'devise'? → Devise auth (uses Warden)
|
|
54
|
-
Gemfile has 'warden'? → Warden auth
|
|
55
|
-
Gemfile has 'omniauth'? → OmniAuth (OAuth/OIDC)
|
|
56
|
-
*.rb files have 'Warden'? → Warden middleware in use
|
|
57
|
-
config/initializers has devise.rb? → Devise configured
|
|
58
|
-
```
|
|
59
|
-
|
|
60
|
-
If existing auth detected:
|
|
61
|
-
|
|
62
|
-
- Do NOT remove or disable it
|
|
63
|
-
- Add WorkOS AuthKit alongside the existing system
|
|
64
|
-
- If Devise is present, Devise uses Warden under the hood — integrate WorkOS at the Warden strategy level if possible
|
|
65
|
-
- Create separate route paths for WorkOS auth (e.g., `/auth/workos/login` if `/login` is taken)
|
|
66
|
-
- Ensure Rack middleware ordering is correct (WorkOS session middleware must not conflict)
|
|
67
|
-
- Ensure existing auth routes continue to work unchanged
|
|
68
|
-
- Document in code comments how to migrate fully to WorkOS later
|
|
69
|
-
|
|
70
|
-
## Step 3: Install WorkOS Gem
|
|
71
|
-
|
|
72
|
-
```bash
|
|
73
|
-
bundle add workos
|
|
74
|
-
```
|
|
75
|
-
|
|
76
|
-
If `dotenv` is not in the Gemfile:
|
|
77
|
-
|
|
78
|
-
```bash
|
|
79
|
-
# Rails
|
|
80
|
-
bundle add dotenv-rails --group development,test
|
|
81
|
-
|
|
82
|
-
# Sinatra / other
|
|
83
|
-
bundle add dotenv
|
|
84
|
-
```
|
|
85
|
-
|
|
86
|
-
**Verify:** `bundle show workos`
|
|
87
|
-
|
|
88
|
-
## Step 4: Integrate Authentication
|
|
89
|
-
|
|
90
|
-
### If Rails
|
|
91
|
-
|
|
92
|
-
1. **Create initializer** — `config/initializers/workos.rb`:
|
|
93
|
-
|
|
94
|
-
```ruby
|
|
95
|
-
WorkOS.configure do |config|
|
|
96
|
-
config.api_key = ENV.fetch("WORKOS_API_KEY")
|
|
97
|
-
config.client_id = ENV.fetch("WORKOS_CLIENT_ID")
|
|
98
|
-
end
|
|
99
|
-
```
|
|
100
|
-
|
|
101
|
-
2. **Create AuthController** — `app/controllers/auth_controller.rb`:
|
|
102
|
-
- `login` action: call `WorkOS::UserManagement.get_authorization_url(provider: "authkit", redirect_uri: ...)`, redirect
|
|
103
|
-
- `callback` action: call `WorkOS::UserManagement.authenticate_with_code(code: params[:code])`, store user in session
|
|
104
|
-
- `logout` action: clear session, redirect
|
|
105
|
-
|
|
106
|
-
3. **Add routes** to `config/routes.rb`:
|
|
107
|
-
|
|
108
|
-
```ruby
|
|
109
|
-
get "/auth/login", to: "auth#login"
|
|
110
|
-
get "/auth/callback", to: "auth#callback"
|
|
111
|
-
get "/auth/logout", to: "auth#logout"
|
|
112
|
-
```
|
|
113
|
-
|
|
114
|
-
4. **Add current_user helper** to `ApplicationController` (optional):
|
|
115
|
-
|
|
116
|
-
```ruby
|
|
117
|
-
helper_method :current_user
|
|
118
|
-
def current_user
|
|
119
|
-
@current_user ||= session[:user] && JSON.parse(session[:user])
|
|
120
|
-
end
|
|
121
|
-
```
|
|
122
|
-
|
|
123
|
-
5. **Verify:** `bundle exec rails routes | grep auth`
|
|
124
|
-
|
|
125
|
-
### If Sinatra
|
|
126
|
-
|
|
127
|
-
Follow the quickstart pattern exactly:
|
|
128
|
-
|
|
129
|
-
1. **Configure WorkOS** in `server.rb`:
|
|
130
|
-
|
|
131
|
-
```ruby
|
|
132
|
-
require "dotenv/load"
|
|
133
|
-
require "workos"
|
|
134
|
-
require "sinatra"
|
|
135
|
-
|
|
136
|
-
WorkOS.configure do |config|
|
|
137
|
-
config.key = ENV["WORKOS_API_KEY"]
|
|
138
|
-
end
|
|
139
|
-
```
|
|
140
|
-
|
|
141
|
-
2. **Create `/login` route** — call `WorkOS::UserManagement.authorization_url(provider: "authkit", client_id: ..., redirect_uri: ...)`, redirect
|
|
142
|
-
|
|
143
|
-
3. **Create `/callback` route** — call `WorkOS::UserManagement.authenticate_with_code(client_id: ..., code: ...)`, store in session cookie
|
|
144
|
-
|
|
145
|
-
4. **Create `/logout` route** — clear session cookie, redirect
|
|
146
|
-
|
|
147
|
-
5. **Update home route** — read session, show user info if present
|
|
148
|
-
|
|
149
|
-
6. **Verify:** `ruby -c server.rb`
|
|
150
|
-
|
|
151
|
-
### If Vanilla Ruby (no framework detected)
|
|
152
|
-
|
|
153
|
-
Install Sinatra and follow the Sinatra pattern above. This matches the official quickstart.
|
|
154
|
-
|
|
155
|
-
## Step 5: Environment Setup
|
|
156
|
-
|
|
157
|
-
Create/update `.env` with WorkOS credentials. Do NOT overwrite existing values.
|
|
158
|
-
|
|
159
|
-
```
|
|
160
|
-
WORKOS_API_KEY=sk_...
|
|
161
|
-
WORKOS_CLIENT_ID=client_...
|
|
162
|
-
```
|
|
163
|
-
|
|
164
|
-
## Step 6: Verification
|
|
165
|
-
|
|
166
|
-
### Rails
|
|
167
|
-
|
|
168
|
-
```bash
|
|
169
|
-
bundle show workos
|
|
170
|
-
bundle exec rails routes | grep auth
|
|
171
|
-
grep WORKOS .env
|
|
172
|
-
```
|
|
173
|
-
|
|
174
|
-
### Sinatra
|
|
175
|
-
|
|
176
|
-
```bash
|
|
177
|
-
bundle show workos
|
|
178
|
-
ruby -c server.rb
|
|
179
|
-
grep WORKOS .env
|
|
180
|
-
```
|
|
181
|
-
|
|
182
|
-
## Error Recovery
|
|
183
|
-
|
|
184
|
-
### "uninitialized constant WorkOS"
|
|
185
|
-
|
|
186
|
-
Gem not loaded. Verify `bundle show workos` succeeds. For Rails, ensure initializer exists. For Sinatra, ensure `require "workos"` is at top of server file.
|
|
187
|
-
|
|
188
|
-
### "NoMethodError" on WorkOS methods
|
|
189
|
-
|
|
190
|
-
SDK API may differ from this skill. Re-read the README (Step 1) and use exact method names.
|
|
191
|
-
|
|
192
|
-
### Routes not working (Rails)
|
|
193
|
-
|
|
194
|
-
Run `bundle exec rails routes | grep auth`. Verify routes are inside `Rails.application.routes.draw` block.
|
|
195
|
-
|
|
196
|
-
### Session not persisting (Sinatra)
|
|
197
|
-
|
|
198
|
-
Enable sessions: `enable :sessions` in server.rb, or use `rack-session` gem.
|