mirror of
https://github.com/SigNoz/signoz.git
synced 2026-02-03 08:33:26 +00:00
* feat(authz): initial commit for migrating rbac to openfga * feat(authz): make the role updates idempotant * feat(authz): split role module into role and grant * feat(authz): some naming changes * feat(authz): integrate the grant module * feat(authz): add support for migrating existing user role * feat(authz): add support for migrating existing user role * feat(authz): figure out the * selector * feat(authz): merge main * feat(authz): merge main * feat(authz): address couple of todos * feat(authz): address couple of todos * feat(authz): fix tests and revert public dashboard change * feat(authz): fix tests and revert public dashboard change * feat(authz): add open api spec * feat(authz): add open api spec * feat(authz): add api key changes and missing migration * feat(authz): split role into getter and setter * feat(authz): add integration tests for authz register * feat(authz): add more tests for user invite and delete * feat(authz): update user tests * feat(authz): rename grant to granter * feat(authz): address review comments * feat(authz): address review comments * feat(authz): address review comments * feat(authz): add the migration for existing roles * feat(authz): go mod tidy * feat(authz): fix integration tests * feat(authz): handle community changes * feat(authz): handle community changes * feat(authz): role selectors for open claims * feat(authz): role selectors for open claims * feat(authz): prevent duplicate entries for changelog * feat(authz): scafolding for rbac migration * feat(authz): scafolding for rbac migration * feat(authz): scafolding for rbac migration * feat(authz): scafolding for rbac migration * feat(authz): scafolding for rbac migration
131 lines
4.5 KiB
Go
131 lines
4.5 KiB
Go
package main
|
|
|
|
import (
|
|
"context"
|
|
"log/slog"
|
|
|
|
"github.com/SigNoz/signoz/cmd"
|
|
"github.com/SigNoz/signoz/pkg/analytics"
|
|
"github.com/SigNoz/signoz/pkg/authn"
|
|
"github.com/SigNoz/signoz/pkg/authz"
|
|
"github.com/SigNoz/signoz/pkg/authz/openfgaauthz"
|
|
"github.com/SigNoz/signoz/pkg/authz/openfgaschema"
|
|
"github.com/SigNoz/signoz/pkg/factory"
|
|
"github.com/SigNoz/signoz/pkg/gateway"
|
|
"github.com/SigNoz/signoz/pkg/gateway/noopgateway"
|
|
"github.com/SigNoz/signoz/pkg/licensing"
|
|
"github.com/SigNoz/signoz/pkg/licensing/nooplicensing"
|
|
"github.com/SigNoz/signoz/pkg/modules/dashboard"
|
|
"github.com/SigNoz/signoz/pkg/modules/dashboard/impldashboard"
|
|
"github.com/SigNoz/signoz/pkg/modules/organization"
|
|
"github.com/SigNoz/signoz/pkg/modules/role"
|
|
"github.com/SigNoz/signoz/pkg/modules/role/implrole"
|
|
"github.com/SigNoz/signoz/pkg/querier"
|
|
"github.com/SigNoz/signoz/pkg/query-service/app"
|
|
"github.com/SigNoz/signoz/pkg/queryparser"
|
|
"github.com/SigNoz/signoz/pkg/signoz"
|
|
"github.com/SigNoz/signoz/pkg/sqlschema"
|
|
"github.com/SigNoz/signoz/pkg/sqlstore"
|
|
"github.com/SigNoz/signoz/pkg/types/authtypes"
|
|
"github.com/SigNoz/signoz/pkg/version"
|
|
"github.com/SigNoz/signoz/pkg/zeus"
|
|
"github.com/SigNoz/signoz/pkg/zeus/noopzeus"
|
|
"github.com/spf13/cobra"
|
|
)
|
|
|
|
func registerServer(parentCmd *cobra.Command, logger *slog.Logger) {
|
|
var flags signoz.DeprecatedFlags
|
|
|
|
serverCmd := &cobra.Command{
|
|
Use: "server",
|
|
Short: "Run the SigNoz server",
|
|
FParseErrWhitelist: cobra.FParseErrWhitelist{UnknownFlags: true},
|
|
RunE: func(currCmd *cobra.Command, args []string) error {
|
|
config, err := cmd.NewSigNozConfig(currCmd.Context(), logger, flags)
|
|
if err != nil {
|
|
return err
|
|
}
|
|
|
|
return runServer(currCmd.Context(), config, logger)
|
|
},
|
|
}
|
|
|
|
flags.RegisterFlags(serverCmd)
|
|
parentCmd.AddCommand(serverCmd)
|
|
}
|
|
|
|
func runServer(ctx context.Context, config signoz.Config, logger *slog.Logger) error {
|
|
// print the version
|
|
version.Info.PrettyPrint(config.Version)
|
|
|
|
signoz, err := signoz.New(
|
|
ctx,
|
|
config,
|
|
zeus.Config{},
|
|
noopzeus.NewProviderFactory(),
|
|
licensing.Config{},
|
|
func(_ sqlstore.SQLStore, _ zeus.Zeus, _ organization.Getter, _ analytics.Analytics) factory.ProviderFactory[licensing.Licensing, licensing.Config] {
|
|
return nooplicensing.NewFactory()
|
|
},
|
|
signoz.NewEmailingProviderFactories(),
|
|
signoz.NewCacheProviderFactories(),
|
|
signoz.NewWebProviderFactories(),
|
|
func(sqlstore sqlstore.SQLStore) factory.NamedMap[factory.ProviderFactory[sqlschema.SQLSchema, sqlschema.Config]] {
|
|
return signoz.NewSQLSchemaProviderFactories(sqlstore)
|
|
},
|
|
signoz.NewSQLStoreProviderFactories(),
|
|
signoz.NewTelemetryStoreProviderFactories(),
|
|
func(ctx context.Context, providerSettings factory.ProviderSettings, store authtypes.AuthNStore, licensing licensing.Licensing) (map[authtypes.AuthNProvider]authn.AuthN, error) {
|
|
return signoz.NewAuthNs(ctx, providerSettings, store, licensing)
|
|
},
|
|
func(ctx context.Context, sqlstore sqlstore.SQLStore) factory.ProviderFactory[authz.AuthZ, authz.Config] {
|
|
return openfgaauthz.NewProviderFactory(sqlstore, openfgaschema.NewSchema().Get(ctx))
|
|
},
|
|
func(store sqlstore.SQLStore, settings factory.ProviderSettings, analytics analytics.Analytics, orgGetter organization.Getter, _ role.Setter, _ role.Granter, queryParser queryparser.QueryParser, _ querier.Querier, _ licensing.Licensing) dashboard.Module {
|
|
return impldashboard.NewModule(impldashboard.NewStore(store), settings, analytics, orgGetter, queryParser)
|
|
},
|
|
func(_ licensing.Licensing) factory.ProviderFactory[gateway.Gateway, gateway.Config] {
|
|
return noopgateway.NewProviderFactory()
|
|
},
|
|
func(store sqlstore.SQLStore, authz authz.AuthZ, licensing licensing.Licensing, _ []role.RegisterTypeable) role.Setter {
|
|
return implrole.NewSetter(implrole.NewStore(store), authz)
|
|
},
|
|
)
|
|
if err != nil {
|
|
logger.ErrorContext(ctx, "failed to create signoz", "error", err)
|
|
return err
|
|
}
|
|
|
|
server, err := app.NewServer(config, signoz)
|
|
if err != nil {
|
|
logger.ErrorContext(ctx, "failed to create server", "error", err)
|
|
return err
|
|
}
|
|
|
|
if err := server.Start(ctx); err != nil {
|
|
logger.ErrorContext(ctx, "failed to start server", "error", err)
|
|
return err
|
|
}
|
|
|
|
signoz.Start(ctx)
|
|
|
|
if err := signoz.Wait(ctx); err != nil {
|
|
logger.ErrorContext(ctx, "failed to start signoz", "error", err)
|
|
return err
|
|
}
|
|
|
|
err = server.Stop(ctx)
|
|
if err != nil {
|
|
logger.ErrorContext(ctx, "failed to stop server", "error", err)
|
|
return err
|
|
}
|
|
|
|
err = signoz.Stop(ctx)
|
|
if err != nil {
|
|
logger.ErrorContext(ctx, "failed to stop signoz", "error", err)
|
|
return err
|
|
}
|
|
|
|
return nil
|
|
}
|