feat: port reduction (#323)

* move mgmt pkg

* begin package restructure

* rename auth package to authz

* begin start api

* move auth

* move admin

* fix merge

* configs and interceptors

* interceptor

* revert generate-grpc.sh

* some cleanups

* console

* move console

* fix tests and merging

* js linting

* merge

* merging and configs

* change k8s base to current ports

* fixes

* cleanup

* regenerate proto

* remove unnecessary whitespace

* missing param

* go mod tidy

* fix merging

* move login pkg

* cleanup

* move api pkgs again

* fix pkg naming

* fix generate-static.sh for login

* update workflow

* fixes

* logging

* remove duplicate

* comment for optional gateway interfaces

* regenerate protos

* fix proto imports for grpc web

* protos

* grpc web generate

* grpc web generate

* fix changes

* add translation interceptor

* fix merging

* regenerate mgmt proto
This commit is contained in:
Livio Amstutz
2020-07-08 13:56:37 +02:00
committed by GitHub
parent 708652a655
commit 3549a8b64e
330 changed files with 30495 additions and 30809 deletions

View File

@@ -2,7 +2,8 @@ package eventsourcing
import (
"context"
"github.com/caos/zitadel/internal/api/auth"
"github.com/caos/zitadel/internal/api/authz"
caos_errs "github.com/caos/zitadel/internal/errors"
es_sdk "github.com/caos/zitadel/internal/eventstore/sdk"
pol_model "github.com/caos/zitadel/internal/policy/model"
@@ -25,7 +26,7 @@ func (es *PolicyEventstore) GetPasswordAgePolicy(ctx context.Context, id string)
}
func (es *PolicyEventstore) CreatePasswordAgePolicy(ctx context.Context, policy *pol_model.PasswordAgePolicy) (*pol_model.PasswordAgePolicy, error) {
ctxData := auth.GetCtxData(ctx)
ctxData := authz.GetCtxData(ctx)
existingPolicy, err := es.GetPasswordAgePolicy(ctx, ctxData.OrgID)
if err != nil && !caos_errs.IsNotFound(err) {
return nil, err
@@ -53,7 +54,7 @@ func (es *PolicyEventstore) CreatePasswordAgePolicy(ctx context.Context, policy
}
func (es *PolicyEventstore) UpdatePasswordAgePolicy(ctx context.Context, policy *pol_model.PasswordAgePolicy) (*pol_model.PasswordAgePolicy, error) {
ctxData := auth.GetCtxData(ctx)
ctxData := authz.GetCtxData(ctx)
existingPolicy, err := es.GetPasswordAgePolicy(ctx, ctxData.OrgID)
if err != nil {
return nil, err

View File

@@ -4,11 +4,12 @@ import (
"context"
"testing"
"github.com/caos/zitadel/internal/api/auth"
"github.com/golang/mock/gomock"
"github.com/caos/zitadel/internal/api/authz"
caos_errs "github.com/caos/zitadel/internal/errors"
es_models "github.com/caos/zitadel/internal/eventstore/models"
"github.com/caos/zitadel/internal/policy/model"
"github.com/golang/mock/gomock"
)
func TestGetPasswordAgePolicy(t *testing.T) {
@@ -84,7 +85,7 @@ func TestCreatePasswordAgePolicy(t *testing.T) {
name: "create policy, ok",
args: args{
es: GetMockPasswordAgePolicyNoEvents(ctrl),
ctx: auth.NewMockContext("orgID", "userID"),
ctx: authz.NewMockContext("orgID", "userID"),
policy: &model.PasswordAgePolicy{ObjectRoot: es_models.ObjectRoot{AggregateID: "AggregateID1", Sequence: 2}, Description: "Name"},
},
res: res{
@@ -130,7 +131,7 @@ func TestUpdatePasswordAgePolicy(t *testing.T) {
name: "update policy, ok",
args: args{
es: GetMockPasswordAgePolicy(ctrl),
ctx: auth.NewMockContext("orgID", "userID"),
ctx: authz.NewMockContext("orgID", "userID"),
new: &model.PasswordAgePolicy{ObjectRoot: es_models.ObjectRoot{AggregateID: "AggregateID", Sequence: 1}, Description: "NameNew"},
},
res: res{
@@ -141,7 +142,7 @@ func TestUpdatePasswordAgePolicy(t *testing.T) {
name: "existing policy not found",
args: args{
es: GetMockPasswordAgePolicyNoEvents(ctrl),
ctx: auth.NewMockContext("orgID", "userID"),
ctx: authz.NewMockContext("orgID", "userID"),
new: &model.PasswordAgePolicy{ObjectRoot: es_models.ObjectRoot{AggregateID: "AggregateID", Sequence: 1}, Description: "NameNew"},
},
res: res{

View File

@@ -2,7 +2,8 @@ package eventsourcing
import (
"context"
"github.com/caos/zitadel/internal/api/auth"
"github.com/caos/zitadel/internal/api/authz"
caos_errs "github.com/caos/zitadel/internal/errors"
es_sdk "github.com/caos/zitadel/internal/eventstore/sdk"
pol_model "github.com/caos/zitadel/internal/policy/model"
@@ -28,7 +29,7 @@ func (es *PolicyEventstore) GetPasswordComplexityPolicy(ctx context.Context, id
}
func (es *PolicyEventstore) CreatePasswordComplexityPolicy(ctx context.Context, policy *pol_model.PasswordComplexityPolicy) (*pol_model.PasswordComplexityPolicy, error) {
ctxData := auth.GetCtxData(ctx)
ctxData := authz.GetCtxData(ctx)
existingPolicy, err := es.GetPasswordComplexityPolicy(ctx, ctxData.OrgID)
if err != nil && !caos_errs.IsNotFound(err) {
return nil, err
@@ -56,7 +57,7 @@ func (es *PolicyEventstore) CreatePasswordComplexityPolicy(ctx context.Context,
}
func (es *PolicyEventstore) UpdatePasswordComplexityPolicy(ctx context.Context, policy *pol_model.PasswordComplexityPolicy) (*pol_model.PasswordComplexityPolicy, error) {
ctxData := auth.GetCtxData(ctx)
ctxData := authz.GetCtxData(ctx)
existingPolicy, err := es.GetPasswordComplexityPolicy(ctx, ctxData.OrgID)
if err != nil {
return nil, err

View File

@@ -4,11 +4,12 @@ import (
"context"
"testing"
"github.com/caos/zitadel/internal/api/auth"
"github.com/golang/mock/gomock"
"github.com/caos/zitadel/internal/api/authz"
caos_errs "github.com/caos/zitadel/internal/errors"
es_models "github.com/caos/zitadel/internal/eventstore/models"
"github.com/caos/zitadel/internal/policy/model"
"github.com/golang/mock/gomock"
)
func TestGetPasswordComplexityPolicy(t *testing.T) {
@@ -84,7 +85,7 @@ func TestCreatePasswordComplexityPolicy(t *testing.T) {
name: "create policy, ok",
args: args{
es: GetMockPasswordComplexityPolicyNoEvents(ctrl),
ctx: auth.NewMockContext("orgID", "userID"),
ctx: authz.NewMockContext("orgID", "userID"),
policy: &model.PasswordComplexityPolicy{ObjectRoot: es_models.ObjectRoot{AggregateID: "AggregateID1", Sequence: 2}, Description: "Name"},
},
res: res{
@@ -130,7 +131,7 @@ func TestUpdatePasswordComplexityPolicy(t *testing.T) {
name: "update policy, ok",
args: args{
es: GetMockPasswordComplexityPolicy(ctrl),
ctx: auth.NewMockContext("orgID", "userID"),
ctx: authz.NewMockContext("orgID", "userID"),
new: &model.PasswordComplexityPolicy{ObjectRoot: es_models.ObjectRoot{AggregateID: "AggregateID", Sequence: 1}, Description: "NameNew"},
},
res: res{
@@ -141,7 +142,7 @@ func TestUpdatePasswordComplexityPolicy(t *testing.T) {
name: "existing policy not found",
args: args{
es: GetMockPasswordComplexityPolicyNoEvents(ctrl),
ctx: auth.NewMockContext("orgID", "userID"),
ctx: authz.NewMockContext("orgID", "userID"),
new: &model.PasswordComplexityPolicy{ObjectRoot: es_models.ObjectRoot{AggregateID: "AggregateID", Sequence: 1}, Description: "NameNew"},
},
res: res{

View File

@@ -2,7 +2,8 @@ package eventsourcing
import (
"context"
"github.com/caos/zitadel/internal/api/auth"
"github.com/caos/zitadel/internal/api/authz"
caos_errs "github.com/caos/zitadel/internal/errors"
es_sdk "github.com/caos/zitadel/internal/eventstore/sdk"
pol_model "github.com/caos/zitadel/internal/policy/model"
@@ -25,7 +26,7 @@ func (es *PolicyEventstore) GetPasswordLockoutPolicy(ctx context.Context, id str
}
func (es *PolicyEventstore) CreatePasswordLockoutPolicy(ctx context.Context, policy *pol_model.PasswordLockoutPolicy) (*pol_model.PasswordLockoutPolicy, error) {
ctxData := auth.GetCtxData(ctx)
ctxData := authz.GetCtxData(ctx)
existingPolicy, err := es.GetPasswordLockoutPolicy(ctx, ctxData.OrgID)
if err != nil && !caos_errs.IsNotFound(err) {
return nil, err
@@ -53,7 +54,7 @@ func (es *PolicyEventstore) CreatePasswordLockoutPolicy(ctx context.Context, pol
}
func (es *PolicyEventstore) UpdatePasswordLockoutPolicy(ctx context.Context, policy *pol_model.PasswordLockoutPolicy) (*pol_model.PasswordLockoutPolicy, error) {
ctxData := auth.GetCtxData(ctx)
ctxData := authz.GetCtxData(ctx)
existingPolicy, err := es.GetPasswordLockoutPolicy(ctx, ctxData.OrgID)
if err != nil {
return nil, err

View File

@@ -4,11 +4,12 @@ import (
"context"
"testing"
"github.com/caos/zitadel/internal/api/auth"
"github.com/golang/mock/gomock"
"github.com/caos/zitadel/internal/api/authz"
caos_errs "github.com/caos/zitadel/internal/errors"
es_models "github.com/caos/zitadel/internal/eventstore/models"
"github.com/caos/zitadel/internal/policy/model"
"github.com/golang/mock/gomock"
)
func TestGetPasswordLockoutPolicy(t *testing.T) {
@@ -84,7 +85,7 @@ func TestCreatePasswordLockoutPolicy(t *testing.T) {
name: "create policy, ok",
args: args{
es: GetMockPasswordLockoutPolicyNoEvents(ctrl),
ctx: auth.NewMockContext("orgID", "userID"),
ctx: authz.NewMockContext("orgID", "userID"),
policy: &model.PasswordLockoutPolicy{ObjectRoot: es_models.ObjectRoot{AggregateID: "AggregateID1", Sequence: 2}, Description: "Name"},
},
res: res{
@@ -130,7 +131,7 @@ func TestUpdatePasswordLockoutPolicy(t *testing.T) {
name: "update policy, ok",
args: args{
es: GetMockPasswordLockoutPolicy(ctrl),
ctx: auth.NewMockContext("orgID", "userID"),
ctx: authz.NewMockContext("orgID", "userID"),
new: &model.PasswordLockoutPolicy{ObjectRoot: es_models.ObjectRoot{AggregateID: "AggregateID", Sequence: 1}, Description: "NameNew"},
},
res: res{
@@ -141,7 +142,7 @@ func TestUpdatePasswordLockoutPolicy(t *testing.T) {
name: "existing policy not found",
args: args{
es: GetMockPasswordLockoutPolicyNoEvents(ctrl),
ctx: auth.NewMockContext("orgID", "userID"),
ctx: authz.NewMockContext("orgID", "userID"),
new: &model.PasswordLockoutPolicy{ObjectRoot: es_models.ObjectRoot{AggregateID: "AggregateID", Sequence: 1}, Description: "NameNew"},
},
res: res{

View File

@@ -4,7 +4,7 @@ import (
"context"
"testing"
"github.com/caos/zitadel/internal/api/auth"
"github.com/caos/zitadel/internal/api/authz"
caos_errs "github.com/caos/zitadel/internal/errors"
"github.com/caos/zitadel/internal/eventstore/models"
policy_model "github.com/caos/zitadel/internal/policy/model"
@@ -81,7 +81,7 @@ func TestPasswordAgePolicyAggregate(t *testing.T) {
{
name: "create aggregate",
args: args{
ctx: auth.NewMockContext("orgID", "userID"),
ctx: authz.NewMockContext("orgID", "userID"),
aggCreator: models.NewAggregateCreator("Test"),
policy: &PasswordAgePolicy{ObjectRoot: models.ObjectRoot{AggregateID: "AggregateID", Sequence: 1}, Description: "Test"},
},
@@ -93,7 +93,7 @@ func TestPasswordAgePolicyAggregate(t *testing.T) {
{
name: "policy nil",
args: args{
ctx: auth.NewMockContext("orgID", "userID"),
ctx: authz.NewMockContext("orgID", "userID"),
aggCreator: models.NewAggregateCreator("Test"),
},
res: res{
@@ -142,7 +142,7 @@ func TestPasswordAgePolicyCreateAggregate(t *testing.T) {
{
name: "policy update aggregate ok",
args: args{
ctx: auth.NewMockContext("orgID", "userID"),
ctx: authz.NewMockContext("orgID", "userID"),
new: &PasswordAgePolicy{ObjectRoot: models.ObjectRoot{AggregateID: "AggregateID"}, Description: "PolicyName", State: int32(policy_model.PolicyStateActive)},
aggCreator: models.NewAggregateCreator("Test"),
},
@@ -154,7 +154,7 @@ func TestPasswordAgePolicyCreateAggregate(t *testing.T) {
{
name: "new policy nil",
args: args{
ctx: auth.NewMockContext("orgID", "userID"),
ctx: authz.NewMockContext("orgID", "userID"),
new: nil,
aggCreator: models.NewAggregateCreator("Test"),
},
@@ -207,7 +207,7 @@ func TestPasswordAgePolicyUpdateAggregate(t *testing.T) {
{
name: "policy update aggregate ok",
args: args{
ctx: auth.NewMockContext("orgID", "userID"),
ctx: authz.NewMockContext("orgID", "userID"),
existing: &PasswordAgePolicy{ObjectRoot: models.ObjectRoot{AggregateID: "AggregateID"}, Description: "PolicyName", State: int32(policy_model.PolicyStateActive)},
new: &PasswordAgePolicy{ObjectRoot: models.ObjectRoot{AggregateID: "AggregateID"}, Description: "PolicyName_Changed", State: int32(policy_model.PolicyStateActive)},
aggCreator: models.NewAggregateCreator("Test"),
@@ -220,7 +220,7 @@ func TestPasswordAgePolicyUpdateAggregate(t *testing.T) {
{
name: "existing policy nil",
args: args{
ctx: auth.NewMockContext("orgID", "userID"),
ctx: authz.NewMockContext("orgID", "userID"),
existing: nil,
aggCreator: models.NewAggregateCreator("Test"),
},
@@ -234,7 +234,7 @@ func TestPasswordAgePolicyUpdateAggregate(t *testing.T) {
{
name: "new policy nil",
args: args{
ctx: auth.NewMockContext("orgID", "userID"),
ctx: authz.NewMockContext("orgID", "userID"),
existing: &PasswordAgePolicy{ObjectRoot: models.ObjectRoot{AggregateID: "AggregateID"}, Description: "ProjectName", State: int32(policy_model.PolicyStateActive)},
new: nil,
aggCreator: models.NewAggregateCreator("Test"),

View File

@@ -4,7 +4,7 @@ import (
"context"
"testing"
"github.com/caos/zitadel/internal/api/auth"
"github.com/caos/zitadel/internal/api/authz"
caos_errs "github.com/caos/zitadel/internal/errors"
"github.com/caos/zitadel/internal/eventstore/models"
policy_model "github.com/caos/zitadel/internal/policy/model"
@@ -81,7 +81,7 @@ func TestPasswordComplexityPolicyAggregate(t *testing.T) {
{
name: "create aggregate",
args: args{
ctx: auth.NewMockContext("orgID", "userID"),
ctx: authz.NewMockContext("orgID", "userID"),
aggCreator: models.NewAggregateCreator("Test"),
policy: &PasswordComplexityPolicy{ObjectRoot: models.ObjectRoot{AggregateID: "AggregateID", Sequence: 1}, Description: "Test"},
},
@@ -93,7 +93,7 @@ func TestPasswordComplexityPolicyAggregate(t *testing.T) {
{
name: "policy nil",
args: args{
ctx: auth.NewMockContext("orgID", "userID"),
ctx: authz.NewMockContext("orgID", "userID"),
aggCreator: models.NewAggregateCreator("Test"),
},
res: res{
@@ -142,7 +142,7 @@ func TestPasswordComplexityPolicyCreateAggregate(t *testing.T) {
{
name: "policy update aggregate ok",
args: args{
ctx: auth.NewMockContext("orgID", "userID"),
ctx: authz.NewMockContext("orgID", "userID"),
new: &PasswordComplexityPolicy{ObjectRoot: models.ObjectRoot{AggregateID: "AggregateID"}, Description: "PolicyName", State: int32(policy_model.PolicyStateActive)},
aggCreator: models.NewAggregateCreator("Test"),
},
@@ -154,7 +154,7 @@ func TestPasswordComplexityPolicyCreateAggregate(t *testing.T) {
{
name: "new policy nil",
args: args{
ctx: auth.NewMockContext("orgID", "userID"),
ctx: authz.NewMockContext("orgID", "userID"),
new: nil,
aggCreator: models.NewAggregateCreator("Test"),
},
@@ -207,7 +207,7 @@ func TestPasswordComplexityPolicyUpdateAggregate(t *testing.T) {
{
name: "policy update aggregate ok",
args: args{
ctx: auth.NewMockContext("orgID", "userID"),
ctx: authz.NewMockContext("orgID", "userID"),
existing: &PasswordComplexityPolicy{ObjectRoot: models.ObjectRoot{AggregateID: "AggregateID"}, Description: "PolicyName", State: int32(policy_model.PolicyStateActive)},
new: &PasswordComplexityPolicy{ObjectRoot: models.ObjectRoot{AggregateID: "AggregateID"}, Description: "PolicyName_Changed", State: int32(policy_model.PolicyStateActive)},
aggCreator: models.NewAggregateCreator("Test"),
@@ -220,7 +220,7 @@ func TestPasswordComplexityPolicyUpdateAggregate(t *testing.T) {
{
name: "existing policy nil",
args: args{
ctx: auth.NewMockContext("orgID", "userID"),
ctx: authz.NewMockContext("orgID", "userID"),
existing: nil,
aggCreator: models.NewAggregateCreator("Test"),
},
@@ -234,7 +234,7 @@ func TestPasswordComplexityPolicyUpdateAggregate(t *testing.T) {
{
name: "new policy nil",
args: args{
ctx: auth.NewMockContext("orgID", "userID"),
ctx: authz.NewMockContext("orgID", "userID"),
existing: &PasswordComplexityPolicy{ObjectRoot: models.ObjectRoot{AggregateID: "AggregateID"}, Description: "ProjectName", State: int32(policy_model.PolicyStateActive)},
new: nil,
aggCreator: models.NewAggregateCreator("Test"),

View File

@@ -4,7 +4,7 @@ import (
"context"
"testing"
"github.com/caos/zitadel/internal/api/auth"
"github.com/caos/zitadel/internal/api/authz"
caos_errs "github.com/caos/zitadel/internal/errors"
"github.com/caos/zitadel/internal/eventstore/models"
policy_model "github.com/caos/zitadel/internal/policy/model"
@@ -81,7 +81,7 @@ func TestPasswordLockoutPolicyAggregate(t *testing.T) {
{
name: "create aggregate",
args: args{
ctx: auth.NewMockContext("orgID", "userID"),
ctx: authz.NewMockContext("orgID", "userID"),
aggCreator: models.NewAggregateCreator("Test"),
policy: &PasswordLockoutPolicy{ObjectRoot: models.ObjectRoot{AggregateID: "AggregateID", Sequence: 1}, Description: "Test"},
},
@@ -93,7 +93,7 @@ func TestPasswordLockoutPolicyAggregate(t *testing.T) {
{
name: "policy nil",
args: args{
ctx: auth.NewMockContext("orgID", "userID"),
ctx: authz.NewMockContext("orgID", "userID"),
aggCreator: models.NewAggregateCreator("Test"),
},
res: res{
@@ -142,7 +142,7 @@ func TestPasswordLockoutPolicyCreateAggregate(t *testing.T) {
{
name: "policy update aggregate ok",
args: args{
ctx: auth.NewMockContext("orgID", "userID"),
ctx: authz.NewMockContext("orgID", "userID"),
new: &PasswordLockoutPolicy{ObjectRoot: models.ObjectRoot{AggregateID: "AggregateID"}, Description: "PolicyName", State: int32(policy_model.PolicyStateActive)},
aggCreator: models.NewAggregateCreator("Test"),
},
@@ -154,7 +154,7 @@ func TestPasswordLockoutPolicyCreateAggregate(t *testing.T) {
{
name: "new policy nil",
args: args{
ctx: auth.NewMockContext("orgID", "userID"),
ctx: authz.NewMockContext("orgID", "userID"),
new: nil,
aggCreator: models.NewAggregateCreator("Test"),
},
@@ -207,7 +207,7 @@ func TestPasswordLockoutPolicyUpdateAggregate(t *testing.T) {
{
name: "policy update aggregate ok",
args: args{
ctx: auth.NewMockContext("orgID", "userID"),
ctx: authz.NewMockContext("orgID", "userID"),
existing: &PasswordLockoutPolicy{ObjectRoot: models.ObjectRoot{AggregateID: "AggregateID"}, Description: "PolicyName", State: int32(policy_model.PolicyStateActive)},
new: &PasswordLockoutPolicy{ObjectRoot: models.ObjectRoot{AggregateID: "AggregateID"}, Description: "PolicyName_Changed", State: int32(policy_model.PolicyStateActive)},
aggCreator: models.NewAggregateCreator("Test"),
@@ -220,7 +220,7 @@ func TestPasswordLockoutPolicyUpdateAggregate(t *testing.T) {
{
name: "existing policy nil",
args: args{
ctx: auth.NewMockContext("orgID", "userID"),
ctx: authz.NewMockContext("orgID", "userID"),
existing: nil,
aggCreator: models.NewAggregateCreator("Test"),
},
@@ -234,7 +234,7 @@ func TestPasswordLockoutPolicyUpdateAggregate(t *testing.T) {
{
name: "new policy nil",
args: args{
ctx: auth.NewMockContext("orgID", "userID"),
ctx: authz.NewMockContext("orgID", "userID"),
existing: &PasswordLockoutPolicy{ObjectRoot: models.ObjectRoot{AggregateID: "AggregateID"}, Description: "ProjectName", State: int32(policy_model.PolicyStateActive)},
new: nil,
aggCreator: models.NewAggregateCreator("Test"),