Commit 2874ba3
feat(auth): integrate Logto authentication with AI components
Add complete Logto authentication integration for AI features:
Logto Integration:
- Auto-detect token from auth_data (Logto callback response)
- Support Logto sign-in flow redirection
- Extract user info from auth_data structure
- Admin role detection from Logto data
AIAuthHelper Updates:
- Priority token extraction from auth_data
- getUserInfo() method for Logto user data
- isAdmin() method for role checking
- redirectToLogtoSignIn() for Logto login flow
- Support for Logto sign-in/sign-out URLs
Token Structure:
Authentication Flow:
1. User visits page
2. Check auth_data in localStorage
3. If not found, redirect to Logto sign-in
4. Logto callback returns auth_data
5. Frontend saves to localStorage
6. AI components use token from auth_data
Features:
- Automatic Logto integration (useLogto: true by default)
- Seamless token extraction from auth_data
- User info and role management
- Graceful fallback to traditional auth
- Storage event monitoring for login/logout
- Token expiration handling
Documentation:
- AI_LOGTO_INTEGRATION.md - Complete Logto integration guide
- Examples for all authentication scenarios
- Debugging and troubleshooting guide
- Security best practices
Usage:
Co-authored-by: Ona <no-reply@ona.com>1 parent 98f9b96 commit 2874ba3
2 files changed
Lines changed: 647 additions & 6 deletions
0 commit comments