feat(auth): add advanced authentication system#4931
Conversation
…ighting - Refactor DetailRow to three-column table (Action/Field/Value) with Table/JSON tabs - Add fieldFilters state with backend `filters` query parameter support - Implement HighlightText multi-keyword support with two-layer highlighting - Add collapsed row Level/Node column highlighting - Sync Level/LogType chip selections with DetailRow highlighting - Add i18n keys for DetailRow component Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
- Add copy button to DetailRow JSON tab with ContentCopy/Check icons - Implement copyToClipboard with navigator.clipboard + execCommand fallback for HTTP - Show copied feedback with 1.5s auto-reset and tooltip - Add useEffect cleanup for timer to prevent stale setState - Add i18n keys: copyJson, copied Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
- Add backend GET /v1/cluster/logs/context endpoint with older/newer dual ES queries - Add ContextDialog component with editable load count and newest-first ordering - Support row expansion in ContextDialog reusing DetailRow component - Isolate ContextDialog filter state from main page filters - Support anchor switching within dialog (replaces nested dialogs) - Add DetailRow onViewContext prop for custom "view surrounding documents" behavior - Add i18n keys for context dialog UI Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
- Add Enter key support on load count TextField to trigger loading - Add filter chips bar in ContextDialog showing active local filters - Implement filterRows for client-side data filtering (OR within same key, AND across keys) - Anchor row always visible regardless of filter state Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
- Use OR (terms/bool.should) for same-field filters instead of AND - Parallelize context API ES queries with asyncio.gather - Sort highlight keywords by length descending to prevent partial matches - Fix prettier formatting for index.js Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
- Change filters parameter from comma-delimited string to list[str] via Query([])
- Frontend uses params.append instead of params.set with join(',')
- Fixes data loss when filter values contain commas (e.g. message fields)
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
…d user management Introduces an optional advanced authentication mode (XINFERENCE_AUTH_ADVANCED=1) that provides: - JWT-based authentication with refresh tokens - Encrypted API key management with per-model access control - User management with role-based permissions (admin/user) - Password change enforcement for first-time login - SQLite-backed user/key storage with migration CLI tool - Frontend: user management, API key management, and password change pages This is an alternative to the existing file-based auth config, activated via environment variables. Both modes are mutually exclusive. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
There was a problem hiding this comment.
Code Review
This pull request introduces a comprehensive advanced authentication system for Xinference, moving from a static JSON configuration to a dynamic SQLite-backed architecture. The new system supports JWT-based authentication, refresh tokens, and granular management of users and API keys with model-level access controls. Significant updates were made to both the backend services and the web UI to accommodate these features, including a new migration utility for existing setups. Review feedback highlights several critical security and performance improvements, such as avoiding plain-text storage of initial admin credentials, implementing refresh token rotation, handling cryptographic exceptions more robustly, and optimizing database queries to prevent N+1 performance issues.
Remove unused imports (Tuple, Any, Dict, List, Depends), fix type annotations to satisfy mypy strict checks, and add None guards for optional dict values. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
- Remove plain-text admin credential file, output to console only - Default user_enabled to 0 (disabled) for non-existent users - Implement refresh token rotation (invalidate on use, return new token) - Catch AES-GCM decryption failures gracefully (return None) - Optimize list_users to batch-fetch permissions (fix N+1 query) - Allow update_user to set nullable fields to NULL Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
qinxuye
left a comment
There was a problem hiding this comment.
Reviewed current head b31bf04. I skipped the existing Gemini findings and only added non-duplicate issues. One additional blocker: the current lint check fails at the Prettier step for src/components/MenuSide.js, src/scenes/apikey_management/index.js, and src/scenes/user_management/index.js.
…ke token on logout - create_api_key: non-admin users can only create keys for themselves - list_api_keys: non-admin users can only see their own keys - get_api_key: non-admin users can only view their own keys - Logout now clears refresh_token from sessionStorage and calls /v1/auth/logout to revoke it server-side (best-effort) Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Summary
XINFERENCE_AUTH_ADVANCED=1) as an alternative to the existing file-based auth configxinference/api/oauth2/advanced/module with SQLite storage, crypto utilities, andxinference-migrate-authCLIConfiguration
Set these environment variables to enable:
Changes
Backend
xinference/api/oauth2/advanced/— Full auth module (auth_service, database, cache, crypto, migrate, routes)xinference/constants.py— New env var constants for advanced authxinference/api/restful_api.py— Advanced auth initialization, model access control (_check_model_access)xinference/api/routers/admin.py— Conditional/tokenroute,auth_advancedin UI configsetup.cfg—xinference-migrate-authentry pointFrontend
fetchWrapper.js— Refresh token mechanism with token rotation supportMenuSide.js— User management, API key management, logout menu itemsrouter/index.js— Routes for new pageschange_password/,apikey_management/,user_management/login.js— Refresh token + must-change-password handlinglocales/— i18n strings for new featuresSecurity Improvements (code review feedback)
list_usersN+1 query optimized to batch fetchupdate_userallows setting nullable fields to NULLTest plan
XINFERENCE_AUTH_ADVANCEDis not setxinference-migrate-authCLI tool--auth-configandXINFERENCE_AUTH_ADVANCEDare set