Project commands (#26)

* feat: eventstore repository

* fix: remove gorm

* version

* feat: pkg

* feat: add some files for project

* feat: eventstore without eventstore-lib

* rename files

* gnueg

* fix: key json

* fix: add object

* fix: change imports

* fix: internal models

* fix: some imports

* fix: global model

* fix: add some functions on repo

* feat(eventstore): sdk

* fix(eventstore): search query

* fix(eventstore): rename app to eventstore

* delete empty test

* remove unused func

* merge master

* fix(eventstore): tests

* fix(models): delete unused struct

* fix: some funcitons

* feat(eventstore): implemented push events

* fix: move project eventstore to project package

* fix: change project eventstore funcs

* feat(eventstore): overwrite context data

* fix: change project eventstore

* fix: add project repo to mgmt server

* feat(types): SQL-config

* fix: commented code

* feat(eventstore): options to overwrite editor

* feat: auth interceptor and cockroach migrations

* fix: migrations

* fix: fix filter

* fix: not found on getbyid

* fix: add sequence

* fix: add some tests

* fix(eventstore): nullable sequence

* fix: add some tests

* merge

* fix: add some tests

* fix(migrations): correct statements for sequence

* fix: add some tests

* fix: add some tests

* fix: changes from mr

* Update internal/eventstore/models/field.go

Co-Authored-By: livio-a <[email protected]>

* fix(eventstore): code quality

* fix: add types to aggregate/Event-types

* fix(eventstore): rename modifier* to editor*

* fix(eventstore): delete editor_org

* fix(migrations): remove editor_org field,
rename modifier_* to editor_*

* fix: generate files

* fix(eventstore): tests

* fix(eventstore): rename modifier to editor

* fix(migrations): add cluster migration,
fix(migrations): fix typo of host in clean clsuter

* fix(eventstore): move health

* fix(eventstore): AggregateTypeFilter aggregateType as param

* code quality

* feat: start implementing project members

* feat: remove member funcs

* feat: remove member model

* feat: remove member events

* feat: remove member repo model

* fix: better error func testing

* Update docs/local.md

Co-Authored-By: Silvan <[email protected]>

* Update docs/local.md

Co-Authored-By: Silvan <[email protected]>

* fix: mr requests

* fix: md file

Co-authored-by: adlerhurst <[email protected]>
Co-authored-by: livio-a <[email protected]>
This commit is contained in:
Fabi
2020-04-07 13:23:04 +02:00
committed by GitHub
co-authored by Silvan livio-a
parent 007fc9e9bd
commit c07ed83c41
61 changed files with 5259 additions and 3481 deletions
+4 -4
View File
@@ -1150,11 +1150,11 @@ var fileDescriptor_73a7fc70dcc2027c = []byte{
// Reference imports to suppress errors if they are not otherwise used.
var _ context.Context
var _ grpc.ClientConnInterface
var _ grpc.ClientConn
// This is a compile-time assertion to ensure that this generated file
// is compatible with the grpc package it is being compiled against.
const _ = grpc.SupportPackageIsVersion6
const _ = grpc.SupportPackageIsVersion4
// AdminServiceClient is the client API for AdminService service.
//
@@ -1173,10 +1173,10 @@ type AdminServiceClient interface {
}
type adminServiceClient struct {
cc grpc.ClientConnInterface
cc *grpc.ClientConn
}
func NewAdminServiceClient(cc grpc.ClientConnInterface) AdminServiceClient {
func NewAdminServiceClient(cc *grpc.ClientConn) AdminServiceClient {
return &adminServiceClient{cc}
}
+263 -8
View File
@@ -13,6 +13,7 @@ import (
"io"
"net/http"
"github.com/golang/protobuf/descriptor"
"github.com/golang/protobuf/proto"
"github.com/golang/protobuf/ptypes/empty"
"github.com/grpc-ecosystem/grpc-gateway/runtime"
@@ -23,11 +24,13 @@ import (
"google.golang.org/grpc/status"
)
// Suppress "imported and not used" errors
var _ codes.Code
var _ io.Reader
var _ status.Status
var _ = runtime.String
var _ = utilities.NewDoubleArray
var _ = descriptor.ForMessage
func request_AdminService_Healthz_0(ctx context.Context, marshaler runtime.Marshaler, client AdminServiceClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) {
var protoReq empty.Empty
@@ -38,6 +41,15 @@ func request_AdminService_Healthz_0(ctx context.Context, marshaler runtime.Marsh
}
func local_request_AdminService_Healthz_0(ctx context.Context, marshaler runtime.Marshaler, server AdminServiceServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) {
var protoReq empty.Empty
var metadata runtime.ServerMetadata
msg, err := server.Healthz(ctx, &protoReq)
return msg, metadata, err
}
func request_AdminService_Ready_0(ctx context.Context, marshaler runtime.Marshaler, client AdminServiceClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) {
var protoReq empty.Empty
var metadata runtime.ServerMetadata
@@ -47,6 +59,15 @@ func request_AdminService_Ready_0(ctx context.Context, marshaler runtime.Marshal
}
func local_request_AdminService_Ready_0(ctx context.Context, marshaler runtime.Marshaler, server AdminServiceServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) {
var protoReq empty.Empty
var metadata runtime.ServerMetadata
msg, err := server.Ready(ctx, &protoReq)
return msg, metadata, err
}
func request_AdminService_Validate_0(ctx context.Context, marshaler runtime.Marshaler, client AdminServiceClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) {
var protoReq empty.Empty
var metadata runtime.ServerMetadata
@@ -56,6 +77,15 @@ func request_AdminService_Validate_0(ctx context.Context, marshaler runtime.Mars
}
func local_request_AdminService_Validate_0(ctx context.Context, marshaler runtime.Marshaler, server AdminServiceServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) {
var protoReq empty.Empty
var metadata runtime.ServerMetadata
msg, err := server.Validate(ctx, &protoReq)
return msg, metadata, err
}
var (
filter_AdminService_IsOrgUnique_0 = &utilities.DoubleArray{Encoding: map[string]int{}, Base: []int(nil), Check: []int(nil)}
)
@@ -64,7 +94,10 @@ func request_AdminService_IsOrgUnique_0(ctx context.Context, marshaler runtime.M
var protoReq UniqueOrgRequest
var metadata runtime.ServerMetadata
if err := runtime.PopulateQueryParameters(&protoReq, req.URL.Query(), filter_AdminService_IsOrgUnique_0); err != nil {
if err := req.ParseForm(); err != nil {
return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err)
}
if err := runtime.PopulateQueryParameters(&protoReq, req.Form, filter_AdminService_IsOrgUnique_0); err != nil {
return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err)
}
@@ -73,6 +106,19 @@ func request_AdminService_IsOrgUnique_0(ctx context.Context, marshaler runtime.M
}
func local_request_AdminService_IsOrgUnique_0(ctx context.Context, marshaler runtime.Marshaler, server AdminServiceServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) {
var protoReq UniqueOrgRequest
var metadata runtime.ServerMetadata
if err := runtime.PopulateQueryParameters(&protoReq, req.URL.Query(), filter_AdminService_IsOrgUnique_0); err != nil {
return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err)
}
msg, err := server.IsOrgUnique(ctx, &protoReq)
return msg, metadata, err
}
func request_AdminService_GetOrgByID_0(ctx context.Context, marshaler runtime.Marshaler, client AdminServiceClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) {
var protoReq OrgID
var metadata runtime.ServerMetadata
@@ -100,6 +146,33 @@ func request_AdminService_GetOrgByID_0(ctx context.Context, marshaler runtime.Ma
}
func local_request_AdminService_GetOrgByID_0(ctx context.Context, marshaler runtime.Marshaler, server AdminServiceServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) {
var protoReq OrgID
var metadata runtime.ServerMetadata
var (
val string
ok bool
err error
_ = err
)
val, ok = pathParams["id"]
if !ok {
return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "id")
}
protoReq.Id, err = runtime.String(val)
if err != nil {
return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "id", err)
}
msg, err := server.GetOrgByID(ctx, &protoReq)
return msg, metadata, err
}
func request_AdminService_SearchOrgs_0(ctx context.Context, marshaler runtime.Marshaler, client AdminServiceClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) {
var protoReq OrgSearchRequest
var metadata runtime.ServerMetadata
@@ -117,6 +190,23 @@ func request_AdminService_SearchOrgs_0(ctx context.Context, marshaler runtime.Ma
}
func local_request_AdminService_SearchOrgs_0(ctx context.Context, marshaler runtime.Marshaler, server AdminServiceServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) {
var protoReq OrgSearchRequest
var metadata runtime.ServerMetadata
newReader, berr := utilities.IOReaderFactory(req.Body)
if berr != nil {
return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", berr)
}
if err := marshaler.NewDecoder(newReader()).Decode(&protoReq); err != nil && err != io.EOF {
return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err)
}
msg, err := server.SearchOrgs(ctx, &protoReq)
return msg, metadata, err
}
func request_AdminService_SetUpOrg_0(ctx context.Context, marshaler runtime.Marshaler, client AdminServiceClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) {
var protoReq OrgSetUpRequest
var metadata runtime.ServerMetadata
@@ -134,6 +224,171 @@ func request_AdminService_SetUpOrg_0(ctx context.Context, marshaler runtime.Mars
}
func local_request_AdminService_SetUpOrg_0(ctx context.Context, marshaler runtime.Marshaler, server AdminServiceServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) {
var protoReq OrgSetUpRequest
var metadata runtime.ServerMetadata
newReader, berr := utilities.IOReaderFactory(req.Body)
if berr != nil {
return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", berr)
}
if err := marshaler.NewDecoder(newReader()).Decode(&protoReq); err != nil && err != io.EOF {
return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err)
}
msg, err := server.SetUpOrg(ctx, &protoReq)
return msg, metadata, err
}
// RegisterAdminServiceHandlerServer registers the http handlers for service AdminService to "mux".
// UnaryRPC :call AdminServiceServer directly.
// StreamingRPC :currently unsupported pending https://github.com/grpc/grpc-go/issues/906.
func RegisterAdminServiceHandlerServer(ctx context.Context, mux *runtime.ServeMux, server AdminServiceServer) error {
mux.Handle("GET", pattern_AdminService_Healthz_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) {
ctx, cancel := context.WithCancel(req.Context())
defer cancel()
inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req)
rctx, err := runtime.AnnotateIncomingContext(ctx, mux, req)
if err != nil {
runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err)
return
}
resp, md, err := local_request_AdminService_Healthz_0(rctx, inboundMarshaler, server, req, pathParams)
ctx = runtime.NewServerMetadataContext(ctx, md)
if err != nil {
runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err)
return
}
forward_AdminService_Healthz_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...)
})
mux.Handle("GET", pattern_AdminService_Ready_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) {
ctx, cancel := context.WithCancel(req.Context())
defer cancel()
inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req)
rctx, err := runtime.AnnotateIncomingContext(ctx, mux, req)
if err != nil {
runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err)
return
}
resp, md, err := local_request_AdminService_Ready_0(rctx, inboundMarshaler, server, req, pathParams)
ctx = runtime.NewServerMetadataContext(ctx, md)
if err != nil {
runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err)
return
}
forward_AdminService_Ready_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...)
})
mux.Handle("GET", pattern_AdminService_Validate_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) {
ctx, cancel := context.WithCancel(req.Context())
defer cancel()
inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req)
rctx, err := runtime.AnnotateIncomingContext(ctx, mux, req)
if err != nil {
runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err)
return
}
resp, md, err := local_request_AdminService_Validate_0(rctx, inboundMarshaler, server, req, pathParams)
ctx = runtime.NewServerMetadataContext(ctx, md)
if err != nil {
runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err)
return
}
forward_AdminService_Validate_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...)
})
mux.Handle("GET", pattern_AdminService_IsOrgUnique_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) {
ctx, cancel := context.WithCancel(req.Context())
defer cancel()
inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req)
rctx, err := runtime.AnnotateIncomingContext(ctx, mux, req)
if err != nil {
runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err)
return
}
resp, md, err := local_request_AdminService_IsOrgUnique_0(rctx, inboundMarshaler, server, req, pathParams)
ctx = runtime.NewServerMetadataContext(ctx, md)
if err != nil {
runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err)
return
}
forward_AdminService_IsOrgUnique_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...)
})
mux.Handle("GET", pattern_AdminService_GetOrgByID_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) {
ctx, cancel := context.WithCancel(req.Context())
defer cancel()
inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req)
rctx, err := runtime.AnnotateIncomingContext(ctx, mux, req)
if err != nil {
runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err)
return
}
resp, md, err := local_request_AdminService_GetOrgByID_0(rctx, inboundMarshaler, server, req, pathParams)
ctx = runtime.NewServerMetadataContext(ctx, md)
if err != nil {
runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err)
return
}
forward_AdminService_GetOrgByID_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...)
})
mux.Handle("POST", pattern_AdminService_SearchOrgs_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) {
ctx, cancel := context.WithCancel(req.Context())
defer cancel()
inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req)
rctx, err := runtime.AnnotateIncomingContext(ctx, mux, req)
if err != nil {
runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err)
return
}
resp, md, err := local_request_AdminService_SearchOrgs_0(rctx, inboundMarshaler, server, req, pathParams)
ctx = runtime.NewServerMetadataContext(ctx, md)
if err != nil {
runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err)
return
}
forward_AdminService_SearchOrgs_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...)
})
mux.Handle("POST", pattern_AdminService_SetUpOrg_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) {
ctx, cancel := context.WithCancel(req.Context())
defer cancel()
inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req)
rctx, err := runtime.AnnotateIncomingContext(ctx, mux, req)
if err != nil {
runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err)
return
}
resp, md, err := local_request_AdminService_SetUpOrg_0(rctx, inboundMarshaler, server, req, pathParams)
ctx = runtime.NewServerMetadataContext(ctx, md)
if err != nil {
runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err)
return
}
forward_AdminService_SetUpOrg_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...)
})
return nil
}
// RegisterAdminServiceHandlerFromEndpoint is same as RegisterAdminServiceHandler but
// automatically dials to "endpoint" and closes the connection when "ctx" gets done.
func RegisterAdminServiceHandlerFromEndpoint(ctx context.Context, mux *runtime.ServeMux, endpoint string, opts []grpc.DialOption) (err error) {
@@ -316,19 +571,19 @@ func RegisterAdminServiceHandlerClient(ctx context.Context, mux *runtime.ServeMu
}
var (
pattern_AdminService_Healthz_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0}, []string{"healthz"}, ""))
pattern_AdminService_Healthz_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0}, []string{"healthz"}, "", runtime.AssumeColonVerbOpt(true)))
pattern_AdminService_Ready_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0}, []string{"ready"}, ""))
pattern_AdminService_Ready_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0}, []string{"ready"}, "", runtime.AssumeColonVerbOpt(true)))
pattern_AdminService_Validate_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0}, []string{"validate"}, ""))
pattern_AdminService_Validate_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0}, []string{"validate"}, "", runtime.AssumeColonVerbOpt(true)))
pattern_AdminService_IsOrgUnique_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1}, []string{"orgs", "_isunique"}, ""))
pattern_AdminService_IsOrgUnique_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1}, []string{"orgs", "_isunique"}, "", runtime.AssumeColonVerbOpt(true)))
pattern_AdminService_GetOrgByID_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 1, 0, 4, 1, 5, 1}, []string{"orgs", "id"}, ""))
pattern_AdminService_GetOrgByID_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 1, 0, 4, 1, 5, 1}, []string{"orgs", "id"}, "", runtime.AssumeColonVerbOpt(true)))
pattern_AdminService_SearchOrgs_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1}, []string{"orgs", "_search"}, ""))
pattern_AdminService_SearchOrgs_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1}, []string{"orgs", "_search"}, "", runtime.AssumeColonVerbOpt(true)))
pattern_AdminService_SetUpOrg_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1}, []string{"orgs", "_setup"}, ""))
pattern_AdminService_SetUpOrg_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1}, []string{"orgs", "_setup"}, "", runtime.AssumeColonVerbOpt(true)))
)
var (
+1 -59
View File
@@ -167,7 +167,7 @@
"200": {
"description": "A successful response.",
"schema": {
"$ref": "#/definitions/protobufStruct"
"type": "object"
}
}
},
@@ -178,19 +178,6 @@
}
},
"definitions": {
"protobufListValue": {
"type": "object",
"properties": {
"values": {
"type": "array",
"items": {
"$ref": "#/definitions/protobufValue"
},
"description": "Repeated field of dynamically typed values."
}
},
"description": "`ListValue` is a wrapper around a repeated field of values.\n\nThe JSON representation for `ListValue` is JSON array."
},
"protobufNullValue": {
"type": "string",
"enum": [
@@ -199,51 +186,6 @@
"default": "NULL_VALUE",
"description": "`NullValue` is a singleton enumeration to represent the null value for the\n`Value` type union.\n\n The JSON representation for `NullValue` is JSON `null`.\n\n - NULL_VALUE: Null value."
},
"protobufStruct": {
"type": "object",
"properties": {
"fields": {
"type": "object",
"additionalProperties": {
"$ref": "#/definitions/protobufValue"
},
"description": "Unordered map of dynamically typed values."
}
},
"description": "`Struct` represents a structured data value, consisting of fields\nwhich map to dynamically typed values. In some languages, `Struct`\nmight be supported by a native representation. For example, in\nscripting languages like JS a struct is represented as an\nobject. The details of that representation are described together\nwith the proto support for the language.\n\nThe JSON representation for `Struct` is JSON object."
},
"protobufValue": {
"type": "object",
"properties": {
"null_value": {
"$ref": "#/definitions/protobufNullValue",
"description": "Represents a null value."
},
"number_value": {
"type": "number",
"format": "double",
"description": "Represents a double value."
},
"string_value": {
"type": "string",
"description": "Represents a string value."
},
"bool_value": {
"type": "boolean",
"format": "boolean",
"description": "Represents a boolean value."
},
"struct_value": {
"$ref": "#/definitions/protobufStruct",
"description": "Represents a structured value."
},
"list_value": {
"$ref": "#/definitions/protobufListValue",
"description": "Represents a repeated `Value`."
}
},
"description": "`Value` represents a dynamically typed value which can be either\nnull, a number, a string, a boolean, a recursive struct value, or a\nlist of values. A producer of value is expected to set one of that\nvariants, absence of any variant indicates an error.\n\nThe JSON representation for `Value` is JSON value."
},
"v1CreateOrgRequest": {
"type": "object",
"properties": {
+8 -8
View File
@@ -8,9 +8,9 @@ import (
context "context"
grpc "github.com/caos/zitadel/pkg/admin/api/grpc"
gomock "github.com/golang/mock/gomock"
empty "github.com/golang/protobuf/ptypes/empty"
struct0 "github.com/golang/protobuf/ptypes/struct"
grpc0 "google.golang.org/grpc"
emptypb "google.golang.org/protobuf/types/known/emptypb"
structpb "google.golang.org/protobuf/types/known/structpb"
reflect "reflect"
)
@@ -58,14 +58,14 @@ func (mr *MockAdminServiceClientMockRecorder) GetOrgByID(arg0, arg1 interface{},
}
// Healthz mocks base method
func (m *MockAdminServiceClient) Healthz(arg0 context.Context, arg1 *empty.Empty, arg2 ...grpc0.CallOption) (*empty.Empty, error) {
func (m *MockAdminServiceClient) Healthz(arg0 context.Context, arg1 *emptypb.Empty, arg2 ...grpc0.CallOption) (*emptypb.Empty, error) {
m.ctrl.T.Helper()
varargs := []interface{}{arg0, arg1}
for _, a := range arg2 {
varargs = append(varargs, a)
}
ret := m.ctrl.Call(m, "Healthz", varargs...)
ret0, _ := ret[0].(*empty.Empty)
ret0, _ := ret[0].(*emptypb.Empty)
ret1, _ := ret[1].(error)
return ret0, ret1
}
@@ -98,14 +98,14 @@ func (mr *MockAdminServiceClientMockRecorder) IsOrgUnique(arg0, arg1 interface{}
}
// Ready mocks base method
func (m *MockAdminServiceClient) Ready(arg0 context.Context, arg1 *empty.Empty, arg2 ...grpc0.CallOption) (*empty.Empty, error) {
func (m *MockAdminServiceClient) Ready(arg0 context.Context, arg1 *emptypb.Empty, arg2 ...grpc0.CallOption) (*emptypb.Empty, error) {
m.ctrl.T.Helper()
varargs := []interface{}{arg0, arg1}
for _, a := range arg2 {
varargs = append(varargs, a)
}
ret := m.ctrl.Call(m, "Ready", varargs...)
ret0, _ := ret[0].(*empty.Empty)
ret0, _ := ret[0].(*emptypb.Empty)
ret1, _ := ret[1].(error)
return ret0, ret1
}
@@ -158,14 +158,14 @@ func (mr *MockAdminServiceClientMockRecorder) SetUpOrg(arg0, arg1 interface{}, a
}
// Validate mocks base method
func (m *MockAdminServiceClient) Validate(arg0 context.Context, arg1 *empty.Empty, arg2 ...grpc0.CallOption) (*struct0.Struct, error) {
func (m *MockAdminServiceClient) Validate(arg0 context.Context, arg1 *emptypb.Empty, arg2 ...grpc0.CallOption) (*structpb.Struct, error) {
m.ctrl.T.Helper()
varargs := []interface{}{arg0, arg1}
for _, a := range arg2 {
varargs = append(varargs, a)
}
ret := m.ctrl.Call(m, "Validate", varargs...)
ret0, _ := ret[0].(*struct0.Struct)
ret0, _ := ret[0].(*structpb.Struct)
ret1, _ := ret[1].(error)
return ret0, ret1
}
+1456 -2691
View File
File diff suppressed because it is too large Load Diff
File diff suppressed because it is too large Load Diff
+21 -59
View File
@@ -535,7 +535,7 @@
"200": {
"description": "A successful response.",
"schema": {
"$ref": "#/definitions/protobufStruct"
"type": "object"
}
}
},
@@ -546,19 +546,6 @@
}
},
"definitions": {
"protobufListValue": {
"type": "object",
"properties": {
"values": {
"type": "array",
"items": {
"$ref": "#/definitions/protobufValue"
},
"description": "Repeated field of dynamically typed values."
}
},
"description": "`ListValue` is a wrapper around a repeated field of values.\n\nThe JSON representation for `ListValue` is JSON array."
},
"protobufNullValue": {
"type": "string",
"enum": [
@@ -567,51 +554,6 @@
"default": "NULL_VALUE",
"description": "`NullValue` is a singleton enumeration to represent the null value for the\n`Value` type union.\n\n The JSON representation for `NullValue` is JSON `null`.\n\n - NULL_VALUE: Null value."
},
"protobufStruct": {
"type": "object",
"properties": {
"fields": {
"type": "object",
"additionalProperties": {
"$ref": "#/definitions/protobufValue"
},
"description": "Unordered map of dynamically typed values."
}
},
"description": "`Struct` represents a structured data value, consisting of fields\nwhich map to dynamically typed values. In some languages, `Struct`\nmight be supported by a native representation. For example, in\nscripting languages like JS a struct is represented as an\nobject. The details of that representation are described together\nwith the proto support for the language.\n\nThe JSON representation for `Struct` is JSON object."
},
"protobufValue": {
"type": "object",
"properties": {
"null_value": {
"$ref": "#/definitions/protobufNullValue",
"description": "Represents a null value."
},
"number_value": {
"type": "number",
"format": "double",
"description": "Represents a double value."
},
"string_value": {
"type": "string",
"description": "Represents a string value."
},
"bool_value": {
"type": "boolean",
"format": "boolean",
"description": "Represents a boolean value."
},
"struct_value": {
"$ref": "#/definitions/protobufStruct",
"description": "Represents a structured value."
},
"list_value": {
"$ref": "#/definitions/protobufListValue",
"description": "Represents a repeated `Value`."
}
},
"description": "`Value` represents a dynamically typed value which can be either\nnull, a number, a string, a boolean, a recursive struct value, or a\nlist of values. A producer of value is expected to set one of that\nvariants, absence of any variant indicates an error.\n\nThe JSON representation for `Value` is JSON value."
},
"v1Gender": {
"type": "string",
"enum": [
@@ -886,6 +828,10 @@
},
"street_address": {
"type": "string"
},
"sequence": {
"type": "string",
"format": "uint64"
}
}
},
@@ -901,6 +847,10 @@
"isEmailVerified": {
"type": "boolean",
"format": "boolean"
},
"sequence": {
"type": "string",
"format": "uint64"
}
}
},
@@ -916,6 +866,10 @@
"is_phone_verified": {
"type": "boolean",
"format": "boolean"
},
"sequence": {
"type": "string",
"format": "uint64"
}
}
},
@@ -945,6 +899,10 @@
},
"gender": {
"$ref": "#/definitions/v1Gender"
},
"sequence": {
"type": "string",
"format": "uint64"
}
}
},
@@ -974,6 +932,10 @@
},
"user_name": {
"type": "string"
},
"sequence": {
"type": "string",
"format": "uint64"
}
}
},
-8
View File
@@ -46,10 +46,6 @@ func (s *Server) ResendMyEmailVerificationMail(ctx context.Context, _ *empty.Emp
return nil, errors.ThrowUnimplemented(nil, "GRPC-dh69i", "Not implemented")
}
func (s *Server) ResendEmailVerificationMail(ctx context.Context, id *UserID) (*empty.Empty, error) {
return nil, errors.ThrowUnimplemented(nil, "GRPC-mAq23", "Not implemented")
}
func (s *Server) ChangeMyUserPhone(ctx context.Context, request *UpdateUserPhoneRequest) (*UserPhone, error) {
return nil, errors.ThrowUnimplemented(nil, "GRPC-dk45g", "Not implemented")
}
@@ -85,7 +81,3 @@ func (s *Server) VerifyMfaOTP(ctx context.Context, request *VerifyMfaOtp) (_ *Mf
func (s *Server) RemoveMfaOTP(ctx context.Context, _ *empty.Empty) (_ *empty.Empty, err error) {
return nil, errors.ThrowUnimplemented(nil, "GRPC-9k46d", "Not implemented")
}
func (s *Server) ResendUserInitMail(ctx context.Context, request *UserID) (_ *empty.Empty, err error) {
return nil, errors.ThrowUnimplemented(nil, "GRPC-dk467", "Not implemented")
}
+6
View File
@@ -297,6 +297,7 @@ message UserSessionView {
UserSessionState auth_state = 3;
string user_id = 4;
string user_name = 5;
uint64 sequence = 6;
}
enum UserSessionState {
@@ -336,6 +337,7 @@ message User {
string region = 22;
string street_address = 23;
bool password_change_required = 24;
uint64 sequence = 25;
}
enum UserState {
@@ -364,6 +366,7 @@ message UserProfile {
string display_name = 6;
string preferred_language = 7;
Gender gender = 8;
uint64 sequence = 26;
}
message UpdateUserProfileRequest {
@@ -379,6 +382,7 @@ message UserEmail {
string id = 1;
string email = 2;
bool isEmailVerified = 3;
uint64 sequence = 4;
}
message VerifyMyUserEmailRequest {
@@ -398,6 +402,7 @@ message UserPhone {
string id = 1;
string phone = 2;
bool is_phone_verified = 3;
uint64 sequence = 4;
}
message UpdateUserPhoneRequest {
@@ -415,6 +420,7 @@ message UserAddress {
string postal_code = 4;
string region = 5;
string street_address = 6;
uint64 sequence = 7;
}
message UpdateUserAddressRequest {
+4 -2
View File
@@ -2,6 +2,8 @@ package api
import (
"context"
"github.com/caos/zitadel/internal/api/auth"
"github.com/caos/zitadel/internal/management/repository"
grpc_util "github.com/caos/zitadel/internal/api/grpc"
"github.com/caos/zitadel/internal/api/grpc/server"
@@ -12,8 +14,8 @@ type Config struct {
GRPC grpc_util.Config
}
func Start(ctx context.Context, conf Config) {
grpcServer := grpc.StartServer(conf.GRPC.ToServerConfig())
func Start(ctx context.Context, conf Config, authZ auth.Config, repo repository.Repository) {
grpcServer := grpc.StartServer(conf.GRPC.ToServerConfig(), authZ, repo)
grpcGateway := grpc.StartGateway(conf.GRPC.ToGatewayConfig())
server.StartServer(ctx, grpcServer)
File diff suppressed because it is too large Load Diff
@@ -3280,6 +3280,10 @@
},
"oidc_config": {
"$ref": "#/definitions/v1OIDCConfig"
},
"sequence": {
"type": "string",
"format": "uint64"
}
}
},
@@ -3832,6 +3836,10 @@
},
"domain": {
"type": "string"
},
"sequence": {
"type": "string",
"format": "uint64"
}
}
},
@@ -3874,6 +3882,10 @@
"creation_date": {
"type": "string",
"format": "date-time"
},
"sequence": {
"type": "string",
"format": "uint64"
}
}
},
@@ -3994,6 +4006,10 @@
"expire_warn_days": {
"type": "string",
"format": "uint64"
},
"sequence": {
"type": "string",
"format": "uint64"
}
}
},
@@ -4071,6 +4087,10 @@
"has_symbol": {
"type": "boolean",
"format": "boolean"
},
"sequence": {
"type": "string",
"format": "uint64"
}
}
},
@@ -4160,6 +4180,10 @@
"show_lock_out_failures": {
"type": "boolean",
"format": "boolean"
},
"sequence": {
"type": "string",
"format": "uint64"
}
}
},
@@ -4256,6 +4280,10 @@
},
"grant_id": {
"type": "string"
},
"sequence": {
"type": "string",
"format": "uint64"
}
}
},
@@ -4304,6 +4332,10 @@
},
"project_name": {
"type": "string"
},
"sequence": {
"type": "string",
"format": "uint64"
}
}
},
@@ -4366,6 +4398,10 @@
"creation_date": {
"type": "string",
"format": "date-time"
},
"sequence": {
"type": "string",
"format": "uint64"
}
}
},
@@ -4676,6 +4712,10 @@
"creation_date": {
"type": "string",
"format": "date-time"
},
"sequence": {
"type": "string",
"format": "uint64"
}
}
},
@@ -4812,6 +4852,10 @@
},
"group": {
"type": "string"
},
"sequence": {
"type": "string",
"format": "uint64"
}
}
},
@@ -4969,7 +5013,7 @@
"enum": [
"PROJECTSTATE_UNSPECIFIED",
"PROJECTSTATE_ACTIVE",
"PROJECTSSTATE_INACTIVE"
"PROJECTSTATE_INACTIVE"
],
"default": "PROJECTSTATE_UNSPECIFIED"
},
@@ -5231,6 +5275,10 @@
},
"street_address": {
"type": "string"
},
"sequence": {
"type": "string",
"format": "uint64"
}
}
},
@@ -5254,6 +5302,10 @@
},
"street_address": {
"type": "string"
},
"sequence": {
"type": "string",
"format": "uint64"
}
}
},
@@ -5269,6 +5321,10 @@
"is_email_verified": {
"type": "boolean",
"format": "boolean"
},
"sequence": {
"type": "string",
"format": "uint64"
}
}
},
@@ -5324,6 +5380,10 @@
},
"project_name": {
"type": "string"
},
"sequence": {
"type": "string",
"format": "uint64"
}
}
},
@@ -5470,6 +5530,10 @@
"is_phone_verified": {
"type": "boolean",
"format": "boolean"
},
"sequence": {
"type": "string",
"format": "uint64"
}
}
},
@@ -5502,6 +5566,10 @@
},
"user_name": {
"type": "string"
},
"sequence": {
"type": "string",
"format": "uint64"
}
}
},
+25 -5
View File
@@ -7,16 +7,32 @@ import (
)
func (s *Server) CreateProject(ctx context.Context, in *ProjectCreateRequest) (*Project, error) {
return nil, errors.ThrowUnimplemented(nil, "GRPC-mo34X", "Not implemented")
project, err := s.project.CreateProject(ctx, in.Name)
if err != nil {
return nil, err
}
return projectFromModel(project), nil
}
func (s *Server) UpdateProject(ctx context.Context, in *ProjectUpdateRequest) (*Project, error) {
return nil, errors.ThrowUnimplemented(nil, "GRPC-0o4fB", "Not implemented")
project, err := s.project.UpdateProject(ctx, projectUpdateToModel(in))
if err != nil {
return nil, err
}
return projectFromModel(project), nil
}
func (s *Server) DeactivateProject(ctx context.Context, in *ProjectID) (*Project, error) {
return nil, errors.ThrowUnimplemented(nil, "GRPC-4Sck8", "Not implemented")
project, err := s.project.DeactivateProject(ctx, in.Id)
if err != nil {
return nil, err
}
return projectFromModel(project), nil
}
func (s *Server) ReactivateProject(ctx context.Context, in *ProjectID) (*Project, error) {
return nil, errors.ThrowUnimplemented(nil, "GRPC-0oVre", "Not implemented")
project, err := s.project.ReactivateProject(ctx, in.Id)
if err != nil {
return nil, err
}
return projectFromModel(project), nil
}
func (s *Server) SearchProjects(ctx context.Context, in *ProjectSearchRequest) (*ProjectSearchResponse, error) {
@@ -24,7 +40,11 @@ func (s *Server) SearchProjects(ctx context.Context, in *ProjectSearchRequest) (
}
func (s *Server) ProjectByID(ctx context.Context, id *ProjectID) (*Project, error) {
return nil, errors.ThrowUnimplemented(nil, "GRPC-plV5x", "Not implemented")
project, err := s.project.ProjectByID(ctx, id.Id)
if err != nil {
return nil, err
}
return projectFromModel(project), nil
}
func (s *Server) GetGrantedProjectGrantByID(ctx context.Context, request *GrantedGrantID) (*ProjectGrant, error) {
@@ -0,0 +1,45 @@
package grpc
import (
"github.com/caos/logging"
"github.com/caos/zitadel/internal/eventstore/models"
proj_model "github.com/caos/zitadel/internal/project/model"
"github.com/golang/protobuf/ptypes"
)
func projectFromModel(project *proj_model.Project) *Project {
creationDate, err := ptypes.TimestampProto(project.CreationDate)
logging.Log("GRPC-iejs3").OnError(err).Debug("unable to parse timestamp")
changeDate, err := ptypes.TimestampProto(project.ChangeDate)
logging.Log("GRPC-di7rw").OnError(err).Debug("unable to parse timestamp")
return &Project{
Id: project.ID,
State: projectStateFromModel(project.State),
CreationDate: creationDate,
ChangeDate: changeDate,
Name: project.Name,
Sequence: project.Sequence,
}
}
func projectStateFromModel(state proj_model.ProjectState) ProjectState {
switch state {
case proj_model.Active:
return ProjectState_PROJECTSTATE_ACTIVE
case proj_model.Inactive:
return ProjectState_PROJECTSTATE_INACTIVE
default:
return ProjectState_PROJECTSTATE_UNSPECIFIED
}
}
func projectUpdateToModel(project *ProjectUpdateRequest) *proj_model.Project {
return &proj_model.Project{
ObjectRoot: models.ObjectRoot{
ID: project.Id,
},
Name: project.Name,
}
}
+13 -3
View File
@@ -1,8 +1,11 @@
package grpc
import (
"github.com/caos/zitadel/internal/api/auth"
grpc_util "github.com/caos/zitadel/internal/api/grpc"
"github.com/caos/zitadel/internal/api/grpc/server/middleware"
mgmt_auth "github.com/caos/zitadel/internal/management/auth"
"github.com/caos/zitadel/internal/management/repository"
grpc_middleware "github.com/grpc-ecosystem/go-grpc-middleware"
"google.golang.org/grpc"
)
@@ -10,12 +13,18 @@ import (
var _ ManagementServiceServer = (*Server)(nil)
type Server struct {
port string
port string
project repository.ProjectRepository
verifier *mgmt_auth.TokenVerifier
authZ auth.Config
}
func StartServer(conf grpc_util.ServerConfig) *Server {
func StartServer(conf grpc_util.ServerConfig, authZ auth.Config, repo repository.Repository) *Server {
return &Server{
port: conf.Port,
port: conf.Port,
project: repo,
authZ: authZ,
verifier: mgmt_auth.Start(),
}
}
@@ -29,6 +38,7 @@ func (s *Server) GRPCServer() (*grpc.Server, error) {
grpc.UnaryInterceptor(
grpc_middleware.ChainUnaryServer(
middleware.ErrorHandler(),
ManagementService_Authorization_Interceptor(s.verifier, &s.authZ),
),
),
)
+18 -1
View File
@@ -1269,6 +1269,7 @@ message User {
string postal_code = 20;
string region = 21;
string street_address = 22;
uint64 sequence = 23;
}
enum UserState {
@@ -1337,6 +1338,7 @@ message UserProfile {
string preferred_language = 7;
Gender gender = 8;
string user_name = 9;
uint64 sequence = 10;
}
message UpdateUserProfileRequest {
@@ -1353,6 +1355,7 @@ message UserEmail {
string id = 1;
string email = 2;
bool is_email_verified = 3;
uint64 sequence = 4;
}
message UpdateUserEmailRequest {
@@ -1365,6 +1368,7 @@ message UserPhone {
string id = 1;
string phone = 2;
bool is_phone_verified = 3;
uint64 sequence = 5;
}
message UpdateUserPhoneRequest {
@@ -1380,6 +1384,7 @@ message UserAddress {
string postal_code = 4;
string region = 5;
string street_address = 6;
uint64 sequence = 7;
}
message UpdateUserAddressRequest {
@@ -1451,6 +1456,7 @@ message PasswordComplexityPolicy {
bool has_uppercase = 8;
bool has_number = 9;
bool has_symbol = 10;
uint64 sequence = 11;
}
message PasswordComplexityPolicyCreate {
@@ -1484,6 +1490,7 @@ message PasswordAgePolicy {
google.protobuf.Timestamp change_date = 5;
uint64 max_age_days = 6;
uint64 expire_warn_days = 7;
uint64 sequence = 8;
}
message PasswordAgePolicyCreate {
@@ -1511,6 +1518,7 @@ message PasswordLockoutPolicy {
google.protobuf.Timestamp change_date = 5;
uint64 max_attempts = 6;
bool show_lock_out_failures = 7;
uint64 sequence = 8;
}
message PasswordLockoutPolicyCreate {
@@ -1548,6 +1556,7 @@ message Org {
google.protobuf.Timestamp change_date = 4;
string name = 5;
string domain = 6;
uint64 sequence = 7;
}
enum OrgState {
@@ -1569,6 +1578,7 @@ message OrgMember {
repeated string roles = 6;
google.protobuf.Timestamp change_date = 7;
google.protobuf.Timestamp creation_date = 8;
uint64 sequence = 9;
}
message AddOrgMemberRequest {
@@ -1641,12 +1651,13 @@ message Project {
string org_name = 9;
string org_domain = 10;
string grant_id = 11;
uint64 sequence = 12;
}
enum ProjectState {
PROJECTSTATE_UNSPECIFIED = 0;
PROJECTSTATE_ACTIVE = 1;
PROJECTSSTATE_INACTIVE = 2;
PROJECTSTATE_INACTIVE = 2;
}
enum ProjectType {
@@ -1692,6 +1703,7 @@ message ProjectMember {
repeated string roles = 6;
google.protobuf.Timestamp change_date = 7;
google.protobuf.Timestamp creation_date = 8;
uint64 sequence = 10;
}
message ProjectMemberAdd {
@@ -1724,6 +1736,7 @@ message ProjectRole {
string display_name = 3;
google.protobuf.Timestamp creation_date = 4;
string group = 5;
uint64 sequence = 6;
}
message ProjectRoleRemove {
@@ -1800,6 +1813,7 @@ message Application {
oneof app_config {
OIDCConfig oidc_config = 8;
}
uint64 sequence = 9;
}
message ApplicationUpdate {
@@ -1906,6 +1920,7 @@ message ProjectGrant {
google.protobuf.Timestamp creation_date = 8;
google.protobuf.Timestamp change_date = 9;
string project_name = 10;
uint64 sequence = 11;
}
message ProjectGrantCreate {
@@ -1961,6 +1976,7 @@ message ProjectGrantMember {
repeated string roles = 6;
google.protobuf.Timestamp change_date = 7;
google.protobuf.Timestamp creation_date = 8;
uint64 sequence = 9;
}
message ProjectGrantMemberAdd {
@@ -2028,6 +2044,7 @@ message UserGrant {
string org_name = 13;
string org_domain = 14;
string project_name = 15;
uint64 sequence = 16;
}
message UserGrantCreate {
+8 -4
View File
@@ -2,16 +2,20 @@ package management
import (
"context"
"github.com/caos/logging"
"github.com/caos/zitadel/internal/api/auth"
app "github.com/caos/zitadel/internal/management"
"github.com/caos/zitadel/internal/management/repository/eventsourcing"
"github.com/caos/zitadel/pkg/management/api"
)
type Config struct {
App app.Config
API api.Config
Repository eventsourcing.Config
API api.Config
}
func Start(ctx context.Context, config Config, authZ auth.Config) {
api.Start(ctx, config.API)
repo, err := eventsourcing.Start(config.Repository)
logging.Log("MAIN-9uBxp").OnError(err).Panic("unable to start app")
api.Start(ctx, config.API, authZ, repo)
}