Use superuser context on structure and data sync, options regenerated
This commit is contained in:
@@ -47,8 +47,7 @@ func (dp *dataProcesser) Process(ctx context.Context, payload []byte) (Processer
|
||||
}, nil
|
||||
}
|
||||
|
||||
// get the user that is tied to this node
|
||||
ctx = auth.SetIdentityToContext(ctx, dp.User)
|
||||
ctx = auth.SetSuperUserContext(ctx)
|
||||
|
||||
for _, er := range o {
|
||||
dp.SyncService.mapper.Merge(&er.Values, dp.ModuleMappingValues, dp.ModuleMappings)
|
||||
|
||||
@@ -7,6 +7,7 @@ import (
|
||||
"time"
|
||||
|
||||
"github.com/cortezaproject/corteza-server/federation/types"
|
||||
"github.com/cortezaproject/corteza-server/pkg/auth"
|
||||
"go.uber.org/zap"
|
||||
)
|
||||
|
||||
@@ -159,10 +160,11 @@ func (w *syncWorkerData) Watch(ctx context.Context, delay time.Duration, limit i
|
||||
w.delay = delay
|
||||
w.limit = limit
|
||||
|
||||
// todo - get auth from the node
|
||||
ctx, cancel := context.WithCancel(ctx)
|
||||
defer cancel()
|
||||
|
||||
ctx = auth.SetSuperUserContext(ctx)
|
||||
|
||||
ticker := time.NewTicker(delay)
|
||||
|
||||
w.PrepareForNodes(ctx, urls)
|
||||
|
||||
@@ -7,6 +7,7 @@ import (
|
||||
"time"
|
||||
|
||||
"github.com/cortezaproject/corteza-server/federation/types"
|
||||
"github.com/cortezaproject/corteza-server/pkg/auth"
|
||||
"github.com/davecgh/go-spew/spew"
|
||||
"go.uber.org/zap"
|
||||
)
|
||||
@@ -103,10 +104,11 @@ func (w *syncWorkerStructure) Watch(ctx context.Context, delay time.Duration, li
|
||||
w.delay = delay
|
||||
w.limit = limit
|
||||
|
||||
// todo - get auth from the node
|
||||
ctx, cancel := context.WithCancel(ctx)
|
||||
defer cancel()
|
||||
|
||||
ctx = auth.SetSuperUserContext(ctx)
|
||||
|
||||
ticker := time.NewTicker(delay)
|
||||
|
||||
w.PrepareForNodes(ctx, urls)
|
||||
|
||||
@@ -0,0 +1,43 @@
|
||||
package options
|
||||
|
||||
// This file is auto-generated.
|
||||
//
|
||||
// Changes to this file may cause incorrect behavior and will be lost if
|
||||
// the code is regenerated.
|
||||
//
|
||||
// Definitions file that controls how this file is generated:
|
||||
// pkg/options/federation.yaml
|
||||
|
||||
import (
|
||||
"time"
|
||||
)
|
||||
|
||||
type (
|
||||
FederationOpt struct {
|
||||
Enabled bool `env:"FEDERATION_ENABLED"`
|
||||
Label string `env:"FEDERATION_LABEL"`
|
||||
Host string `env:"FEDERATION_HOST"`
|
||||
StructureMonitorInterval time.Duration `env:"FEDERATION_SYNC_STRUCTURE_MONITOR_INTERVAL"`
|
||||
StructurePageSize int `env:"FEDERATION_SYNC_STRUCTURE_PAGE_SIZE"`
|
||||
DataMonitorInterval time.Duration `env:"FEDERATION_SYNC_DATA_MONITOR_INTERVAL"`
|
||||
DataPageSize int `env:"FEDERATION_SYNC_DATA_PAGE_SIZE"`
|
||||
}
|
||||
)
|
||||
|
||||
// Federation initializes and returns a FederationOpt with default values
|
||||
func Federation() (o *FederationOpt) {
|
||||
o = &FederationOpt{}
|
||||
|
||||
fill(o)
|
||||
|
||||
// Function that allows access to custom logic inside the parent function.
|
||||
// The custom logic in the other file should be like:
|
||||
// func (o *Federation) Defaults() {...}
|
||||
func(o interface{}) {
|
||||
if def, ok := o.(interface{ Defaults() }); ok {
|
||||
def.Defaults()
|
||||
}
|
||||
}(o)
|
||||
|
||||
return
|
||||
}
|
||||
@@ -0,0 +1,33 @@
|
||||
name: federation
|
||||
|
||||
imports:
|
||||
- time
|
||||
|
||||
props:
|
||||
- name: Enabled
|
||||
type: bool
|
||||
env: FEDERATION_ENABLED
|
||||
|
||||
- name: Label
|
||||
type: string
|
||||
env: FEDERATION_LABEL
|
||||
|
||||
- name: Host
|
||||
type: string
|
||||
env: FEDERATION_HOST
|
||||
|
||||
- name: StructureMonitorInterval
|
||||
type: time.Duration
|
||||
env: FEDERATION_SYNC_STRUCTURE_MONITOR_INTERVAL
|
||||
|
||||
- name: StructurePageSize
|
||||
type: int
|
||||
env: FEDERATION_SYNC_STRUCTURE_PAGE_SIZE
|
||||
|
||||
- name: DataMonitorInterval
|
||||
type: time.Duration
|
||||
env: FEDERATION_SYNC_DATA_MONITOR_INTERVAL
|
||||
|
||||
- name: DataPageSize
|
||||
type: int
|
||||
env: FEDERATION_SYNC_DATA_PAGE_SIZE
|
||||
@@ -0,0 +1,34 @@
|
||||
allow:
|
||||
admins:
|
||||
federation:
|
||||
- grant
|
||||
- access
|
||||
- pair
|
||||
- settings.read
|
||||
- settings.manage
|
||||
- node.create
|
||||
|
||||
federation:node:
|
||||
- manage
|
||||
- module.create
|
||||
|
||||
federation:module:
|
||||
- manage
|
||||
- map
|
||||
|
||||
federation:
|
||||
federation:
|
||||
- grant
|
||||
- access
|
||||
- pair
|
||||
- settings.read
|
||||
- settings.manage
|
||||
- node.create
|
||||
|
||||
federation:node:
|
||||
- manage
|
||||
- module.create
|
||||
|
||||
federation:module:
|
||||
- manage
|
||||
- map
|
||||
@@ -2,6 +2,8 @@ package service
|
||||
|
||||
import (
|
||||
"context"
|
||||
"strconv"
|
||||
|
||||
"github.com/cortezaproject/corteza-server/pkg/actionlog"
|
||||
"github.com/cortezaproject/corteza-server/pkg/errors"
|
||||
"github.com/cortezaproject/corteza-server/pkg/eventbus"
|
||||
@@ -11,7 +13,6 @@ import (
|
||||
"github.com/cortezaproject/corteza-server/store"
|
||||
"github.com/cortezaproject/corteza-server/system/service/event"
|
||||
"github.com/cortezaproject/corteza-server/system/types"
|
||||
"strconv"
|
||||
)
|
||||
|
||||
type (
|
||||
@@ -214,7 +215,8 @@ func (svc role) FindByAny(ctx context.Context, identifier interface{}) (r *types
|
||||
return svc.With(ctx).FindByID(ID)
|
||||
} else {
|
||||
r, err = svc.With(ctx).FindByHandle(strIdentifier)
|
||||
if err == nil && r.ID == 0 {
|
||||
|
||||
if (err == nil && r.ID == 0) || errors.IsNotFound(err) {
|
||||
return svc.With(ctx).FindByName(strIdentifier)
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user