Overview
PingPilot uses Clerk for authentication, providing a secure and seamless sign-in experience. Clerk handles all aspects of user authentication, including sign-up, sign-in, session management, and user profiles.Authentication Flow
When users access protected routes in PingPilot, they are automatically authenticated through Clerk’s middleware:- User attempts to access a protected route (e.g.,
/dashboard) - Clerk middleware intercepts the request
- If not authenticated, user is redirected to the sign-in page
- After successful authentication, user is redirected to their intended destination
Protected Routes
The following routes are protected by Clerk authentication:/dashboard/*- All dashboard pages/welcome- Onboarding page/api/*- API routes (excluding the public event endpoint)/trpc/*- tRPC routes
Sign In & Sign Up
Sign In Page
Users can sign in at/sign-in using:
- Email and password
- OAuth providers (if configured)
- Magic links
Sign Up Page
New users can create an account at/sign-up. Upon successful registration:
- A new user record is created in the database
- A unique API key is automatically generated
- User is redirected to the onboarding flow
User Session
Clerk maintains user sessions across the application. You can access the current user in:Server Components
Client Components
User Profile Management
Clerk provides a built-in user button component for profile management:- View their profile
- Update account settings
- Sign out
Security Features
Session Management
Session Management
Clerk automatically manages user sessions with secure, httpOnly cookies. Sessions are refreshed automatically and expire after periods of inactivity.
Password Security
Password Security
Clerk enforces strong password requirements and handles secure password hashing. Passwords are never stored in plain text.
OAuth Integration
OAuth Integration
Clerk supports OAuth providers for social sign-in, allowing users to authenticate with their existing accounts while maintaining security.
Database Integration
When a user signs up through Clerk:- Clerk creates a user account with a unique
externalId - PingPilot creates a corresponding
Userrecord in the database - The
externalIdlinks the Clerk user to the PingPilot user - A unique
apiKeyis generated for API authentication
Troubleshooting
Redirect loops
Redirect loops
If you experience redirect loops, ensure that:
- Your Clerk API keys are correctly configured
- The middleware matcher is properly set up
- You’re not blocking Clerk’s internal routes
Session not persisting
Session not persisting
Check that:
- Cookies are enabled in your browser
- You’re not in incognito/private mode
- Your domain is correctly configured in Clerk
Next Steps
API Keys
Learn how to manage your API key for programmatic access
Account Settings
Configure your notification preferences