Add system user to context for system CLI ops
This commit is contained in:
@@ -7,6 +7,7 @@ import (
|
||||
"path"
|
||||
"strings"
|
||||
|
||||
"github.com/cortezaproject/corteza-server/pkg/auth"
|
||||
"github.com/cortezaproject/corteza-server/pkg/envoy/yaml"
|
||||
"github.com/spf13/cobra"
|
||||
|
||||
@@ -27,6 +28,8 @@ func Export(ctx context.Context, storeInit func(ctx context.Context) (store.Stor
|
||||
Long: `Export data to YAML files.`,
|
||||
|
||||
Run: func(cmd *cobra.Command, args []string) {
|
||||
ctx = auth.SetIdentityToContext(ctx, auth.ServiceUser())
|
||||
|
||||
var (
|
||||
f = su.NewDecodeFilter()
|
||||
)
|
||||
|
||||
@@ -3,6 +3,7 @@ package commands
|
||||
import (
|
||||
"context"
|
||||
|
||||
"github.com/cortezaproject/corteza-server/pkg/auth"
|
||||
"github.com/cortezaproject/corteza-server/pkg/cli"
|
||||
"github.com/cortezaproject/corteza-server/store"
|
||||
"github.com/cortezaproject/corteza-server/system/service"
|
||||
@@ -31,6 +32,8 @@ func rolesAddUser(ctx context.Context, app serviceInitializer) *cobra.Command {
|
||||
Args: cobra.ExactArgs(2),
|
||||
PreRunE: commandPreRunInitService(app),
|
||||
Run: func(cmd *cobra.Command, args []string) {
|
||||
ctx = auth.SetIdentityToContext(ctx, auth.ServiceUser())
|
||||
|
||||
var (
|
||||
roleStr, userStr = args[0], args[1]
|
||||
|
||||
@@ -62,6 +65,8 @@ func rolesList(ctx context.Context, app serviceInitializer) *cobra.Command {
|
||||
Short: "List all roles",
|
||||
PreRunE: commandPreRunInitService(app),
|
||||
Run: func(cmd *cobra.Command, args []string) {
|
||||
ctx = auth.SetIdentityToContext(ctx, auth.ServiceUser())
|
||||
|
||||
f := types.RoleFilter{Query: ""}
|
||||
if len(args) > 0 {
|
||||
f.Query = args[0]
|
||||
|
||||
@@ -6,6 +6,7 @@ import (
|
||||
"os"
|
||||
"strings"
|
||||
|
||||
"github.com/cortezaproject/corteza-server/pkg/auth"
|
||||
"github.com/cortezaproject/corteza-server/system/types"
|
||||
|
||||
"github.com/spf13/cobra"
|
||||
@@ -27,6 +28,8 @@ func Settings(ctx context.Context, app serviceInitializer) *cobra.Command {
|
||||
Short: "List all",
|
||||
PreRunE: commandPreRunInitService(app),
|
||||
Run: func(cmd *cobra.Command, args []string) {
|
||||
ctx = auth.SetIdentityToContext(ctx, auth.ServiceUser())
|
||||
|
||||
prefix := cmd.Flags().Lookup("prefix").Value.String()
|
||||
if kv, err := service.DefaultSettings.FindByPrefix(ctx, prefix); err != nil {
|
||||
cli.HandleError(err)
|
||||
@@ -54,6 +57,8 @@ func Settings(ctx context.Context, app serviceInitializer) *cobra.Command {
|
||||
Args: cobra.ExactArgs(1),
|
||||
PreRunE: commandPreRunInitService(app),
|
||||
Run: func(cmd *cobra.Command, args []string) {
|
||||
ctx = auth.SetIdentityToContext(ctx, auth.ServiceUser())
|
||||
|
||||
if v, err := service.DefaultSettings.Get(ctx, args[0], 0); err != nil {
|
||||
cli.HandleError(err)
|
||||
} else if v != nil {
|
||||
@@ -68,6 +73,8 @@ func Settings(ctx context.Context, app serviceInitializer) *cobra.Command {
|
||||
Args: cobra.ExactArgs(2),
|
||||
PreRunE: commandPreRunInitService(app),
|
||||
Run: func(cmd *cobra.Command, args []string) {
|
||||
ctx = auth.SetIdentityToContext(ctx, auth.ServiceUser())
|
||||
|
||||
value := args[1]
|
||||
|
||||
v := &types.SettingValue{
|
||||
@@ -98,6 +105,8 @@ func Settings(ctx context.Context, app serviceInitializer) *cobra.Command {
|
||||
Args: cobra.MaximumNArgs(1),
|
||||
PreRunE: commandPreRunInitService(app),
|
||||
Run: func(cmd *cobra.Command, args []string) {
|
||||
ctx = auth.SetIdentityToContext(ctx, auth.ServiceUser())
|
||||
|
||||
var (
|
||||
fh *os.File
|
||||
err error
|
||||
@@ -137,6 +146,8 @@ func Settings(ctx context.Context, app serviceInitializer) *cobra.Command {
|
||||
Args: cobra.MaximumNArgs(1),
|
||||
PreRunE: commandPreRunInitService(app),
|
||||
Run: func(cmd *cobra.Command, args []string) {
|
||||
ctx = auth.SetIdentityToContext(ctx, auth.ServiceUser())
|
||||
|
||||
var (
|
||||
fh *os.File
|
||||
err error
|
||||
@@ -169,6 +180,8 @@ func Settings(ctx context.Context, app serviceInitializer) *cobra.Command {
|
||||
Args: cobra.MinimumNArgs(0),
|
||||
PreRunE: commandPreRunInitService(app),
|
||||
Run: func(cmd *cobra.Command, args []string) {
|
||||
ctx = auth.SetIdentityToContext(ctx, auth.ServiceUser())
|
||||
|
||||
var (
|
||||
names = []string{}
|
||||
)
|
||||
|
||||
@@ -6,6 +6,7 @@ import (
|
||||
"strconv"
|
||||
"syscall"
|
||||
|
||||
"github.com/cortezaproject/corteza-server/pkg/auth"
|
||||
"github.com/cortezaproject/corteza-server/pkg/cli"
|
||||
"github.com/cortezaproject/corteza-server/pkg/filter"
|
||||
"github.com/cortezaproject/corteza-server/system/service"
|
||||
@@ -32,6 +33,8 @@ func Users(ctx context.Context, app serviceInitializer) *cobra.Command {
|
||||
|
||||
PreRunE: commandPreRunInitService(app),
|
||||
Run: func(cmd *cobra.Command, args []string) {
|
||||
ctx = auth.SetIdentityToContext(ctx, auth.ServiceUser())
|
||||
|
||||
var (
|
||||
queryFlag = cmd.Flags().Lookup("query").Value.String()
|
||||
limitFlag = cmd.Flags().Lookup("limit").Value.String()
|
||||
@@ -85,6 +88,8 @@ func Users(ctx context.Context, app serviceInitializer) *cobra.Command {
|
||||
|
||||
PreRunE: commandPreRunInitService(app),
|
||||
Run: func(cmd *cobra.Command, args []string) {
|
||||
ctx = auth.SetIdentityToContext(ctx, auth.ServiceUser())
|
||||
|
||||
var (
|
||||
authSvc = service.Auth()
|
||||
|
||||
@@ -95,7 +100,7 @@ func Users(ctx context.Context, app serviceInitializer) *cobra.Command {
|
||||
password []byte
|
||||
)
|
||||
|
||||
// Update current settings to be sure that we do not have outdated values
|
||||
// Update current settings to be sure we do not have outdated values
|
||||
cli.HandleError(service.DefaultSettings.UpdateCurrent(ctx))
|
||||
|
||||
if user, err = service.DefaultUser.Create(ctx, user); err != nil {
|
||||
@@ -134,6 +139,8 @@ func Users(ctx context.Context, app serviceInitializer) *cobra.Command {
|
||||
Args: cobra.MinimumNArgs(1),
|
||||
PreRunE: commandPreRunInitService(app),
|
||||
Run: func(cmd *cobra.Command, args []string) {
|
||||
ctx = auth.SetIdentityToContext(ctx, auth.ServiceUser())
|
||||
|
||||
var (
|
||||
user *types.User
|
||||
err error
|
||||
|
||||
Reference in New Issue
Block a user