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,231 +0,0 @@
1
- ---
2
- name: workos-elixir
3
- description: Integrate WorkOS AuthKit with Elixir/Phoenix applications. Server-side authentication with Phoenix controllers and routes.
4
- ---
5
-
6
- # WorkOS AuthKit for Elixir (Phoenix)
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-elixir/main/README.md`
13
-
14
- The README is the source of truth for SDK API usage. If this skill conflicts with README, follow README.
15
-
16
- ## Step 2: Pre-Flight Validation
17
-
18
- ### Project Structure
19
-
20
- - Confirm `mix.exs` exists
21
- - Read `mix.exs` to extract the app name (look for `app: :my_app` in `project/0`)
22
- - Confirm `lib/{app}_web/router.ex` exists (Phoenix project marker)
23
- - Confirm `config/runtime.exs` exists
24
-
25
- ### Determine App Name
26
-
27
- The app name from `mix.exs` determines all file paths. For example, if `app: :my_app`:
28
-
29
- - Web module: `lib/my_app_web/`
30
- - Router: `lib/my_app_web/router.ex`
31
- - Controllers: `lib/my_app_web/controllers/`
32
-
33
- ### Environment Variables
34
-
35
- Check `.env.local` for:
36
-
37
- - `WORKOS_API_KEY` - starts with `sk_`
38
- - `WORKOS_CLIENT_ID` - starts with `client_`
39
-
40
- ## Step 2b: Partial Install Recovery
41
-
42
- Before creating new files, check if a previous AuthKit attempt exists:
43
-
44
- 1. Check if `:workos` is already in `mix.exs` dependencies
45
- 2. Check for incomplete auth code — AuthController exists but has TODO stubs, 501 responses, or missing callback/sign_out functions
46
- 3. If partial install detected:
47
- - Do NOT re-add the SDK dependency (it's already there)
48
- - Do NOT re-run `mix deps.get` if deps are already fetched
49
- - Read existing auth files to understand what's done vs missing
50
- - Complete the integration by filling gaps (controller methods, routes)
51
- - Preserve any working code — only fix what's broken
52
- - Check for missing `/auth/callback` route (most common gap)
53
-
54
- ## Step 2c: Existing Auth System Detection
55
-
56
- Check for existing authentication before integrating:
57
-
58
- ```
59
- mix.exs has ':ueberauth'? → Ueberauth auth
60
- mix.exs has ':pow'? → Pow auth
61
- mix.exs has ':guardian'? → Guardian JWT auth
62
- mix.exs has ':phx_gen_auth'? → Phoenix generated auth
63
- config/*.exs has 'Ueberauth' config? → Ueberauth configured
64
- router.ex has '/:provider' wildcard auth routes? → Ueberauth routes
65
- ```
66
-
67
- If existing auth detected:
68
-
69
- - Do NOT remove or disable it
70
- - Add WorkOS AuthKit alongside the existing system
71
- - If Ueberauth is configured, be careful of `/:provider` wildcard routes — use a specific scope like `/auth/workos` to avoid conflicts
72
- - Reuse existing session infrastructure if compatible
73
- - Create separate route paths for WorkOS auth
74
- - Ensure existing auth routes continue to work unchanged
75
- - Document in code comments how to migrate fully to WorkOS later
76
-
77
- ## Step 3: Install SDK
78
-
79
- Add the `workos` package to `mix.exs` dependencies:
80
-
81
- ```elixir
82
- defp deps do
83
- [
84
- # ... existing deps
85
- {:workos, "~> 1.0"}
86
- ]
87
- end
88
- ```
89
-
90
- Then run:
91
-
92
- ```bash
93
- mix deps.get
94
- ```
95
-
96
- **Verify:** Check that `mix deps.get` completed successfully (exit code 0).
97
-
98
- ## Step 4: Configure WorkOS
99
-
100
- Add WorkOS configuration to `config/runtime.exs`:
101
-
102
- ```elixir
103
- config :workos,
104
- api_key: System.get_env("WORKOS_API_KEY"),
105
- client_id: System.get_env("WORKOS_CLIENT_ID")
106
- ```
107
-
108
- This ensures credentials are loaded from environment variables at runtime, not compiled into the release.
109
-
110
- ## Step 5: Create Auth Controller
111
-
112
- ### Prerequisite: Verify `{AppName}Web` module exists
113
-
114
- The controller uses `use {AppName}Web, :controller`. Confirm `lib/{app}_web.ex` exists and defines the `:controller` macro. If it doesn't exist (minimal Phoenix projects may lack it), create it:
115
-
116
- ```elixir
117
- defmodule {AppName}Web do
118
- def controller do
119
- quote do
120
- use Phoenix.Controller, formats: [:html, :json]
121
- import Plug.Conn
122
- end
123
- end
124
-
125
- defmacro __using__(which) when is_atom(which) do
126
- apply(__MODULE__, which, [])
127
- end
128
- end
129
- ```
130
-
131
- ### Create controller
132
-
133
- Create `lib/{app}_web/controllers/auth_controller.ex`:
134
-
135
- ```elixir
136
- defmodule {AppName}Web.AuthController do
137
- use {AppName}Web, :controller
138
-
139
- def sign_in(conn, _params) do
140
- client_id = Application.get_env(:workos, :client_id)
141
- redirect_uri = "http://localhost:4000/auth/callback"
142
-
143
- authorization_url = WorkOS.UserManagement.get_authorization_url(%{
144
- provider: "authkit",
145
- client_id: client_id,
146
- redirect_uri: redirect_uri
147
- })
148
-
149
- case authorization_url do
150
- {:ok, url} -> redirect(conn, external: url)
151
- {:error, reason} -> conn |> put_status(500) |> text("Auth error: #{inspect(reason)}")
152
- end
153
- end
154
-
155
- def callback(conn, %{"code" => code}) do
156
- client_id = Application.get_env(:workos, :client_id)
157
-
158
- case WorkOS.UserManagement.authenticate_with_code(%{
159
- code: code,
160
- client_id: client_id
161
- }) do
162
- {:ok, auth_response} ->
163
- conn
164
- |> put_session(:user, auth_response.user)
165
- |> redirect(to: "/")
166
-
167
- {:error, reason} ->
168
- conn |> put_status(401) |> text("Authentication failed: #{inspect(reason)}")
169
- end
170
- end
171
-
172
- def sign_out(conn, _params) do
173
- conn
174
- |> clear_session()
175
- |> redirect(to: "/")
176
- end
177
- end
178
- ```
179
-
180
- **IMPORTANT:** Adapt the module name and API calls based on the README. The WorkOS Elixir SDK API may differ from the pseudocode above. Always follow the README for exact function names, parameter shapes, and return types.
181
-
182
- ## Step 6: Add Routes
183
-
184
- Add auth routes to `lib/{app}_web/router.ex`. Add these routes inside or outside the existing pipeline scope as appropriate:
185
-
186
- ```elixir
187
- scope "/auth", {AppName}Web do
188
- pipe_through :browser
189
-
190
- get "/sign-in", AuthController, :sign_in
191
- get "/callback", AuthController, :callback
192
- post "/sign-out", AuthController, :sign_out
193
- end
194
- ```
195
-
196
- ## Step 7: Verification
197
-
198
- Run the following to confirm the integration compiles:
199
-
200
- ```bash
201
- mix compile
202
- ```
203
-
204
- **If compilation fails:**
205
-
206
- 1. Read the error message carefully
207
- 2. Check that the WorkOS SDK module names match what's in the README
208
- 3. Verify the app name is consistent across all files
209
- 4. Fix the issue and re-run `mix compile`
210
-
211
- ## Error Recovery
212
-
213
- ### "could not compile dependency :workos"
214
-
215
- - Check Elixir version compatibility (1.15+ recommended)
216
- - Try `mix deps.clean workos && mix deps.get`
217
-
218
- ### "module WorkOS.UserManagement is not available"
219
-
220
- - The SDK API may use different module paths — re-read the README
221
- - Check if the SDK uses `WorkOS.SSO` or another module instead
222
-
223
- ### "undefined function" in controller
224
-
225
- - Verify `use {AppName}Web, :controller` is correct
226
- - Check that the SDK functions match the README exactly
227
-
228
- ### Route conflicts
229
-
230
- - Check existing routes in router.ex for `/auth` prefix conflicts
231
- - Adjust the scope path if needed (e.g., `/workos-auth`)
@@ -1,226 +0,0 @@
1
- ---
2
- name: workos-go
3
- description: Integrate WorkOS AuthKit with Go applications. Supports Gin and stdlib net/http.
4
- ---
5
-
6
- # WorkOS AuthKit for Go
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-go/main/README.md`
13
-
14
- The README is the source of truth for SDK API usage. If this skill conflicts with README, follow README.
15
-
16
- ## Step 2: Pre-Flight Validation
17
-
18
- ### Project Structure
19
-
20
- - Confirm `go.mod` exists in the project root
21
- - Confirm Go module is initialized (module path declared in `go.mod`)
22
-
23
- ### Environment Variables
24
-
25
- Check `.env` for:
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:8080/auth/callback`)
30
-
31
- ### Framework Detection
32
-
33
- Read `go.mod` to detect web framework:
34
-
35
- ```
36
- go.mod contains github.com/gin-gonic/gin?
37
- |
38
- +-- Yes --> Use Gin router patterns
39
- |
40
- +-- No --> Use stdlib net/http patterns
41
- ```
42
-
43
- ## Step 2b: Partial Install Recovery
44
-
45
- Before creating new files, check if a previous AuthKit attempt exists:
46
-
47
- 1. Check if `github.com/workos/workos-go` is already in `go.mod`
48
- 2. Check for incomplete auth code — files that import WorkOS packages but have non-functional handlers (TODO comments, 501 responses, empty handler bodies)
49
- 3. If partial install detected:
50
- - Do NOT re-run `go get` (the module is already there)
51
- - Read existing auth files to understand what's done vs missing
52
- - Complete the integration by filling gaps rather than starting fresh
53
- - Preserve any working code — only fix what's broken
54
- - If `usermanagement.SetAPIKey()` is already called in `init()`, don't call it again
55
- - Always run `go mod tidy` after changes to keep `go.sum` consistent
56
-
57
- ## Step 2c: Existing Auth System Detection
58
-
59
- Check for existing authentication before integrating:
60
-
61
- ```
62
- *.go files have 'jwt' or 'JWT'? → Custom JWT auth
63
- *.go files have 'oauth2'? → OAuth2 middleware
64
- *.go files have 'authMiddleware'? → Custom auth middleware
65
- go.mod has 'golang.org/x/oauth2'? → OAuth2 package
66
- go.mod has 'github.com/coreos/go-oidc'? → OIDC auth
67
- ```
68
-
69
- If existing auth detected:
70
-
71
- - Do NOT remove or disable it
72
- - Add WorkOS AuthKit alongside the existing system
73
- - Create separate route paths for WorkOS auth (e.g., `/auth/workos/login` if `/auth/login` is taken)
74
- - Match handler signatures to the detected framework (Gin `*gin.Context` vs stdlib `http.ResponseWriter, *http.Request`)
75
- - Ensure existing auth middleware continues to work on its routes
76
- - Document in code comments how to migrate fully to WorkOS later
77
-
78
- ## Step 3: Install SDK
79
-
80
- Run:
81
-
82
- ```bash
83
- go get github.com/workos/workos-go/v4
84
- ```
85
-
86
- **Verify:** Check that `go.mod` now contains `github.com/workos/workos-go/v4`. Both `go.mod` and `go.sum` will be modified — this is expected.
87
-
88
- ## Step 4: Configure Authentication
89
-
90
- ### 4a: Create Auth Handler File
91
-
92
- Create an auth handler file. Respect existing project structure:
93
-
94
- - If `internal/` directory exists, create `internal/auth/handlers.go`
95
- - If `handlers/` directory exists, create `handlers/auth.go`
96
- - Otherwise, create `auth/handlers.go`
97
-
98
- The file must:
99
-
100
- - Declare a package matching the directory name
101
- - Import `github.com/workos/workos-go/v4` packages as needed
102
- - Read env vars with `os.Getenv("WORKOS_API_KEY")`, `os.Getenv("WORKOS_CLIENT_ID")`, `os.Getenv("WORKOS_REDIRECT_URI")`
103
-
104
- ### 4b: Implement Handlers
105
-
106
- Implement these three handlers following the redirect-based auth flow from the README:
107
-
108
- **Login handler** (`/auth/login`):
109
-
110
- - Get the authorization URL from WorkOS using `usermanagement.GetAuthorizationURL()`
111
- - Set `Provider` to the string `"authkit"` (it's a plain string, not a constant)
112
- - Include `ClientID` and `RedirectURI` from env vars
113
- - Redirect the user to the returned URL
114
-
115
- **Callback handler** (`/auth/callback`):
116
-
117
- - Extract the `code` query parameter from the redirect
118
- - Call `usermanagement.AuthenticateWithCode()` with the code and `ClientID`
119
- - Store user info in session/cookie (or return as JSON for API-first apps)
120
- - Redirect to homepage or return user data
121
-
122
- **Logout handler** (`/auth/logout`):
123
-
124
- - Clear session data
125
- - Redirect to homepage
126
-
127
- **CRITICAL:** Use idiomatic Go error handling throughout:
128
-
129
- ```go
130
- result, err := someFunction()
131
- if err != nil {
132
- http.Error(w, "Error message", http.StatusInternalServerError)
133
- return
134
- }
135
- ```
136
-
137
- ### 4c: Wire Handlers into Router
138
-
139
- #### If using Gin:
140
-
141
- ```go
142
- r := gin.Default()
143
- r.GET("/auth/login", handleLogin)
144
- r.GET("/auth/callback", handleCallback)
145
- r.GET("/auth/logout", handleLogout)
146
- ```
147
-
148
- #### If using stdlib net/http:
149
-
150
- ```go
151
- http.HandleFunc("/auth/login", handleLogin)
152
- http.HandleFunc("/auth/callback", handleCallback)
153
- http.HandleFunc("/auth/logout", handleLogout)
154
- ```
155
-
156
- Wire these routes into the existing router setup in `main.go` or wherever routes are defined. Do NOT replace existing routes — add alongside them.
157
-
158
- ### 4d: Initialize WorkOS Client
159
-
160
- In the appropriate init location (package-level `init()` or `main()`), initialize the WorkOS client:
161
-
162
- ```go
163
- import "github.com/workos/workos-go/v4/pkg/usermanagement"
164
-
165
- func init() {
166
- usermanagement.SetAPIKey(os.Getenv("WORKOS_API_KEY"))
167
- }
168
- ```
169
-
170
- Follow the README for the exact initialization pattern — it may differ from above.
171
-
172
- ## Step 5: Environment Setup
173
-
174
- The `.env` file should already contain the required variables (written by the installer). Verify it contains:
175
-
176
- ```
177
- WORKOS_API_KEY=sk_...
178
- WORKOS_CLIENT_ID=client_...
179
- WORKOS_REDIRECT_URI=http://localhost:8080/auth/callback
180
- ```
181
-
182
- **Note for production:** Go does not have a built-in .env convention. In production, set real OS environment variables. The `.env` file is for development only. If using a `.env` loader like `github.com/joho/godotenv`, the agent may install it and add `godotenv.Load()` to `main()`.
183
-
184
- ## Step 6: Verification
185
-
186
- Run these commands. **Do not mark complete until all pass:**
187
-
188
- ```bash
189
- # 1. Go module is tidy
190
- go mod tidy
191
-
192
- # 2. Build succeeds
193
- go build ./...
194
-
195
- # 3. Vet passes (catches common mistakes)
196
- go vet ./...
197
- ```
198
-
199
- If build fails:
200
-
201
- - Check import paths match the SDK version in `go.mod`
202
- - Ensure all new files have correct package declarations
203
- - Run `go mod tidy` to resolve dependency issues
204
-
205
- ## Error Recovery
206
-
207
- ### "cannot find module providing package github.com/workos/workos-go/v4/..."
208
-
209
- - Run `go mod tidy` to sync dependencies
210
- - Check that `go get` completed successfully
211
- - Verify the import path matches exactly (v4 suffix required)
212
-
213
- ### "undefined: usermanagement.SetAPIKey" or similar
214
-
215
- - SDK API may have changed — refer to the fetched README
216
- - Check the correct subpackage import path
217
-
218
- ### Build fails with type errors
219
-
220
- - Ensure handler function signatures match the framework (Gin uses `*gin.Context`, stdlib uses `http.ResponseWriter, *http.Request`)
221
- - Check that error return values are handled
222
-
223
- ### "package X is not in std"
224
-
225
- - Run `go mod tidy` after adding new imports
226
- - Ensure `go get` was run before writing import statements
@@ -1,195 +0,0 @@
1
- ---
2
- name: workos-kotlin
3
- description: Integrate WorkOS AuthKit with Kotlin/Spring Boot. Backend authentication with Gradle.
4
- ---
5
-
6
- # WorkOS AuthKit for Kotlin (Spring Boot)
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-kotlin/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 `build.gradle.kts` exists (Kotlin DSL) or `build.gradle` (Groovy DSL)
21
- - Confirm Spring Boot plugin is present (`org.springframework.boot`)
22
- - Detect Gradle wrapper: check if `./gradlew` exists
23
-
24
- ### Gradle Wrapper
25
-
26
- ```bash
27
- # If gradlew exists, ensure it's executable
28
- if [ -f ./gradlew ]; then chmod +x ./gradlew; fi
29
- ```
30
-
31
- Use `./gradlew` if wrapper exists, otherwise fall back to `gradle`.
32
-
33
- ### Environment Variables
34
-
35
- Check `application.properties` or `application.yml` for:
36
-
37
- - `workos.api-key` or `WORKOS_API_KEY`
38
- - `workos.client-id` or `WORKOS_CLIENT_ID`
39
-
40
- ## Step 2b: Partial Install Recovery
41
-
42
- Before creating new files, check if a previous AuthKit attempt exists:
43
-
44
- 1. Check if `workos-kotlin` is already in `build.gradle.kts` dependencies
45
- 2. Check for incomplete auth code — WorkOS imported/instantiated but no controller with login/callback endpoints
46
- 3. If partial install detected:
47
- - Do NOT re-add the SDK dependency (it's already there)
48
- - Read existing source files to understand what's done vs missing
49
- - Complete the integration by filling gaps (controller, config bean, routes)
50
- - Preserve any working code — only fix what's broken
51
- - Check for a missing `/auth/callback` endpoint (most common gap)
52
-
53
- ## Step 2c: Existing Auth System Detection
54
-
55
- Check for existing authentication before integrating:
56
-
57
- ```
58
- build.gradle.kts has 'spring-boot-starter-security'? → Spring Security
59
- *.kt files have 'SecurityFilterChain'? → Security filter config
60
- *.kt files have 'formLogin'? → Form-based auth
61
- *.kt files have 'oauth2Login'? → OAuth2 auth
62
- *.kt files have 'httpBasic'? → Basic auth
63
- ```
64
-
65
- If existing auth detected:
66
-
67
- - Do NOT remove or disable it
68
- - Add WorkOS AuthKit alongside the existing system
69
- - If Spring Security is configured, ensure WorkOS auth routes are permitted through the security filter chain (add `.requestMatchers("/auth/workos/**").permitAll()`)
70
- - Create separate route paths for WorkOS auth (e.g., `/auth/workos/login` if `/login` is taken)
71
- - Ensure existing auth routes continue to work unchanged
72
- - Document in code comments how to migrate fully to WorkOS later
73
-
74
- ## Step 3: Install SDK
75
-
76
- Add the WorkOS Kotlin SDK dependency to `build.gradle.kts`:
77
-
78
- ```kotlin
79
- dependencies {
80
- implementation("com.workos:workos-kotlin:4.18.1")
81
- // ... existing dependencies
82
- }
83
- ```
84
-
85
- Check the README for the latest version number — use the version from the README if it differs from above.
86
-
87
- **JVM target**: Ensure `jvmTarget` in `build.gradle.kts` matches the JDK on the system. Check with `java -version`. Common values: `"17"`, `"21"`. If `kotlin { jvmToolchain(...) }` is set, ensure it matches too.
88
-
89
- **Verify:** Run `./gradlew dependencies` or `gradle dependencies` to confirm the dependency resolves.
90
-
91
- ## Step 4: Configure Authentication
92
-
93
- ### 4a: Application Properties
94
-
95
- Add WorkOS configuration to `src/main/resources/application.properties`:
96
-
97
- ```properties
98
- workos.api-key=${WORKOS_API_KEY}
99
- workos.client-id=${WORKOS_CLIENT_ID}
100
- workos.redirect-uri=http://localhost:8080/auth/callback
101
- ```
102
-
103
- Or if the project uses `application.yml`, add the equivalent YAML.
104
-
105
- ### 4b: Create WorkOS Configuration Bean
106
-
107
- Create a configuration class that initializes the WorkOS client:
108
-
109
- ```kotlin
110
- @Configuration
111
- class WorkOSConfig {
112
- @Value("\${workos.api-key}")
113
- lateinit var apiKey: String
114
-
115
- @Bean
116
- fun workos(): WorkOS = WorkOS(apiKey)
117
- }
118
- ```
119
-
120
- Adapt based on the SDK README — the exact client initialization may vary.
121
-
122
- ### 4c: Create Auth Controller
123
-
124
- Create a Spring `@RestController` with these endpoints:
125
-
126
- 1. **GET /auth/login** — Redirect user to WorkOS AuthKit hosted login
127
- - Use `workos.userManagement.getAuthorizationUrl()` — this returns a URL string
128
- - Parameters: `clientId`, `redirectUri`, `provider = "authkit"`
129
- - The method uses a builder pattern: `.provider("authkit").redirectUri(uri).build()`
130
-
131
- 2. **GET /auth/callback** — Exchange authorization code for user profile
132
- - Extract `code` query parameter
133
- - Call `workos.userManagement.authenticateWithCode()` with the code and clientId
134
- - Store user session (use Spring's `HttpSession`)
135
- - Redirect to home page
136
-
137
- 3. **GET /auth/logout** — Clear session and redirect
138
- - Invalidate `HttpSession`
139
- - Redirect to home page or WorkOS logout URL
140
-
141
- **Follow the README for exact API method names and parameters.**
142
-
143
- ## Step 5: Session Management
144
-
145
- Use Spring's built-in `HttpSession` for session management:
146
-
147
- - Store user profile in session after callback
148
- - Check session in protected routes
149
- - Clear session on logout
150
-
151
- If Spring Security is already configured, integrate with the existing security filter chain rather than replacing it.
152
-
153
- ## Step 6: Verification
154
-
155
- Run the build to verify everything compiles:
156
-
157
- ```bash
158
- ./gradlew build
159
- ```
160
-
161
- **If build fails:**
162
-
163
- - Check dependency resolution: `./gradlew dependencies | grep workos`
164
- - Check for missing imports in the auth controller
165
- - Verify application.properties syntax
166
- - Gradle builds can be slow (30-60s) — be patient
167
-
168
- ### Checklist
169
-
170
- - [ ] WorkOS SDK dependency in build.gradle.kts
171
- - [ ] Application properties configured
172
- - [ ] Auth controller with login, callback, logout endpoints
173
- - [ ] Build succeeds (`./gradlew build`)
174
-
175
- ## Error Recovery
176
-
177
- ### Dependency resolution failure
178
-
179
- - Check Maven Central is accessible
180
- - Verify the artifact coordinates match README exactly
181
- - Ensure `mavenCentral()` is in the `repositories` block of build.gradle.kts
182
-
183
- ### "Could not resolve com.workos:workos-kotlin"
184
-
185
- - The package may use a different group ID — check README
186
- - Ensure repositories block includes `mavenCentral()`
187
-
188
- ### Build fails with missing Spring Boot annotations
189
-
190
- - Verify `org.springframework.boot` plugin is applied
191
- - Check Spring Boot starter dependencies are present
192
-
193
- ### Gradle wrapper permission denied
194
-
195
- - Run `chmod +x ./gradlew` before building