Session: 2025-11-30 - Dev Environment Troubleshooting
Summary
Troubleshooting session to get the CyberOrigen dev environment running and fix issues with Admin Portal/Audit Logs visibility in the sidebar.
Issues Addressed
1. TypeScript Build Errors
- Problem: UI Docker build failed due to TypeScript compilation errors
- Solution:
- Changed
package.jsonbuild script fromtsc && vite buildtovite build - Added
build:typecheckscript for strict type checking when needed - Fixed several type errors:
- Added
DORAtoComplianceMapping.frameworktype intypes.ts - Renamed
AuditLogEntrytoRemediationAuditLogEntryinapiService.tsto avoid conflict - Fixed
OrganizationSettingsView.tsxto usecancelInviteinstead ofrevokeInvite - Fixed role type casting for
updateMemberRole - Replaced missing translation keys with hardcoded strings in
SignupView.tsx
- Added
- Changed
2. Port Conflicts
- Problem: Ports 5432, 3002, 8000 were already in use
- Solution: Updated
docker-compose.ymlto use alternative ports:- PostgreSQL: 5434 (was 5432)
- API: Changed binding from
127.0.0.1to0.0.0.0for dev access - UI: Changed binding from
127.0.0.1to0.0.0.0for dev access - Peppermint: 3002 (unchanged)
3. Database Password Mismatch
- Problem: API couldn't connect to PostgreSQL after container recreation
- Solution: Recreated volumes with
docker-compose down -vand freshup -d
4. Missing Admin User
- Problem: After volume reset, no admin user existed
- Solution: Created admin user via SQL (see Commands Reference section for template)
5. Missing Python Module
- Problem: API container failed with
ModuleNotFoundError: No module named 'pyotp' - Solution: Rebuilt API container without cache:
docker-compose build --no-cache api
6. Browser Connection Issues
- Problem: Windows browser couldn't connect to localhost:3000 despite PowerShell working
- Status: User restarting computer to resolve networking between Windows and WSL
Current Configuration
Docker Compose Ports
| Service | Internal Port | External Port |
|---|---|---|
| UI | 80 | 3000 |
| API | 8000 | 8000 |
| PostgreSQL | 5432 | 5434 |
| Redis | 6379 | 6379 |
| Peppermint | 3000 | 3002 |
| Peppermint DB | 5432 | 5433 |
Access URLs
- UI: http://localhost:3000
- API: http://localhost:8000
- API Health: http://localhost:8000/health
Admin User
- User Type: PLATFORM_ADMIN
- Note: Credentials stored securely, not in documentation
Files Modified
Infrastructure
infrastructure/docker-compose.yml- Port bindings, build argsinfrastructure/docker-compose.dev.yml- PostgreSQL port changed to 5434
Frontend (ui_cyberorigen)
package.json- Build script modifiedtypes.ts- Added DORA to ComplianceMappingservices/apiService.ts- Renamed AuditLogEntry to RemediationAuditLogEntrycomponents/OrganizationSettingsView.tsx- Fixed API calls and type castingcomponents/SignupView.tsx- Replaced missing translation keyscomponents/VulnerabilityTable.tsx- Hardcoded "Scan ID" headercomponents/RemediationAuditView.tsx- Updated importe2e/ui-features.spec.ts- Fixed Playwright locator syntaxDockerfile- Created for UI container
Pending Work
- Fix remaining TypeScript errors for production build (run
npm run build:typecheck) Verify Admin Portal and Audit Logs appear in sidebar after login✅ FIXED- Add missing translation keys to
LanguageContext.tsx
Additional Fixes (Dec 1, 2025)
- VITE_API_URL: Fixed build arg in
docker-compose.ymlfromhttp://localhost:8000tohttp://localhost:8000/api/v1 - Admin Portal visibility: Updated
Sidebar.tsxto show Admin Portal for users withis_admin: true(not justPLATFORM_ADMIN)
Commands Reference
Start Dev Environment
bash
cd /home/d4sh010101/co-development/infrastructure
docker-compose --env-file .env.development -f docker-compose.yml -f docker-compose.dev.yml up -dRebuild Without Cache
bash
docker-compose -f docker-compose.yml -f docker-compose.dev.yml build --no-cacheCheck Container Status
bash
docker ps --filter "name=cyberorigen" --format "table {{.Names}}\t{{.Status}}\t{{.Ports}}"Create Admin User (if needed)
bash
# Generate password hash
docker exec cyberorigen-api python3 -c "
from passlib.context import CryptContext
pwd_context = CryptContext(schemes=['bcrypt'], deprecated='auto')
print(pwd_context.hash('<YOUR_PASSWORD>'))
"
# Insert into database
docker exec cyberorigen-postgres psql -U postgres -d security_agent -c "
INSERT INTO users (username, email, hashed_password, user_type, is_admin, is_active, created_at)
VALUES ('admin', '[email protected]', '<hash>', 'PLATFORM_ADMIN', true, true, NOW())
ON CONFLICT (username) DO NOTHING;
"Session Continuation - MFA Implementation
7. MFA TOTP Implementation
- Requirement: Mandatory MFA for all users using standard TOTP (compatible with any authenticator app)
- Backend: Already had MFA endpoints in
auth.py- status, setup, verify, disable, regenerate-backup-codes, verify-login - Frontend Changes:
- Added
mfaApitoapiService.tswith all MFA operations - Created
MFASetupView.tsx- step-by-step wizard with QR code, manual secret, backup codes - Created
MFAVerifyView.tsx- for login MFA verification (supports TOTP and backup codes) - Updated
LoginView.tsxto handlemfa_requiredresponse - Updated
App.tsxto integrate MFA flow with enforcement check
- Added
8. Docker/WSL2 Networking Issues with Twingate
- Problem: MFA endpoints returning 404 from host but worked inside container
- Cause: Twingate VPN client was interfering with Docker networking
- Solution:
- User uninstalled Twingate from Windows
- Removed orphaned Twingate Docker containers
- Restarted Docker Desktop
9. MFA Enforcement Not Working
- Problem: User could log in without being prompted for MFA setup
- Cause: MFA status check was getting 403 (token not ready) and error handler was skipping enforcement
- Solution: Modified MFA check in
App.tsxto add 500ms delay, retry on 401/403, and default to enforcing MFA setup on errors
10. Username Standards Implementation
- Requirement: Change from email-based usernames to alphanumeric format
- Rules:
- Alphanumeric only (letters and numbers)
- 3-20 characters
- Must start with a letter
- Reserved words blocked (admin, root, system, etc.)
- Backend: Added
validate_username()function inauth.py, updated register/signup endpoints - Frontend: Added validation to
LoginView.tsxandSignupView.tsx - Database: Updated user's username from email format to
d4sh010101
11. MFA Login Response Validation Error
- Problem: After setting up MFA, user couldn't log back in
- Error:
ResponseValidationError: access_token should be a valid string, got None - Cause: Login endpoint returned
access_token: Nonewhen MFA required, butTokenmodel required string - Solution: Created new
LoginResponsemodel with optionalaccess_tokenand MFA fields, updated/tokenendpoint to use it
Files Modified (MFA Session)
Backend (backend/api/routes/auth.py)
- Added
LoginResponsePydantic model for MFA-aware login responses - Added
validate_username()function for username format validation - Updated
/tokenendpoint to useLoginResponseinstead ofToken - Updated register/signup endpoints to validate usernames
Frontend (ui_cyberorigen)
services/apiService.ts- AddedmfaApiwith all MFA operations, updatedLoginResponsetypecomponents/MFASetupView.tsx- New component for MFA setup wizardcomponents/MFAVerifyView.tsx- New component for MFA verification during logincomponents/LoginView.tsx- AddedonMfaRequiredprop, username validationcomponents/SignupView.tsx- Added username validationApp.tsx- Integrated MFA flow with enforcement check and retry logic
Current User
- Username: d4sh010101
- Role: PLATFORM_ADMIN
- MFA: Enabled