mirror of
https://github.com/zitadel/zitadel.git
synced 2025-02-28 21:07:22 +00:00
fix: allow project grants without roles in database (#3786)
This commit is contained in:
parent
a377f2816c
commit
7f34ce1891
@ -97,7 +97,7 @@ type orgViewProvider interface {
|
||||
|
||||
type userGrantProvider interface {
|
||||
ProjectByOIDCClientID(context.Context, string) (*query.Project, error)
|
||||
UserGrantsByProjectAndUserID(string, string) ([]*query.UserGrant, error)
|
||||
UserGrantsByProjectAndUserID(context.Context, string, string) ([]*query.UserGrant, error)
|
||||
}
|
||||
|
||||
type projectProvider interface {
|
||||
@ -1266,7 +1266,7 @@ func userGrantRequired(ctx context.Context, request *domain.AuthRequest, user *u
|
||||
if !project.ProjectRoleCheck {
|
||||
return false, nil
|
||||
}
|
||||
grants, err := userGrantProvider.UserGrantsByProjectAndUserID(project.ID, user.ID)
|
||||
grants, err := userGrantProvider.UserGrantsByProjectAndUserID(ctx, project.ID, user.ID)
|
||||
if err != nil {
|
||||
return false, err
|
||||
}
|
||||
|
@ -195,7 +195,7 @@ func (m *mockUserGrants) ProjectByOIDCClientID(ctx context.Context, s string) (*
|
||||
return &query.Project{ProjectRoleCheck: m.roleCheck}, nil
|
||||
}
|
||||
|
||||
func (m *mockUserGrants) UserGrantsByProjectAndUserID(s string, s2 string) ([]*query.UserGrant, error) {
|
||||
func (m *mockUserGrants) UserGrantsByProjectAndUserID(ctx context.Context, s string, s2 string) ([]*query.UserGrant, error) {
|
||||
var grants []*query.UserGrant
|
||||
if m.userGrants > 0 {
|
||||
grants = make([]*query.UserGrant, m.userGrants)
|
||||
|
@ -115,7 +115,7 @@ type queryViewWrapper struct {
|
||||
*auth_view.View
|
||||
}
|
||||
|
||||
func (q queryViewWrapper) UserGrantsByProjectAndUserID(projectID, userID string) ([]*query.UserGrant, error) {
|
||||
func (q queryViewWrapper) UserGrantsByProjectAndUserID(ctx context.Context, projectID, userID string) ([]*query.UserGrant, error) {
|
||||
userGrantProjectID, err := query.NewUserGrantProjectIDSearchQuery(projectID)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
@ -125,7 +125,7 @@ func (q queryViewWrapper) UserGrantsByProjectAndUserID(projectID, userID string)
|
||||
return nil, err
|
||||
}
|
||||
queries := &query.UserGrantsQueries{Queries: []query.SearchQuery{userGrantUserID, userGrantProjectID}}
|
||||
grants, err := q.Queries.UserGrants(context.TODO(), queries)
|
||||
grants, err := q.Queries.UserGrants(ctx, queries)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
@ -47,7 +47,7 @@ func NewProjectGrantProjection(ctx context.Context, config crdb.StatementHandler
|
||||
crdb.NewColumn(ProjectGrantColumnInstanceID, crdb.ColumnTypeText),
|
||||
crdb.NewColumn(ProjectGrantColumnProjectID, crdb.ColumnTypeText),
|
||||
crdb.NewColumn(ProjectGrantColumnGrantedOrgID, crdb.ColumnTypeText),
|
||||
crdb.NewColumn(ProjectGrantColumnRoleKeys, crdb.ColumnTypeTextArray),
|
||||
crdb.NewColumn(ProjectGrantColumnRoleKeys, crdb.ColumnTypeTextArray, crdb.Nullable()),
|
||||
},
|
||||
crdb.NewPrimaryKey(ProjectGrantColumnInstanceID, ProjectGrantColumnGrantID),
|
||||
crdb.WithIndex(crdb.NewIndex("ro_idx", []string{ProjectGrantColumnResourceOwner})),
|
||||
|
Loading…
x
Reference in New Issue
Block a user