mirror of
https://github.com/zitadel/zitadel.git
synced 2025-12-06 19:36:41 +00:00
feat: check has project (#2206)
* feat: define org grant check on project * feat: has project check * feat: has project check * feat: check has project * feat: check has project * feat: add has project check to console * Update internal/auth/repository/eventsourcing/eventstore/auth_request.go Co-authored-by: Livio Amstutz <livio.a@gmail.com> * Update internal/auth/repository/eventsourcing/eventstore/auth_request.go Co-authored-by: Livio Amstutz <livio.a@gmail.com> * Update internal/auth/repository/eventsourcing/eventstore/auth_request.go Co-authored-by: Livio Amstutz <livio.a@gmail.com> * Update internal/auth/repository/eventsourcing/eventstore/auth_request.go Co-authored-by: Livio Amstutz <livio.a@gmail.com> * Update internal/auth/repository/eventsourcing/eventstore/auth_request_test.go Co-authored-by: Livio Amstutz <livio.a@gmail.com> * Update internal/auth/repository/eventsourcing/eventstore/auth_request_test.go Co-authored-by: Livio Amstutz <livio.a@gmail.com> * Update internal/auth/repository/eventsourcing/eventstore/auth_request_test.go Co-authored-by: Livio Amstutz <livio.a@gmail.com> * Update internal/ui/login/static/i18n/en.yaml Co-authored-by: Livio Amstutz <livio.a@gmail.com> * fix: add has project tests Co-authored-by: Livio Amstutz <livio.a@gmail.com>
This commit is contained in:
@@ -31,6 +31,7 @@ type ApplicationView struct {
|
||||
State int32 `json:"-" gorm:"column:app_state"`
|
||||
ProjectRoleAssertion bool `json:"projectRoleAssertion" gorm:"column:project_role_assertion"`
|
||||
ProjectRoleCheck bool `json:"projectRoleCheck" gorm:"column:project_role_check"`
|
||||
HasProjectCheck bool `json:"hasProjectCheck" gorm:"column:has_project_check"`
|
||||
|
||||
IsOIDC bool `json:"-" gorm:"column:is_oidc"`
|
||||
OIDCVersion int32 `json:"oidcVersion" gorm:"column:oidc_version"`
|
||||
@@ -234,6 +235,7 @@ func (a *ApplicationView) setProjectChanges(event *models.Event) error {
|
||||
changes := struct {
|
||||
ProjectRoleAssertion *bool `json:"projectRoleAssertion,omitempty"`
|
||||
ProjectRoleCheck *bool `json:"projectRoleCheck,omitempty"`
|
||||
HasProjectCheck *bool `json:"hasProjectCheck,omitempty"`
|
||||
}{}
|
||||
if err := json.Unmarshal(event.Data, &changes); err != nil {
|
||||
logging.Log("EVEN-DFbfg").WithError(err).Error("could not unmarshal event data")
|
||||
@@ -245,5 +247,8 @@ func (a *ApplicationView) setProjectChanges(event *models.Event) error {
|
||||
if changes.ProjectRoleCheck != nil {
|
||||
a.ProjectRoleCheck = *changes.ProjectRoleCheck
|
||||
}
|
||||
if changes.HasProjectCheck != nil {
|
||||
a.HasProjectCheck = *changes.HasProjectCheck
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
@@ -0,0 +1,13 @@
|
||||
package model
|
||||
|
||||
const (
|
||||
OrgProjectMappingKeyProjectID = "project_id"
|
||||
OrgProjectMappingKeyOrgID = "org_id"
|
||||
OrgProjectMappingKeyProjectGrantID = "project_grant_id"
|
||||
)
|
||||
|
||||
type OrgProjectMapping struct {
|
||||
ProjectID string `json:"-" gorm:"column:project_id;primary_key"`
|
||||
OrgID string `json:"-" gorm:"column:org_id;primary_key"`
|
||||
ProjectGrantID string `json:"-" gorm:"column:project_grant_id;"`
|
||||
}
|
||||
@@ -0,0 +1,63 @@
|
||||
package model
|
||||
|
||||
import (
|
||||
"github.com/caos/zitadel/internal/domain"
|
||||
proj_model "github.com/caos/zitadel/internal/project/model"
|
||||
"github.com/caos/zitadel/internal/view/repository"
|
||||
)
|
||||
|
||||
type OrgProjectMappingSearchRequest proj_model.OrgProjectMappingViewSearchRequest
|
||||
type OrgProjectMappingSearchQuery proj_model.OrgProjectMappingViewSearchQuery
|
||||
type OrgProjectMappingSearchKey proj_model.OrgProjectMappingViewSearchKey
|
||||
|
||||
func (req OrgProjectMappingSearchRequest) GetLimit() uint64 {
|
||||
return req.Limit
|
||||
}
|
||||
|
||||
func (req OrgProjectMappingSearchRequest) GetOffset() uint64 {
|
||||
return req.Offset
|
||||
}
|
||||
|
||||
func (req OrgProjectMappingSearchRequest) GetSortingColumn() repository.ColumnKey {
|
||||
if req.SortingColumn == proj_model.OrgProjectMappingSearchKeyUnspecified {
|
||||
return nil
|
||||
}
|
||||
return OrgProjectMappingSearchKey(req.SortingColumn)
|
||||
}
|
||||
|
||||
func (req OrgProjectMappingSearchRequest) GetAsc() bool {
|
||||
return req.Asc
|
||||
}
|
||||
|
||||
func (req OrgProjectMappingSearchRequest) GetQueries() []repository.SearchQuery {
|
||||
result := make([]repository.SearchQuery, len(req.Queries))
|
||||
for i, q := range req.Queries {
|
||||
result[i] = OrgProjectMappingSearchQuery{Key: q.Key, Value: q.Value, Method: q.Method}
|
||||
}
|
||||
return result
|
||||
}
|
||||
|
||||
func (req OrgProjectMappingSearchQuery) GetKey() repository.ColumnKey {
|
||||
return OrgProjectMappingSearchKey(req.Key)
|
||||
}
|
||||
|
||||
func (req OrgProjectMappingSearchQuery) GetMethod() domain.SearchMethod {
|
||||
return req.Method
|
||||
}
|
||||
|
||||
func (req OrgProjectMappingSearchQuery) GetValue() interface{} {
|
||||
return req.Value
|
||||
}
|
||||
|
||||
func (key OrgProjectMappingSearchKey) ToColumnName() string {
|
||||
switch proj_model.OrgProjectMappingViewSearchKey(key) {
|
||||
case proj_model.OrgProjectMappingSearchKeyOrgID:
|
||||
return OrgProjectMappingKeyOrgID
|
||||
case proj_model.OrgProjectMappingSearchKeyProjectID:
|
||||
return OrgProjectMappingKeyProjectID
|
||||
case proj_model.OrgProjectMappingSearchKeyProjectGrantID:
|
||||
return OrgProjectMappingKeyProjectGrantID
|
||||
default:
|
||||
return ""
|
||||
}
|
||||
}
|
||||
@@ -27,23 +27,10 @@ type ProjectView struct {
|
||||
ResourceOwner string `json:"-" gorm:"column:resource_owner"`
|
||||
ProjectRoleAssertion bool `json:"projectRoleAssertion" gorm:"column:project_role_assertion"`
|
||||
ProjectRoleCheck bool `json:"projectRoleCheck" gorm:"column:project_role_check"`
|
||||
HasProjectCheck bool `json:"hasProjectCheck" gorm:"column:has_project_check"`
|
||||
Sequence uint64 `json:"-" gorm:"column:sequence"`
|
||||
}
|
||||
|
||||
func ProjectFromModel(project *model.ProjectView) *ProjectView {
|
||||
return &ProjectView{
|
||||
ProjectID: project.ProjectID,
|
||||
Name: project.Name,
|
||||
ChangeDate: project.ChangeDate,
|
||||
CreationDate: project.CreationDate,
|
||||
State: int32(project.State),
|
||||
ResourceOwner: project.ResourceOwner,
|
||||
ProjectRoleAssertion: project.ProjectRoleAssertion,
|
||||
ProjectRoleCheck: project.ProjectRoleCheck,
|
||||
Sequence: project.Sequence,
|
||||
}
|
||||
}
|
||||
|
||||
func ProjectToModel(project *ProjectView) *model.ProjectView {
|
||||
return &model.ProjectView{
|
||||
ProjectID: project.ProjectID,
|
||||
@@ -54,6 +41,7 @@ func ProjectToModel(project *ProjectView) *model.ProjectView {
|
||||
ResourceOwner: project.ResourceOwner,
|
||||
ProjectRoleAssertion: project.ProjectRoleAssertion,
|
||||
ProjectRoleCheck: project.ProjectRoleCheck,
|
||||
HasProjectCheck: project.HasProjectCheck,
|
||||
Sequence: project.Sequence,
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user