migrating-to-scalekit-auth
Scalekit Auth Migration Planner
Guides an incremental, reversible migration from an existing auth system to Scalekit. Follow these phases in order—do not skip phases.
Migration checklist
Copy and track progress:
Migration Progress:
- [ ] Phase 1: Audit and export existing auth data
- [ ] Phase 2: Import organizations and users into Scalekit
- [ ] Phase 3: Configure redirects and roles
- [ ] Phase 4: Update application code
- [ ] Phase 5: Deploy and monitor
Phase 1: Audit and export
Conduct a code audit covering:
- Sign-up/login flows, session middleware, token validation
- RBAC logic, email verification, logout/session termination
Export the following data:
- User records (email, name,
email_verified) - Org/tenant structure
- Role assignments and permissions
- SSO/IdP provider configs
Backup checklist before proceeding:
- Export a sample JWT or session cookie (understand current format)
- Set up a feature flag to roll back to old auth system
- Document rollback procedure
Minimum user schema:
| Field | Required |
|---|---|
email |
Required |
first_name |
Optional |
last_name |
Optional |
email_verified |
Optional (defaults false) |
See AUDIT-CHECKLIST.md for full code audit patterns.
Phase 2: Import organizations and users
external_id is critical—store original PKs here to preserve system-to-system mappings.
Step 1: Create organizations first
Node.js example:
const result = await scalekit.organization.createOrganization(
org.display_name,
{ externalId: org.external_id, metadata: org.metadata }
);
Step 2: Create users within organizations
const { user } = await scalekit.user.createUserAndMembership("org_scalekit_id", {
email: "user@example.com",
externalId: "usr_987",
userProfile: { firstName: "John", lastName: "Doe" },
});
Rules:
- Set
sendInvitationEmail: falseduring import to skip invite emails; membership auto-activates and email is marked verified - Batch imports in parallel; respect Scalekit rate limits
- Validate
external_idmappings match source data exactly
For language-specific samples (Python, Go, Java, cURL): See IMPORT-SAMPLES.md.
Phase 3: Configure redirects and roles
Redirects:
- Register callback URLs in Settings → Redirects in Scalekit dashboard
- Add post-logout URLs to control destination after logout
Roles:
- Define roles under User Management → Roles or via SDK
- During user import, include
rolesarray inside themembershipobject - Verify role claims are readable from the token after login
Phase 4: Update application code
Session middleware: Replace legacy JWT validation with Scalekit SDK or JWKS endpoint.
Verify:
- Access tokens accepted on all protected routes
- Refresh token renewal works seamlessly
-
rolesclaim from Scalekit tokens used for RBAC checks
Login page: Update logo, colors, copy, and legal links in Scalekit dashboard under Branding.
Secondary flows to update:
- Email verification prompt
- Logout redirect destination
Phase 5: Deploy and monitor
Pre-deployment:
- Test login with a subset of migrated users
- Verify session creation, validation, and expiry
- Confirm role-based access works end-to-end
Deployment sequence:
- Deploy updated application code
- Enable feature flag → route traffic to Scalekit
- Start at 5–10% of users; expand after stability confirmed
- Monitor auth success rates and error logs
- Keep rollback plan active for first 48 hours
Post-deployment monitoring:
- Auth error rates
- Session creation/validation metrics
- SSO connection health
- User-reported issues via support
Troubleshooting
| Symptom | Fix |
|---|---|
| Users can't log in | Verify callback URLs registered; check external_id mappings; ensure emails match exactly |
| Session validation fails | Switch JWT validation to Scalekit JWKS endpoint; verify token expiry/refresh logic |
| SSO not working | Confirm org has SSO enabled; verify IdP config; test IdP-initiated login |
Note: Password migration support is coming. If required, contact Scalekit's Solutions team.
More from scalekit-inc/skills
setup-scalekit
Use when a developer is new to Scalekit and needs guidance on where to start, doesn't know which auth plugin or skill to choose, wants to connect an AI agent or agentic workflow to third-party services (Gmail, Slack, Notion, Google Calendar), needs OAuth or tool-calling auth for agents, wants to add authentication to a project but hasn't chosen an approach yet, or needs to install the Scalekit plugin for their AI coding tool (Claude Code, Codex, Copilot CLI, Cursor, or other agents).
11implementing-scalekit-fsa
Implements Scalekit full-stack authentication (FSA) including sign-up, login, logout, and secure session management using JWT tokens. Use when building or integrating user authentication with the Scalekit SDK across Node.js, Python, Go, or Java — or when the user asks about auth flows, OAuth callbacks, token refresh, or session handling with Scalekit.
4integrating-agent-auth
Integrates Scalekit Agent Auth into a project to handle OAuth flows, token storage, and automatic refresh for third-party services (Gmail, Slack, Notion, Calendar). Use when a user needs to connect to an external service, authorize OAuth access, fetch access or refresh tokens, or execute API calls on behalf of a user.
4adding-mcp-oauth
Guides users through adding OAuth 2.1 authorization to Model Context Protocol (MCP) servers using Scalekit. Use when setting up MCP servers, implementing authentication for AI hosts like Claude Desktop, Cursor, or VS Code, or when users mention MCP security, OAuth, or Scalekit integration.
3modular-sso
Implements complete SSO and authentication flows using Scalekit. Handles modular SSO, IdP-initiated login, user session management, and enterprise customer onboarding. Use when adding authentication, SSO, SAML, OIDC, or user login to applications.
3sk-actions-custom-provider
Create or review Scalekit custom providers/connectors for proxy-only usage. Use this skill when the task is to gather API docs, infer whether a connector is OAuth, Basic, Bearer, or API Key, determine required tracked fields like domain or version, generate provider JSON, check for existing custom providers, show update diffs, run approved create or update curls, and print resolved delete curls.
3