mirror of
https://github.com/netbirdio/netbird.git
synced 2026-10-25 13:59:08 +01:00
better naming of exposed user permissions
This commit is contained in:
@@ -191,7 +191,7 @@ components:
|
|||||||
UserPermissions:
|
UserPermissions:
|
||||||
type: object
|
type: object
|
||||||
properties:
|
properties:
|
||||||
permissions:
|
modules:
|
||||||
type: object
|
type: object
|
||||||
additionalProperties:
|
additionalProperties:
|
||||||
type: object
|
type: object
|
||||||
@@ -208,7 +208,7 @@ components:
|
|||||||
- read
|
- read
|
||||||
- write
|
- write
|
||||||
example: {"networks": { "read": true, "write": false}, "peers": { "read": false, "write": false} }
|
example: {"networks": { "read": true, "write": false}, "peers": { "read": false, "write": false} }
|
||||||
auto_allow_new:
|
default:
|
||||||
type: object
|
type: object
|
||||||
additionalProperties:
|
additionalProperties:
|
||||||
type: boolean
|
type: boolean
|
||||||
@@ -218,8 +218,7 @@ components:
|
|||||||
- read
|
- read
|
||||||
- write
|
- write
|
||||||
required:
|
required:
|
||||||
- permissions
|
- default
|
||||||
- auto_allow_new
|
|
||||||
UserRequest:
|
UserRequest:
|
||||||
type: object
|
type: object
|
||||||
properties:
|
properties:
|
||||||
|
|||||||
@@ -1703,8 +1703,8 @@ type UserCreateRequest struct {
|
|||||||
|
|
||||||
// UserPermissions defines model for UserPermissions.
|
// UserPermissions defines model for UserPermissions.
|
||||||
type UserPermissions struct {
|
type UserPermissions struct {
|
||||||
AutoAllowNew map[string]bool `json:"auto_allow_new"`
|
Default map[string]bool `json:"default"`
|
||||||
Permissions map[string]map[string]bool `json:"permissions"`
|
Modules *map[string]map[string]bool `json:"modules,omitempty"`
|
||||||
}
|
}
|
||||||
|
|
||||||
// UserRequest defines model for UserRequest.
|
// UserRequest defines model for UserRequest.
|
||||||
|
|||||||
@@ -292,14 +292,14 @@ func toUserWithPermissionsResponse(user *users.UserInfoWithPermissions, userID s
|
|||||||
|
|
||||||
permissions := &api.UserPermissions{}
|
permissions := &api.UserPermissions{}
|
||||||
if len(user.Permissions.AutoAllowNew) > 0 {
|
if len(user.Permissions.AutoAllowNew) > 0 {
|
||||||
permissions.AutoAllowNew = make(map[string]bool)
|
permissions.Default = make(map[string]bool)
|
||||||
for k, v := range user.Permissions.AutoAllowNew {
|
for k, v := range user.Permissions.AutoAllowNew {
|
||||||
permissions.AutoAllowNew[string(k)] = v
|
permissions.Default[string(k)] = v
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if len(user.Permissions.Permissions) > 0 {
|
if len(user.Permissions.Permissions) > 0 {
|
||||||
permissions.Permissions = make(map[string]map[string]bool)
|
modules := make(map[string]map[string]bool)
|
||||||
for module, operations := range user.Permissions.Permissions {
|
for module, operations := range user.Permissions.Permissions {
|
||||||
if len(operations) == 0 {
|
if len(operations) == 0 {
|
||||||
continue
|
continue
|
||||||
@@ -309,8 +309,9 @@ func toUserWithPermissionsResponse(user *users.UserInfoWithPermissions, userID s
|
|||||||
for k, v := range operations {
|
for k, v := range operations {
|
||||||
access[string(k)] = v
|
access[string(k)] = v
|
||||||
}
|
}
|
||||||
permissions.Permissions[string(module)] = access
|
modules[string(module)] = access
|
||||||
}
|
}
|
||||||
|
permissions.Modules = &modules
|
||||||
}
|
}
|
||||||
|
|
||||||
response.Permissions = permissions
|
response.Permissions = permissions
|
||||||
|
|||||||
Reference in New Issue
Block a user