feat: project view (#90)

* init for views (spooler, handler)

* init for views (spooler, handler)

* start view in management

* granted project

* implement granted project view

* search granted projects

* fix search column

* update all projects on project change

* search roles

* filter org

* project members

* project grant members

* fix tests

* application view

* project grant search

* mock

* test appendevents

* test appendevents

* Update internal/view/query.go

Co-authored-by: Livio Amstutz <livio.a@gmail.com>

* Update internal/eventstore/spooler/spooler.go

Co-authored-by: Livio Amstutz <livio.a@gmail.com>

* Update internal/view/query.go

Co-authored-by: Livio Amstutz <livio.a@gmail.com>

* merge request changes

* Update internal/project/repository/view/model/application.go

Co-authored-by: Livio Amstutz <livio.a@gmail.com>

* merge request changes

* Project view sql (#92)

* sql and configs

* error handling

* sql start in eventstore

* on error handling, config

* read user on members

* Update internal/project/repository/view/application_view.go

Co-authored-by: Silvan <silvan.reusser@gmail.com>

* Update internal/project/repository/view/model/application.go

Co-authored-by: Silvan <silvan.reusser@gmail.com>

* Update internal/project/repository/view/model/application.go

Co-authored-by: Silvan <silvan.reusser@gmail.com>

* Update internal/project/repository/view/model/application.go

Co-authored-by: Silvan <silvan.reusser@gmail.com>

* Update internal/project/repository/view/model/application.go

Co-authored-by: Silvan <silvan.reusser@gmail.com>

* Update internal/project/repository/view/model/application.go

Co-authored-by: Silvan <silvan.reusser@gmail.com>

* Update internal/project/repository/view/model/application_query.go

Co-authored-by: Silvan <silvan.reusser@gmail.com>

* Update pkg/management/api/grpc/project_grant_converter.go

Co-authored-by: Silvan <silvan.reusser@gmail.com>

* Update pkg/management/api/grpc/project_grant_member_converter.go

Co-authored-by: Silvan <silvan.reusser@gmail.com>

* Update pkg/management/api/grpc/project_grant_member_converter.go

Co-authored-by: Silvan <silvan.reusser@gmail.com>

* Update pkg/management/api/grpc/project_member_converter.go

Co-authored-by: Silvan <silvan.reusser@gmail.com>

* Update pkg/management/api/grpc/project_member_converter.go

Co-authored-by: Silvan <silvan.reusser@gmail.com>

* Update internal/project/repository/view/model/granted_project.go

Co-authored-by: Silvan <silvan.reusser@gmail.com>

* return caos errors

* Update internal/project/repository/view/model/granted_project_query.go

Co-authored-by: Silvan <silvan.reusser@gmail.com>

* Update internal/project/repository/view/model/project_grant_member.go

Co-authored-by: Silvan <silvan.reusser@gmail.com>

* Update internal/project/repository/view/model/project_grant_member_query.go

Co-authored-by: Silvan <silvan.reusser@gmail.com>

* Update internal/project/repository/view/model/project_member.go

Co-authored-by: Silvan <silvan.reusser@gmail.com>

* Update internal/project/repository/view/model/project_member_query.go

Co-authored-by: Silvan <silvan.reusser@gmail.com>

* Update internal/project/repository/view/model/project_role.go

Co-authored-by: Silvan <silvan.reusser@gmail.com>

* Update internal/project/repository/view/model/project_role_query.go

Co-authored-by: Silvan <silvan.reusser@gmail.com>

* Update pkg/management/api/grpc/application_converter.go

Co-authored-by: Silvan <silvan.reusser@gmail.com>

* Update pkg/management/api/grpc/application_converter.go

Co-authored-by: Silvan <silvan.reusser@gmail.com>

* Update pkg/management/api/grpc/project_converter.go

Co-authored-by: Silvan <silvan.reusser@gmail.com>

* Update pkg/management/api/grpc/project_converter.go

Co-authored-by: Silvan <silvan.reusser@gmail.com>

* Update pkg/management/api/grpc/project_converter.go

Co-authored-by: Silvan <silvan.reusser@gmail.com>

* Update pkg/management/api/grpc/project_converter.go

Co-authored-by: Silvan <silvan.reusser@gmail.com>

* converter fix

Co-authored-by: Livio Amstutz <livio.a@gmail.com>
Co-authored-by: Silvan <silvan.reusser@gmail.com>
This commit is contained in:
Fabi
2020-05-11 12:16:29 +02:00
committed by GitHub
parent 49d86fdabb
commit 6e105f662e
92 changed files with 8354 additions and 3423 deletions

View File

@@ -0,0 +1,63 @@
package model
import (
"github.com/caos/zitadel/internal/model"
"time"
)
type ApplicationView struct {
ID string
ProjectID string
Name string
CreationDate time.Time
ChangeDate time.Time
State AppState
IsOIDC bool
OIDCClientID string
OIDCRedirectUris []string
OIDCResponseTypes []OIDCResponseType
OIDCGrantTypes []OIDCGrantType
OIDCApplicationType OIDCApplicationType
OIDCAuthMethodType OIDCAuthMethodType
OIDCPostLogoutRedirectUris []string
Sequence uint64
}
type ApplicationSearchRequest struct {
Offset uint64
Limit uint64
SortingColumn ApplicationSearchKey
Asc bool
Queries []*ApplicationSearchQuery
}
type ApplicationSearchKey int32
const (
APPLICATIONSEARCHKEY_UNSPECIFIED ApplicationSearchKey = iota
APPLICATIONSEARCHKEY_NAME
APPLICATIONSEARCHKEY_OIDC_CLIENT_ID
APPLICATIONSEARCHKEY_PROJECT_ID
APPLICATIONSEARCHKEY_APP_ID
)
type ApplicationSearchQuery struct {
Key ApplicationSearchKey
Method model.SearchMethod
Value string
}
type ApplicationSearchResponse struct {
Offset uint64
Limit uint64
TotalResult uint64
Result []*ApplicationView
}
func (r *ApplicationSearchRequest) EnsureLimit(limit uint64) {
if r.Limit == 0 || r.Limit > limit {
r.Limit = limit
}
}

View File

@@ -0,0 +1,85 @@
package model
import (
"context"
"github.com/caos/zitadel/internal/api"
grpc_util "github.com/caos/zitadel/internal/api/grpc"
"github.com/caos/zitadel/internal/model"
"time"
)
type GrantedProjectView struct {
ProjectID string
Name string
CreationDate time.Time
ChangeDate time.Time
State ProjectState
Type ProjectType
ResourceOwner string
OrgID string
OrgName string
OrgDomain string
Sequence uint64
GrantID string
GrantedRoleKeys []string
}
type ProjectType int32
const (
PROJECTTYPE_OWNED ProjectType = iota
PROJECTTYPE_GRANTED
)
type GrantedProjectSearchRequest struct {
Offset uint64
Limit uint64
SortingColumn GrantedProjectSearchKey
Asc bool
Queries []*GrantedProjectSearchQuery
}
type GrantedProjectSearchKey int32
const (
GRANTEDPROJECTSEARCHKEY_UNSPECIFIED GrantedProjectSearchKey = iota
GRANTEDPROJECTSEARCHKEY_NAME
GRANTEDPROJECTSEARCHKEY_PROJECTID
GRANTEDPROJECTSEARCHKEY_GRANTID
GRANTEDPROJECTSEARCHKEY_ORGID
GRANTEDPROJECTSEARCHKEY_RESOURCE_OWNER
)
type GrantedProjectSearchQuery struct {
Key GrantedProjectSearchKey
Method model.SearchMethod
Value string
}
type GrantedProjectSearchResponse struct {
Offset uint64
Limit uint64
TotalResult uint64
Result []*GrantedProjectView
}
func (r *GrantedProjectSearchRequest) AppendMyOrgQuery(ctx context.Context) {
orgID := grpc_util.GetHeader(ctx, api.ZitadelOrgID)
r.Queries = append(r.Queries, &GrantedProjectSearchQuery{Key: GRANTEDPROJECTSEARCHKEY_ORGID, Method: model.SEARCHMETHOD_EQUALS, Value: orgID})
}
func (r *GrantedProjectSearchRequest) AppendNotMyOrgQuery(ctx context.Context) {
orgID := grpc_util.GetHeader(ctx, api.ZitadelOrgID)
r.Queries = append(r.Queries, &GrantedProjectSearchQuery{Key: GRANTEDPROJECTSEARCHKEY_ORGID, Method: model.SEARCHMETHOD_NOT_EQUALS, Value: orgID})
}
func (r *GrantedProjectSearchRequest) AppendMyResourceOwnerQuery(ctx context.Context) {
orgID := grpc_util.GetHeader(ctx, api.ZitadelOrgID)
r.Queries = append(r.Queries, &GrantedProjectSearchQuery{Key: GRANTEDPROJECTSEARCHKEY_RESOURCE_OWNER, Method: model.SEARCHMETHOD_EQUALS, Value: orgID})
}
func (r *GrantedProjectSearchRequest) EnsureLimit(limit uint64) {
if r.Limit == 0 || r.Limit > limit {
r.Limit = limit
}
}

View File

@@ -0,0 +1,59 @@
package model
import (
"github.com/caos/zitadel/internal/model"
"time"
)
type ProjectGrantMemberView struct {
UserID string
GrantID string
ProjectID string
UserName string
Email string
FirstName string
LastName string
Roles []string
CreationDate time.Time
ChangeDate time.Time
Sequence uint64
}
type ProjectGrantMemberSearchRequest struct {
Offset uint64
Limit uint64
SortingColumn ProjectGrantMemberSearchKey
Asc bool
Queries []*ProjectGrantMemberSearchQuery
}
type ProjectGrantMemberSearchKey int32
const (
PROJECTGRANTMEMBERSEARCHKEY_UNSPECIFIED ProjectGrantMemberSearchKey = iota
PROJECTGRANTMEMBERSEARCHKEY_USER_NAME
PROJECTGRANTMEMBERSEARCHKEY_EMAIL
PROJECTGRANTMEMBERSEARCHKEY_FIRST_NAME
PROJECTGRANTMEMBERSEARCHKEY_LAST_NAME
PROJECTGRANTMEMBERSEARCHKEY_GRANT_ID
PROJECTGRANTMEMBERSEARCHKEY_USER_ID
)
type ProjectGrantMemberSearchQuery struct {
Key ProjectGrantMemberSearchKey
Method model.SearchMethod
Value string
}
type ProjectGrantMemberSearchResponse struct {
Offset uint64
Limit uint64
TotalResult uint64
Result []*ProjectGrantMemberView
}
func (r *ProjectGrantMemberSearchRequest) EnsureLimit(limit uint64) {
if r.Limit == 0 || r.Limit > limit {
r.Limit = limit
}
}

View File

@@ -0,0 +1,58 @@
package model
import (
"github.com/caos/zitadel/internal/model"
"time"
)
type ProjectMemberView struct {
UserID string
ProjectID string
UserName string
Email string
FirstName string
LastName string
Roles []string
CreationDate time.Time
ChangeDate time.Time
Sequence uint64
}
type ProjectMemberSearchRequest struct {
Offset uint64
Limit uint64
SortingColumn ProjectMemberSearchKey
Asc bool
Queries []*ProjectMemberSearchQuery
}
type ProjectMemberSearchKey int32
const (
PROJECTMEMBERSEARCHKEY_UNSPECIFIED ProjectMemberSearchKey = iota
PROJECTMEMBERSEARCHKEY_USER_NAME
PROJECTMEMBERSEARCHKEY_EMAIL
PROJECTMEMBERSEARCHKEY_FIRST_NAME
PROJECTMEMBERSEARCHKEY_LAST_NAME
PROJECTMEMBERSEARCHKEY_PROJECT_ID
PROJECTMEMBERSEARCHKEY_USER_ID
)
type ProjectMemberSearchQuery struct {
Key ProjectMemberSearchKey
Method model.SearchMethod
Value string
}
type ProjectMemberSearchResponse struct {
Offset uint64
Limit uint64
TotalResult uint64
Result []*ProjectMemberView
}
func (r *ProjectMemberSearchRequest) EnsureLimit(limit uint64) {
if r.Limit == 0 || r.Limit > limit {
r.Limit = limit
}
}

View File

@@ -0,0 +1,63 @@
package model
import (
"context"
"github.com/caos/zitadel/internal/api"
grpc_util "github.com/caos/zitadel/internal/api/grpc"
"github.com/caos/zitadel/internal/model"
"time"
)
type ProjectRoleView struct {
ResourceOwner string
OrgID string
ProjectID string
Key string
DisplayName string
Group string
CreationDate time.Time
Sequence uint64
}
type ProjectRoleSearchRequest struct {
Offset uint64
Limit uint64
SortingColumn ProjectRoleSearchKey
Asc bool
Queries []*ProjectRoleSearchQuery
}
type ProjectRoleSearchKey int32
const (
PROJECTROLESEARCHKEY_UNSPECIFIED ProjectRoleSearchKey = iota
PROJECTROLESEARCHKEY_KEY
PROJECTROLESEARCHKEY_PROJECTID
PROJECTROLESEARCHKEY_ORGID
PROJECTROLESEARCHKEY_RESOURCEOWNER
PROJECTROLESEARCHKEY_DISPLAY_NAME
)
type ProjectRoleSearchQuery struct {
Key ProjectRoleSearchKey
Method model.SearchMethod
Value string
}
type ProjectRoleSearchResponse struct {
Offset uint64
Limit uint64
TotalResult uint64
Result []*ProjectRoleView
}
func (r *ProjectRoleSearchRequest) AppendMyOrgQuery(ctx context.Context) {
orgID := grpc_util.GetHeader(ctx, api.ZitadelOrgID)
r.Queries = append(r.Queries, &ProjectRoleSearchQuery{Key: PROJECTROLESEARCHKEY_ORGID, Method: model.SEARCHMETHOD_EQUALS, Value: orgID})
}
func (r *ProjectRoleSearchRequest) EnsureLimit(limit uint64) {
if r.Limit == 0 || r.Limit > limit {
r.Limit = limit
}
}

View File

@@ -1,40 +0,0 @@
package model
import "github.com/caos/zitadel/internal/eventstore/models"
const (
ProjectAggregate models.AggregateType = "project"
ProjectAdded models.EventType = "project.added"
ProjectChanged models.EventType = "project.changed"
ProjectDeactivated models.EventType = "project.deactivated"
ProjectReactivated models.EventType = "project.reactivated"
ProjectMemberAdded models.EventType = "project.member.added"
ProjectMemberChanged models.EventType = "project.member.changed"
ProjectMemberRemoved models.EventType = "project.member.removed"
ProjectRoleAdded models.EventType = "project.role.added"
ProjectRoleChanged models.EventType = "project.role.changed"
ProjectRoleRemoved models.EventType = "project.role.removed"
ProjectGrantAdded models.EventType = "project.grant.added"
ProjectGrantChanged models.EventType = "project.grant.changed"
ProjectGrantRemoved models.EventType = "project.grant.removed"
ProjectGrantDeactivated models.EventType = "project.grant.deactivated"
ProjectGrantReactivated models.EventType = "project.grant.reactivated"
ProjectGrantMemberAdded models.EventType = "project.grant.member.added"
ProjectGrantMemberChanged models.EventType = "project.grant.member.changed"
ProjectGrantMemberRemoved models.EventType = "project.grant.member.removed"
ApplicationAdded models.EventType = "project.application.added"
ApplicationChanged models.EventType = "project.application.changed"
ApplicationRemoved models.EventType = "project.application.removed"
ApplicationDeactivated models.EventType = "project.application.deactivated"
ApplicationReactivated models.EventType = "project.application.reactivated"
OIDCConfigAdded models.EventType = "project.application.config.oidc.added"
OIDCConfigChanged models.EventType = "project.application.config.oidc.changed"
OIDCConfigSecretChanged models.EventType = "project.application.config.oidc.secret.changed"
)