From 59b4a5df8b3434631f027bd85db66df952834829 Mon Sep 17 00:00:00 2001 From: Yash Mehrotra Date: Mon, 7 Aug 2023 18:54:35 +0530 Subject: [PATCH] feat: use properties file and disable settings in clerk auth --- cmd/server.go | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/cmd/server.go b/cmd/server.go index a2b0fc0e9..94ae9a8c8 100644 --- a/cmd/server.go +++ b/cmd/server.go @@ -17,6 +17,7 @@ import ( "gorm.io/gorm" ctrl "sigs.k8s.io/controller-runtime" + "github.com/flanksource/duty/models" "github.com/flanksource/incident-commander/api" v1 "github.com/flanksource/incident-commander/api/v1" "github.com/flanksource/incident-commander/auth" @@ -34,6 +35,7 @@ import ( const ( HeaderCacheControl = "Cache-Control" CacheControlValue = "public, max-age=2592000, immutable" + propertiesFile = "mission-control.properties" ) var cacheSuffixes = []string{ @@ -86,6 +88,13 @@ func createHTTPServer(gormDB *gorm.DB) *echo.Echo { } e.Use(clerkHandler.Session) + // We also need to disable "settings.users" feature in database + // to hide the menu from UI + props := []models.AppProperty{{Name: "settings.user.disabled", Value: "true"}} + if err := models.SetProperties(db.Gorm, props); err != nil { + logger.Fatalf("Error setting property in database: %v", err) + } + default: logger.Fatalf("Invalid auth provider: %s", authMode) } @@ -188,6 +197,10 @@ var Serve = &cobra.Command{ db.PostgresDBAnonRole = "postgrest_api" } + if err := models.SetPropertiesInDBFromFile(db.Gorm, propertiesFile); err != nil { + logger.Fatalf("Error setting properties in database: %v", err) + } + if postgrestURI != "" { parsedURL, err := url.Parse(postgrestURI) if err != nil {