mirror of
https://github.com/zitadel/zitadel.git
synced 2025-01-08 19:07:39 +00:00
fix(token): filter users by instance id (#5596)
* fix(token): filter users by instance id
This commit is contained in:
parent
e688954308
commit
dd84b93ac3
1
.github/pull_request_template.md
vendored
1
.github/pull_request_template.md
vendored
@ -1,5 +1,6 @@
|
|||||||
```[tasklist]
|
```[tasklist]
|
||||||
### Definition of Ready
|
### Definition of Ready
|
||||||
|
|
||||||
- [ ] I am happy with the code
|
- [ ] I am happy with the code
|
||||||
- [ ] Short description of the feature/issue is added in the pr description
|
- [ ] Short description of the feature/issue is added in the pr description
|
||||||
- [ ] PR is linked to the corresponding user story
|
- [ ] PR is linked to the corresponding user story
|
||||||
|
@ -50,6 +50,7 @@ func (r *RefreshTokenRepo) RefreshTokenByID(ctx context.Context, tokenID, userID
|
|||||||
tokenView = new(model.RefreshTokenView)
|
tokenView = new(model.RefreshTokenView)
|
||||||
tokenView.ID = tokenID
|
tokenView.ID = tokenID
|
||||||
tokenView.UserID = userID
|
tokenView.UserID = userID
|
||||||
|
tokenView.InstanceID = authz.GetInstance(ctx).InstanceID()
|
||||||
}
|
}
|
||||||
|
|
||||||
events, esErr := r.getUserEvents(ctx, userID, tokenView.InstanceID, tokenView.Sequence)
|
events, esErr := r.getUserEvents(ctx, userID, tokenView.InstanceID, tokenView.Sequence)
|
||||||
|
@ -42,6 +42,7 @@ func (repo *TokenRepo) TokenByIDs(ctx context.Context, userID, tokenID string) (
|
|||||||
token = new(model.TokenView)
|
token = new(model.TokenView)
|
||||||
token.ID = tokenID
|
token.ID = tokenID
|
||||||
token.UserID = userID
|
token.UserID = userID
|
||||||
|
token.InstanceID = authz.GetInstance(ctx).InstanceID()
|
||||||
}
|
}
|
||||||
|
|
||||||
events, esErr := repo.getUserEvents(ctx, userID, token.InstanceID, token.Sequence)
|
events, esErr := repo.getUserEvents(ctx, userID, token.InstanceID, token.Sequence)
|
||||||
|
@ -3,6 +3,7 @@ package sql
|
|||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
"database/sql"
|
"database/sql"
|
||||||
|
"runtime/debug"
|
||||||
|
|
||||||
"github.com/zitadel/logging"
|
"github.com/zitadel/logging"
|
||||||
|
|
||||||
@ -17,6 +18,9 @@ type Querier interface {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (db *SQL) Filter(ctx context.Context, searchQuery *es_models.SearchQueryFactory) (events []*es_models.Event, err error) {
|
func (db *SQL) Filter(ctx context.Context, searchQuery *es_models.SearchQueryFactory) (events []*es_models.Event, err error) {
|
||||||
|
if !searchQuery.InstanceFiltered {
|
||||||
|
logging.WithFields("stack", string(debug.Stack())).Warn("instanceid not filtered")
|
||||||
|
}
|
||||||
return filter(ctx, db.client, searchQuery)
|
return filter(ctx, db.client, searchQuery)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -13,6 +13,8 @@ type SearchQueryFactory struct {
|
|||||||
limit uint64
|
limit uint64
|
||||||
desc bool
|
desc bool
|
||||||
queries []*query
|
queries []*query
|
||||||
|
|
||||||
|
InstanceFiltered bool
|
||||||
}
|
}
|
||||||
|
|
||||||
type query struct {
|
type query struct {
|
||||||
@ -42,11 +44,11 @@ const (
|
|||||||
Columns_Event = iota
|
Columns_Event = iota
|
||||||
Columns_Max_Sequence
|
Columns_Max_Sequence
|
||||||
Columns_InstanceIDs
|
Columns_InstanceIDs
|
||||||
//insert new columns-types before this columnsCount because count is needed for validation
|
// insert new columns-types before this columnsCount because count is needed for validation
|
||||||
columnsCount
|
columnsCount
|
||||||
)
|
)
|
||||||
|
|
||||||
//FactoryFromSearchQuery is deprecated because it's for migration purposes. use NewSearchQueryFactory
|
// FactoryFromSearchQuery is deprecated because it's for migration purposes. use NewSearchQueryFactory
|
||||||
func FactoryFromSearchQuery(q *SearchQuery) *SearchQueryFactory {
|
func FactoryFromSearchQuery(q *SearchQuery) *SearchQueryFactory {
|
||||||
factory := &SearchQueryFactory{
|
factory := &SearchQueryFactory{
|
||||||
columns: q.Columns,
|
columns: q.Columns,
|
||||||
@ -76,6 +78,7 @@ func FactoryFromSearchQuery(q *SearchQuery) *SearchQueryFactory {
|
|||||||
case Field_ResourceOwner:
|
case Field_ResourceOwner:
|
||||||
factory.queries[i] = factory.queries[i].ResourceOwner(filter.value.(string))
|
factory.queries[i] = factory.queries[i].ResourceOwner(filter.value.(string))
|
||||||
case Field_InstanceID:
|
case Field_InstanceID:
|
||||||
|
factory.InstanceFiltered = true
|
||||||
if filter.operation == Operation_Equals {
|
if filter.operation == Operation_Equals {
|
||||||
factory.queries[i] = factory.queries[i].InstanceID(filter.value.(string))
|
factory.queries[i] = factory.queries[i].InstanceID(filter.value.(string))
|
||||||
} else if filter.operation == Operation_NotIn {
|
} else if filter.operation == Operation_NotIn {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user