Allow service users with user role read-only access to all resources (#1484)

We allow service users with user role read-only access 
to all resources so users can create service user and propagate 
PATs without having to give full admin permissions.
This commit is contained in:
pascal-fischer
2024-01-25 09:50:27 +01:00
committed by GitHub
parent 4771fed64f
commit 399493a954
17 changed files with 72 additions and 35 deletions

View File

@@ -54,7 +54,7 @@ func (am *DefaultAccountManager) GetPeers(accountID, userID string) ([]*nbpeer.P
peers := make([]*nbpeer.Peer, 0)
peersMap := make(map[string]*nbpeer.Peer)
for _, peer := range account.Peers {
if !user.HasAdminPower() && user.Id != peer.UserID {
if !(user.HasAdminPower() || user.IsServiceUser) && user.Id != peer.UserID {
// only display peers that belong to the current user if the current user is not an admin
continue
}
@@ -723,7 +723,7 @@ func (am *DefaultAccountManager) GetPeer(accountID, peerID, userID string) (*nbp
}
// if admin or user owns this peer, return peer
if user.HasAdminPower() || peer.UserID == userID {
if user.HasAdminPower() || user.IsServiceUser || peer.UserID == userID {
return peer, nil
}