-
Notifications
You must be signed in to change notification settings - Fork 0
feat(api): Add setup wizard endpoints for installer #70
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
Add setup flow endpoints for the installer UI to configure: - System validation checks - Domain configuration - CORS/UI origin settings - Initial user creation Note: Dynamic CORS middleware included but may be removed if installer UI is served from same origin. Signed-off-by: nfebe <fenn25.fn@gmail.com>
Code Review SummaryThis pull request introduces a comprehensive initial setup flow for the agent, encapsulated within the new 🚀 Key Improvements
🚨 Critical Issues
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Review complete. See the overview comment for a summary.
| bytes := make([]byte, length) | ||
| if _, err := rand.Read(bytes); err != nil { | ||
| fallback := make([]byte, length) | ||
| for i := range fallback { | ||
| fallback[i] = byte(os.Getpid()>>i) ^ byte(time.Now().UnixNano()>>i) | ||
| } | ||
| return hex.EncodeToString(fallback) | ||
| } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The fallback for cryptoRand.Read in generateSecret uses os.Getpid() and time.Now().UnixNano(), which provide very low entropy. While cryptoRand.Read failing is rare, if it does, the generated JWT secret would be predictable, posing a significant security risk. It's generally better to let cryptoRand.Read fail and return an error for critical security functions like secret generation, rather than using a weak fallback.
| bytes := make([]byte, length) | |
| if _, err := rand.Read(bytes); err != nil { | |
| fallback := make([]byte, length) | |
| for i := range fallback { | |
| fallback[i] = byte(os.Getpid()>>i) ^ byte(time.Now().UnixNano()>>i) | |
| } | |
| return hex.EncodeToString(fallback) | |
| } | |
| func generateSecret(length int) string { | |
| bytes := make([]byte, length) | |
| if _, err := rand.Read(bytes); err != nil { | |
| // Log the error and potentially panic or return an empty string/error | |
| // to prevent using a weak secret. | |
| log.Fatalf("Failed to generate secure random bytes for JWT secret: %v", err) | |
| return "" | |
| } | |
| return hex.EncodeToString(bytes) | |
| } |
Add setup flow endpoints for the installer UI to configure:
Note: Dynamic CORS middleware included but may be removed if installer UI is served from same origin.