@@ -110,7 +110,6 @@ type AccountManager interface {
110
110
SaveGroups (ctx context.Context , accountID , userID string , newGroups []* nbgroup.Group ) error
111
111
DeleteGroup (ctx context.Context , accountId , userId , groupID string ) error
112
112
DeleteGroups (ctx context.Context , accountId , userId string , groupIDs []string ) error
113
- ListGroups (ctx context.Context , accountId string ) ([]* nbgroup.Group , error )
114
113
GroupAddPeer (ctx context.Context , accountId , groupID , peerID string ) error
115
114
GroupDeletePeer (ctx context.Context , accountId , groupID , peerID string ) error
116
115
GetPolicy (ctx context.Context , accountID , policyID , userID string ) (* Policy , error )
@@ -1435,7 +1434,7 @@ func isNil(i idp.Manager) bool {
1435
1434
// addAccountIDToIDPAppMeta update user's app metadata in idp manager
1436
1435
func (am * DefaultAccountManager ) addAccountIDToIDPAppMeta (ctx context.Context , userID string , accountID string ) error {
1437
1436
if ! isNil (am .idpManager ) {
1438
- accountUsers , err := am .Store .GetAccountUsers (ctx , accountID )
1437
+ accountUsers , err := am .Store .GetAccountUsers (ctx , LockingStrengthShare , accountID )
1439
1438
if err != nil {
1440
1439
return err
1441
1440
}
@@ -2083,7 +2082,7 @@ func (am *DefaultAccountManager) syncJWTGroups(ctx context.Context, accountID st
2083
2082
return fmt .Errorf ("error saving groups: %w" , err )
2084
2083
}
2085
2084
2086
- if err = transaction .IncrementNetworkSerial (ctx , accountID ); err != nil {
2085
+ if err = transaction .IncrementNetworkSerial (ctx , LockingStrengthUpdate , accountID ); err != nil {
2087
2086
return fmt .Errorf ("error incrementing network serial: %w" , err )
2088
2087
}
2089
2088
}
@@ -2101,7 +2100,7 @@ func (am *DefaultAccountManager) syncJWTGroups(ctx context.Context, accountID st
2101
2100
}
2102
2101
2103
2102
for _ , g := range addNewGroups {
2104
- group , err := am .Store .GetGroupByID (ctx , LockingStrengthShare , g , accountID )
2103
+ group , err := am .Store .GetGroupByID (ctx , LockingStrengthShare , accountID , g )
2105
2104
if err != nil {
2106
2105
log .WithContext (ctx ).Debugf ("group %s not found while saving user activity event of account %s" , g , accountID )
2107
2106
} else {
@@ -2114,7 +2113,7 @@ func (am *DefaultAccountManager) syncJWTGroups(ctx context.Context, accountID st
2114
2113
}
2115
2114
2116
2115
for _ , g := range removeOldGroups {
2117
- group , err := am .Store .GetGroupByID (ctx , LockingStrengthShare , g , accountID )
2116
+ group , err := am .Store .GetGroupByID (ctx , LockingStrengthShare , accountID , g )
2118
2117
if err != nil {
2119
2118
log .WithContext (ctx ).Debugf ("group %s not found while saving user activity event of account %s" , g , accountID )
2120
2119
} else {
@@ -2127,14 +2126,19 @@ func (am *DefaultAccountManager) syncJWTGroups(ctx context.Context, accountID st
2127
2126
}
2128
2127
2129
2128
if settings .GroupsPropagationEnabled {
2130
- account , err := am . requestBuffer . GetAccountWithBackpressure (ctx , accountID )
2129
+ removedGroupAffectsPeers , err := areGroupChangesAffectPeers (ctx , am . Store , accountID , removeOldGroups )
2131
2130
if err != nil {
2132
- return status . NewGetAccountError ( err )
2131
+ return err
2133
2132
}
2134
2133
2135
- if areGroupChangesAffectPeers (account , addNewGroups ) || areGroupChangesAffectPeers (account , removeOldGroups ) {
2134
+ newGroupsAffectsPeers , err := areGroupChangesAffectPeers (ctx , am .Store , accountID , addNewGroups )
2135
+ if err != nil {
2136
+ return err
2137
+ }
2138
+
2139
+ if removedGroupAffectsPeers || newGroupsAffectsPeers {
2136
2140
log .WithContext (ctx ).Tracef ("user %s: JWT group membership changed, updating account peers" , claims .UserId )
2137
- am .updateAccountPeers (ctx , account )
2141
+ am .updateAccountPeers (ctx , accountID )
2138
2142
}
2139
2143
}
2140
2144
@@ -2401,12 +2405,7 @@ func (am *DefaultAccountManager) CheckUserAccessByJWTGroups(ctx context.Context,
2401
2405
2402
2406
func (am * DefaultAccountManager ) onPeersInvalidated (ctx context.Context , accountID string ) {
2403
2407
log .WithContext (ctx ).Debugf ("validated peers has been invalidated for account %s" , accountID )
2404
- updatedAccount , err := am .Store .GetAccount (ctx , accountID )
2405
- if err != nil {
2406
- log .WithContext (ctx ).Errorf ("failed to get account %s: %v" , accountID , err )
2407
- return
2408
- }
2409
- am .updateAccountPeers (ctx , updatedAccount )
2408
+ am .updateAccountPeers (ctx , accountID )
2410
2409
}
2411
2410
2412
2411
func (am * DefaultAccountManager ) FindExistingPostureCheck (accountID string , checks * posture.ChecksDefinition ) (* posture.Checks , error ) {
0 commit comments