Allow regular users to see peers of group he belongs to #6680
a-elkaim
started this conversation in
Ideas & Feature Requests
Replies: 1 comment
|
I've implemented this proposal as a draft PR: #6771 It follows the plan in this discussion closely — an opt-in, default-off account setting
Build and tests are green: @a-elkaim — since you offered to submit a PR, feel free to take this over or use it as a base. Would a maintainer be willing to weigh in on whether a default-off setting like this is an acceptable approach? Happy to adjust to fit the preferred design. This also addresses the regression reported in #6599. |
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Before posting
Product area
CLI, Desktop UI, Mobile app, Dashboard / Admin UI, Management service / API
Problem or use case
We are managing a fleet of IoT devices, we are keeping track of the devices through their MAC Addresses.
In a near future, the support team will need to SSH into the devices for basic troubleshooting:
netbird ssh user@hostname.netbird.selfhostedor
ssh user@hostname.netbird.selfhostedTo do so, we created accounts with User Role set to "User" (the idea is to give the least permission possible), however we are currently facing a limitation: despite being able to connect to peers belonging to the same group, those peers are not visible in the WebUI (from what I understand, a simple "User" can only see peers he registered himself).
Because of this limitation, the support team is not able to determine which device they need to connect to on their own.
Either we give them an "Auditor" account (but then they can see ALL the peers), or provide them with the information for them to be able to connect (ie: engineering team member connects to the webui, search for the device using its serial / mac address / other... , and provides the IP or the hostname to the support).
Apparently, this behavior wasn't always present and might be a regression: #6599
Proposed solution
Since a user can already reach peers from the groups he belongs to (if the policies allow it), either allowing by default a user to see the peers from the groups he belongs to, or making it a per-user setting would solve this issue.
Alternatives or workarounds considered
I played with all the different "User roles" level, the only one that might allow our support team to be autonomous would be "Auditor", but then could see all the other peers, even those that aren't in their groups.
Community impact and priority
Self-hosted server, IoT device currently in final stages of development and will be deployed soon
Examples from other tools or products
No response
Security, privacy, and compatibility considerations
No response
Implementation ideas
A possible implementation, gated behind a new account setting (default off, so current behavior is preserved):
New account setting, add
RegularUsersGroupPeersViewEnabled booltoSettingsinmanagement/server/types/settings.go(next toRegularUsersViewBlocked, incl.Settings.Copy()). Column is picked up by AutoMigrate; the raw Postgres account query instore/sql_store.go(getAccount) also needs the new column.API surface, add optional
regular_users_group_peers_view_enabledtoAccountSettingsin the OpenAPI spec, regenerate types, and wire it through the accounts handler (updateAccountRequestSettings/toAccountResponse) so the dashboard can toggle it.Peer list (
DefaultAccountManager.GetPeers,management/server/peer.go), on the restricted path (nopeers:readpermission), when the setting is on, union the user's own peers (GetUserPeers) with peers from the user's groups via the existingStore.GetPeersByGroupIDs(accountID, user.AutoGroups), deduped by peer ID.RegularUsersViewBlockedkeeps precedence and still returns an empty list.Peer detail (
DefaultAccountManager.GetPeer), after the existing owner/admin check, allow access when the setting is on and the peer shares at least one group with the user (Store.GetPeerGroupIDs∩user.AutoGroups).Accessible peers (
GetAccessiblePeersinhttp/handlers/peers/peers_handler.go), extend thepeer.UserID != user.Idcheck with the same shared-group test (groups are already loaded on the account there).No store interface changes needed,
GetPeersByGroupIDsandGetPeerGroupIDsalready exist. Tests: extendTestDefaultAccountManager_GetPeers/_GetPeerand the accessible-peers handler tests (setting off → unchanged, on → own + group peers deduped,regular_users_view_blockedalways wins).Are you willing to help?
Yes, I can submit a PR if the approach is accepted.
Additional context
No response
All reactions