fix: prevent 'admin with no permissions' on fresh install#49
Merged
Conversation
Fixes permission issues when user-policy.json creation fails or is missing. Changes: 1. init.go: Make createDefaultPolicy() failure fatal - Previously: warning only, continued execution - Now: exits with detailed error message - Provides actionable guidance (antivirus, permissions, disk space) 2. manager.go: Add safe RBAC fallback in LoadPolicy() - Previously: returned RBAC=nil when file missing - Now: returns minimal admin role with full permissions - Prevents "admin with no permissions" scenario in dashboard 3. manager.go: Enhanced error messages for SavePolicy() - Added specific causes for write failures - Windows-specific guidance (antivirus, OneDrive, UAC) Root Cause: - On Windows, file write can fail due to: * Antivirus real-time protection scanning binary * OneDrive/Dropbox sync conflicts * Controlled Folder Access (ransomware protection) * Transient I/O errors - Silent failure left .env with CURRENT_ROLE=admin but no policy file - Dashboard loaded RBAC=nil → permission check failed Impact: - Prevents confusing UX where admin role has no edit buttons - Provides clear error messages to help users resolve issues - Fails fast instead of creating inconsistent state
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes permission issues when user-policy.json creation fails or is missing.
Changes:
init.go: Make createDefaultPolicy() failure fatal
manager.go: Add safe RBAC fallback in LoadPolicy()
manager.go: Enhanced error messages for SavePolicy()
Root Cause:
Impact: