feat: api v2beta to api v2 (#8283)

# Which Problems Are Solved

The v2beta services are stable but not GA.

# How the Problems Are Solved

The v2beta services are copied to v2. The corresponding v1 and v2beta
services are deprecated.

# Additional Context

Closes #7236

---------

Co-authored-by: Elio Bischof <elio@zitadel.com>
This commit is contained in:
Stefan Benz
2024-07-26 22:39:55 +02:00
committed by GitHub
parent bc16962aac
commit 7d2d85f57c
142 changed files with 15170 additions and 386 deletions

View File

@@ -98,6 +98,29 @@ type AuthMethods struct {
AuthMethods []*AuthMethod
}
func (l *AuthMethods) RemoveNoPermission(ctx context.Context, permissionCheck domain.PermissionCheck) {
removableIndexes := make([]int, 0)
for i := range l.AuthMethods {
ctxData := authz.GetCtxData(ctx)
if ctxData.UserID != l.AuthMethods[i].UserID {
if err := permissionCheck(ctx, domain.PermissionUserRead, l.AuthMethods[i].ResourceOwner, l.AuthMethods[i].UserID); err != nil {
removableIndexes = append(removableIndexes, i)
}
}
}
removed := 0
for _, removeIndex := range removableIndexes {
l.AuthMethods = removeAuthMethod(l.AuthMethods, removeIndex-removed)
removed++
}
// reset count as some users could be removed
l.SearchResponse.Count = uint64(len(l.AuthMethods))
}
func removeAuthMethod(slice []*AuthMethod, s int) []*AuthMethod {
return append(slice[:s], slice[s+1:]...)
}
type AuthMethod struct {
UserID string
CreationDate time.Time