Feat add clerk auth#8724
Conversation
|
Caution Review failedThe pull request is closed. WalkthroughThis update introduces Clerk authentication support to both the backend and frontend, enabling JWT-based SSO via Clerk. It adds new configuration options, utility modules, and conditional control flows to support Clerk or legacy authentication. The frontend integrates Clerk components and adapts routing, login, and logout logic accordingly. Documentation and environment examples are updated. Changes
Sequence Diagram(s)sequenceDiagram
participant User
participant Frontend
participant Clerk
participant Backend
participant Database
User->>Frontend: Visits app
Frontend->>Clerk: Check if Clerk auth enabled
alt Clerk auth enabled
Frontend->>Clerk: Is user signed in?
alt Signed in
Frontend->>Clerk: Get JWT token
Frontend->>Backend: Send request with Clerk JWT
Backend->>Clerk: Fetch JWKS
Backend->>Backend: Verify JWT, extract user info
Backend->>Database: Find or create user by Clerk ID
Database-->>Backend: User record
Backend-->>Frontend: API response
else Not signed in
Frontend->>Clerk: Show SignIn/SignUp UI
end
else Legacy auth
Frontend->>Backend: Show login form or auto-login
User->>Frontend: Enter credentials
Frontend->>Backend: Send credentials
Backend->>Database: Validate user/password
Database-->>Backend: User record
Backend-->>Frontend: JWT token, set cookies
Frontend->>Backend: Use JWT for API requests
Backend->>Backend: Validate JWT, fetch user
Backend-->>Frontend: API response
end
Possibly related PRs
Suggested labels
📜 Recent review detailsConfiguration used: .coderabbit.yaml ⛔ Files ignored due to path filters (1)
📒 Files selected for processing (30)
✨ Finishing Touches
🧪 Generate Unit Tests
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. 🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
SupportNeed help? Create a ticket on our support page for assistance with any issues or questions. Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments. CodeRabbit Commands (Invoked using PR comments)
Other keywords and placeholders
Documentation and Community
|
✨ Clerk Authentication Integration (Feature Request)
This PR adds optional support for Clerk authentication to Langflow, controlled via a toggle using the new environment variable
LANGFLOW_CLERK_AUTH_ENABLEDandVITE_CLERK_AUTH_ENABLED. When set totrue, Clerk handles all frontend and backend authentication flows (including GitHub, Google, etc.). Whenfalse, the existing legacy login remains fully functional.✅ Key Features
LANGFLOW_CLERK_AUTH_ENABLED=trueandVITE_CLERK_AUTH_ENABLED=trueto activate Clerk loginAuthorization: Bearer <token>to authenticate<SignIn />,<SignUp />) when enabled🛠️ Modified Files
🔁 Backend
🖼️ Frontend
Additional Changes:
authGuard.tsx,authAdminGuard.tsx,useClerkAccessToken.ts,api.tsxmodifications<SignIn />UI in Clerk mode/mefetch inAppInitPage⚙️ Environment Setup
📁
.env.exampleTo use legacy auth:
CLERK_AUTH_ENABLED=true, an unwanted call to/api/v1/users/undefinedoccurs.authContextor a stalewhoamicall).whoamicall behind Clerk sessionisSignedIn.🧪 How to Run
🧰 Backend
make init make backend # Visit http://0.0.0.0:7860/🌐 Frontend
make frontend # Opens http://localhost:3000/Summary by CodeRabbit
New Features
Improvements
Bug Fixes
Documentation
Chores