Skip to content
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

feat: use properties file and disable settings in clerk auth #476

Merged
merged 1 commit into from
Aug 7, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 13 additions & 0 deletions cmd/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand All @@ -34,6 +35,7 @@ import (
const (
HeaderCacheControl = "Cache-Control"
CacheControlValue = "public, max-age=2592000, immutable"
propertiesFile = "mission-control.properties"
)

var cacheSuffixes = []string{
Expand Down Expand Up @@ -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)
}
Expand Down Expand Up @@ -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 {
Expand Down
Loading