Manage .env from the admin panel
Add an Environment tab to /admin that lists every variable in .env.example and lets keys, OAuth settings, email settings and generated secrets be changed without SSH. Secrets are write-only; infrastructure variables are shown read-only. The backend never writes .env or touches Docker. It validates an edit and queues it in env-apply/run/request.json; env-apply/apply.py, run on the host by a systemd path unit (env-apply/install.sh), rewrites .env atomically, keeps .env.bak, and recreates only the services that read the change. backend/services/env_registry.json is the single list of variables, shared by the backend and the host script; a test keeps it in step with .env.example. It replaces the drifted checklist in handle_admin.go. The job capture token card moves to the new tab. Co-Authored-By: Claude Opus 5.5 <[email protected]>
This commit is contained in:
+15
-3
@@ -169,7 +169,15 @@ func main() {
|
||||
log.Println("Job capture token not loaded:", err)
|
||||
}
|
||||
|
||||
store := handlers.Store{DB: db, SpotifyAuth: spotifyAuth, SpotifyClient: spotifyClient, Auth: auth, Notes: notes, LoginLimiter: loginLimiter, EmailSync: emailSync, GiteaHost: giteaHost, GiteaPort: giteaPort, SteamAPIKey: steamAPIKey, SteamID: steamID, PythonURL: pythonURL, CaptureToken: captureToken}
|
||||
// ENVIRONMENT
|
||||
// The registry is embedded, so the only way this fails is a malformed
|
||||
// env_registry.json — a build mistake worth stopping for.
|
||||
envManager, err := services.NewEnvManager(services.ENV_APPLY_DIR)
|
||||
if err != nil {
|
||||
log.Fatal(err)
|
||||
}
|
||||
|
||||
store := handlers.Store{DB: db, SpotifyAuth: spotifyAuth, SpotifyClient: spotifyClient, Auth: auth, Notes: notes, LoginLimiter: loginLimiter, EmailSync: emailSync, GiteaHost: giteaHost, GiteaPort: giteaPort, SteamAPIKey: steamAPIKey, SteamID: steamID, PythonURL: pythonURL, CaptureToken: captureToken, Env: envManager}
|
||||
|
||||
// Route groups. AdminMiddleware reads the claims AuthMiddlewear stored in
|
||||
// the Gin context, so the order in the admin group matters.
|
||||
@@ -226,9 +234,13 @@ func main() {
|
||||
// NOTES
|
||||
admin.GET("/notes/*path", store.GetNoteFile)
|
||||
|
||||
// ADMIN DIAGNOSTICS: env-var checklist and log tail for the admin panel.
|
||||
admin.GET("/admin/config", store.ConfigCheck)
|
||||
// ADMIN DIAGNOSTICS: log tail for the admin panel.
|
||||
admin.GET("/admin/logs", store.Logs)
|
||||
// ENVIRONMENT: report on .env and queue changes for the host to apply.
|
||||
admin.GET("/admin/env", store.GetEnv)
|
||||
admin.PUT("/admin/env", store.UpdateEnv)
|
||||
admin.GET("/admin/env/status", store.GetEnvStatus)
|
||||
admin.DELETE("/admin/env/pending", store.CancelEnv)
|
||||
// The job capture token is managed with the session cookie, never with
|
||||
// the token itself.
|
||||
admin.GET("/admin/capture-token", store.GetCaptureToken)
|
||||
|
||||
Reference in New Issue
Block a user