-
Notifications
You must be signed in to change notification settings - Fork 6
/
Copy pathpermissions.go
94 lines (82 loc) · 3.07 KB
/
permissions.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
package guacamole
import (
"fmt"
"github.com/techBeck03/guacamole-api-client/types"
)
const (
// ConnectionPermissionsBasePath defines base path for connection permissions
ConnectionPermissionsBasePath = "/connectionPermissions"
// ConnectionGroupPermissionsBasePath defines base path for connection group permissions
ConnectionGroupPermissionsBasePath = "/connectionGroupPermissions"
)
var validSystemPermissions = types.StrSlice{
"ADMINISTER",
"CREATE_USER",
"CREATE_CONNECTION",
"CREATE_CONNECTION_GROUP",
"CREATE_SHARING_PROFILE",
}
// NewRemoveGroupMemberPermission creates a formatted guac permission item for removing a group member
func (c *Client) NewRemoveGroupMemberPermission(identifier string) types.GuacPermissionItem {
return types.GuacPermissionItem{
Op: "remove",
Path: "/",
Value: identifier,
}
}
// NewAddGroupMemberPermission creates a formatted guac permission item for adding a group member
func (c *Client) NewAddGroupMemberPermission(identifier string) types.GuacPermissionItem {
return types.GuacPermissionItem{
Op: "add",
Path: "/",
Value: identifier,
}
}
// NewAddSystemPermission creates a formatted guac permission item for system permissions
func (c *Client) NewAddSystemPermission(permission string) types.GuacPermissionItem {
return types.GuacPermissionItem{
Op: "add",
Path: "/systemPermissions",
Value: permission,
}
}
// NewRemoveSystemPermission creates a formatted guac permission item for system permissions
func (c *Client) NewRemoveSystemPermission(permission string) types.GuacPermissionItem {
return types.GuacPermissionItem{
Op: "remove",
Path: "/systemPermissions",
Value: permission,
}
}
// NewRemoveConnectionPermission creates a formatted guac permission item for removing a user connection permission
func (c *Client) NewRemoveConnectionPermission(identifier string) types.GuacPermissionItem {
return types.GuacPermissionItem{
Op: "remove",
Path: fmt.Sprintf("%s/%s", ConnectionPermissionsBasePath, identifier),
Value: "READ",
}
}
// NewAddConnectionPermission creates a formatted guac permission item for adding a user connection permission
func (c *Client) NewAddConnectionPermission(identifier string) types.GuacPermissionItem {
return types.GuacPermissionItem{
Op: "add",
Path: fmt.Sprintf("%s/%s", ConnectionPermissionsBasePath, identifier),
Value: "READ",
}
}
// NewRemoveConnectionGroupPermission creates a formatted guac permission item for removing a user connection permission
func (c *Client) NewRemoveConnectionGroupPermission(identifier string) types.GuacPermissionItem {
return types.GuacPermissionItem{
Op: "remove",
Path: fmt.Sprintf("%s/%s", ConnectionGroupPermissionsBasePath, identifier),
Value: "READ",
}
}
// NewAddConnectionGroupPermission creates a formatted guac permission item for adding a user connection permission
func (c *Client) NewAddConnectionGroupPermission(identifier string) types.GuacPermissionItem {
return types.GuacPermissionItem{
Op: "add",
Path: fmt.Sprintf("%s/%s", ConnectionGroupPermissionsBasePath, identifier),
Value: "READ",
}
}