mirror of
https://github.com/netbirdio/netbird.git
synced 2025-08-13 08:57:28 +02:00
check user accounts for setup keys
Signed-off-by: bcmmbaga <bethuelmbaga12@gmail.com>
This commit is contained in:
@ -217,7 +217,7 @@ func (am *DefaultAccountManager) CreateSetupKey(ctx context.Context, accountID s
|
|||||||
}
|
}
|
||||||
|
|
||||||
if user.AccountID != accountID {
|
if user.AccountID != accountID {
|
||||||
return nil, status.Errorf(status.PermissionDenied, "only users with admin power can update setup keys")
|
return nil, status.Errorf(status.PermissionDenied, errUserNotPartOfAccountMsg)
|
||||||
}
|
}
|
||||||
|
|
||||||
keyDuration := DefaultSetupKeyDuration
|
keyDuration := DefaultSetupKeyDuration
|
||||||
@ -275,7 +275,7 @@ func (am *DefaultAccountManager) SaveSetupKey(ctx context.Context, accountID str
|
|||||||
}
|
}
|
||||||
|
|
||||||
if user.AccountID != accountID {
|
if user.AccountID != accountID {
|
||||||
return nil, status.Errorf(status.PermissionDenied, "only users with admin power can update setup keys")
|
return nil, status.Errorf(status.PermissionDenied, errUserNotPartOfAccountMsg)
|
||||||
}
|
}
|
||||||
|
|
||||||
groups, err := am.Store.GetAccountGroups(ctx, LockingStrengthShare, accountID)
|
groups, err := am.Store.GetAccountGroups(ctx, LockingStrengthShare, accountID)
|
||||||
@ -348,10 +348,14 @@ func (am *DefaultAccountManager) ListSetupKeys(ctx context.Context, accountID, u
|
|||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
if !user.IsAdminOrServiceUser() || user.AccountID != accountID {
|
if !user.IsAdminOrServiceUser() {
|
||||||
return nil, status.Errorf(status.Unauthorized, "only users with admin power can view setup keys")
|
return nil, status.Errorf(status.Unauthorized, "only users with admin power can view setup keys")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if user.AccountID != accountID {
|
||||||
|
return nil, status.Errorf(status.PermissionDenied, errUserNotPartOfAccountMsg)
|
||||||
|
}
|
||||||
|
|
||||||
setupKeys, err := am.Store.GetAccountSetupKeys(ctx, LockingStrengthShare, accountID)
|
setupKeys, err := am.Store.GetAccountSetupKeys(ctx, LockingStrengthShare, accountID)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
@ -378,10 +382,14 @@ func (am *DefaultAccountManager) GetSetupKey(ctx context.Context, accountID, use
|
|||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
if !user.IsAdminOrServiceUser() || user.AccountID != accountID {
|
if !user.IsAdminOrServiceUser() {
|
||||||
return nil, status.Errorf(status.Unauthorized, "only users with admin power can view setup keys")
|
return nil, status.Errorf(status.Unauthorized, "only users with admin power can view setup keys")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if user.AccountID != accountID {
|
||||||
|
return nil, status.Errorf(status.PermissionDenied, errUserNotPartOfAccountMsg)
|
||||||
|
}
|
||||||
|
|
||||||
setupKey, err := am.Store.GetSetupKeyByID(ctx, LockingStrengthShare, accountID, keyID)
|
setupKey, err := am.Store.GetSetupKeyByID(ctx, LockingStrengthShare, accountID, keyID)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
|
Reference in New Issue
Block a user