Skip to content

Conversation

@michelroegl-brunner
Copy link
Member

🚀 Authentication System Implementation

This PR implements a complete authentication system for the ProxmoxVE Local application with the following features:

✨ Key Features

  • JWT-based authentication with secure token management
  • Bcrypt password hashing for secure credential storage
  • Flexible setup flow - users can enable/disable authentication
  • Auto-login after setup for seamless user experience
  • Settings integration for ongoing credential management
  • Environment-based configuration with .env file storage

🔧 Technical Implementation

  • JWT tokens stored as httpOnly cookies
  • Password hashing using bcrypt (industry standard)
  • Race condition prevention with JWT secret caching
  • Setup completion tracking to prevent repeated setup prompts
  • Comprehensive error handling and user feedback

🎯 User Experience

  • First-time setup modal appears only once
  • Option to skip authentication during initial setup
  • Automatic login after credential setup
  • Settings panel for ongoing authentication management
  • Clean console without unnecessary API calls

🛠️ Files Modified

  • Added authentication API routes (/api/auth/*)
  • Created React components (AuthProvider, AuthGuard, AuthModal, SetupModal)
  • Enhanced settings modal with authentication tab
  • Updated environment configuration
  • Added utility functions for JWT and password management

✅ Testing

  • All build errors resolved
  • ESLint and TypeScript checks pass
  • Authentication flow tested end-to-end
  • Console errors eliminated

🔒 Security Features

  • Secure password hashing with bcrypt
  • JWT tokens with configurable secrets
  • HttpOnly cookies for token storage
  • Environment variable protection
  • Input validation and sanitization

Ready for review and merge! 🎉

- Add bcrypt password hashing and JWT token generation
- Create blocking auth modals for login and setup
- Add authentication management to General Settings
- Implement API routes for login, verify, setup, and credential management
- Add AuthProvider and AuthGuard components
- Support first-time setup and persistent authentication
- Store credentials securely in .env file
- Add toggle in SetupModal to choose whether to enable authentication immediately
- Users can set up credentials but keep authentication disabled initially
- Authentication can be enabled/disabled later through General Settings
- Maintains flexibility for users who want to configure auth gradually
- Make password fields optional when authentication is disabled in setup
- Update button validation to only require password when auth is enabled
- Modify API to handle optional password parameter
- Update hasCredentials logic to work with username-only setup
- Users can now complete setup with just username when auth is disabled
- Password can be added later when enabling authentication
- When auth is disabled, no username or password is stored
- Setup modal only requires credentials when authentication is enabled
- Disabling authentication clears all stored credentials
- Users can skip authentication entirely without storing any data
- Clean separation between enabled/disabled authentication states
- Add AUTH_SETUP_COMPLETED flag to track when user has completed setup
- Setup modal only appears when setupCompleted is false
- Both enabled and disabled auth setups mark setup as completed
- Clean .env file when authentication is disabled (no empty credential lines)
- Prevents setup modal from appearing on every page load after user decision
- Authentication tab button was missing from the tabs navigation
- Users couldn't access authentication settings
- Added Authentication tab button with proper styling and click handler
- Authentication settings are now accessible through the settings modal
- Add setupCompleted state variable to track setup status
- Update loadAuthCredentials to include setupCompleted field
- Fix authentication status display logic to show correct state
- Show proper status when auth is disabled but setup is completed
- Enable toggle only when setup is completed (not just when credentials exist)
- Settings now correctly reflect the actual authentication state
- Add check for empty or invalid FILTERS JSON before parsing
- Prevents 'Unexpected end of JSON input' error when FILTERS is empty
- Return null filters instead of throwing parse error
- Clean up empty FILTERS line from .env file
- Fixes console error when loading settings modal
- Add loadAuthCredentials() call to useEffect when modal opens
- Authentication settings were not loading because the function wasn't being called
- Now properly loads auth configuration when settings modal is opened
- Settings will display the correct authentication status and state
- Add JWT secret caching to prevent race conditions
- Multiple API calls were generating duplicate JWT secrets
- Now caches secret after first generation/read
- Clean up duplicate JWT_SECRET lines from .env file
- Prevents .env file from being cluttered with multiple secrets
- When user sets up authentication with credentials, automatically log them in
- Prevents need to manually log in after setup completion
- Setup modal now calls login API after successful setup when auth is enabled
- AuthGuard no longer reloads page after setup, just refreshes config
- Seamless user experience from setup to authenticated state
- Fix 401 Unauthorized error by checking setup status before auth verification
- AuthProvider now checks if setup is completed before attempting to verify auth
- Prevents unnecessary auth verification calls when no credentials exist
- Add webpack polling configuration to fix WebSocket HMR issues
- Improves development experience when accessing from different IPs
- Eliminates console errors during initial setup flow
- Fix TypeScript ESLint error: use optional chain expression in auth.ts
- Fix React Hook warning: add missing 'isRunning' dependency to useEffect in Terminal.tsx
- Build now compiles successfully without any errors or warnings
- All linting rules are now satisfied
@michelroegl-brunner michelroegl-brunner requested a review from a team as a code owner October 10, 2025 10:44
@michelroegl-brunner michelroegl-brunner merged commit 6265ffe into main Oct 10, 2025
4 checks passed
@michelroegl-brunner michelroegl-brunner deleted the feature/auth-system branch October 14, 2025 06:43
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants