add(sam): per-entity permissions list
This commit is contained in:
@@ -0,0 +1,51 @@
|
||||
package types
|
||||
|
||||
import "github.com/crusttech/crust/internal/rbac"
|
||||
|
||||
/* File is generated from sam/types/permissions/3-channel.json & main.go */
|
||||
|
||||
func (c *Channel) Permissions() []rbac.OperationGroup {
|
||||
return []rbac.OperationGroup{
|
||||
rbac.OperationGroup{
|
||||
Name: "",
|
||||
Operations: []rbac.Operation{
|
||||
rbac.Operation{
|
||||
Key: "manage.webhooks",
|
||||
Name: "Manage webhooks (@todo: implement webhooks)",
|
||||
Title: "Members with this permission can create, edit and delete webhooks",
|
||||
Enabled: false, Default: "",
|
||||
},
|
||||
},
|
||||
}, rbac.OperationGroup{
|
||||
Name: "",
|
||||
Operations: []rbac.Operation{
|
||||
rbac.Operation{
|
||||
Key: "send",
|
||||
Name: "Send Messages",
|
||||
Title: "",
|
||||
Enabled: true, Default: "",
|
||||
}, rbac.Operation{
|
||||
Key: "embed",
|
||||
Name: "Embed Links",
|
||||
Title: "",
|
||||
Enabled: true, Default: "",
|
||||
}, rbac.Operation{
|
||||
Key: "attach",
|
||||
Name: "Attach Files",
|
||||
Title: "",
|
||||
Enabled: true, Default: "",
|
||||
}, rbac.Operation{
|
||||
Key: "manage.messages",
|
||||
Name: "Manage messages",
|
||||
Title: "Members with this permission can edit/delete messages inside this channel",
|
||||
Enabled: true, Default: "",
|
||||
}, rbac.Operation{
|
||||
Key: "react",
|
||||
Name: "Manage reactions",
|
||||
Title: "Members with this permission can add new reactions to a message",
|
||||
Enabled: true, Default: "",
|
||||
},
|
||||
},
|
||||
},
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,76 @@
|
||||
package types
|
||||
|
||||
import "github.com/crusttech/crust/internal/rbac"
|
||||
|
||||
/* File is generated from sam/types/permissions/1-organisation.json & main.go */
|
||||
|
||||
func (c *Organisation) Permissions() []rbac.OperationGroup {
|
||||
return []rbac.OperationGroup{
|
||||
rbac.OperationGroup{
|
||||
Name: "",
|
||||
Operations: []rbac.Operation{
|
||||
rbac.Operation{
|
||||
Key: "admin",
|
||||
Name: "Administrator",
|
||||
Title: "Members with this permission have every permission and also bypass channel specific permissions. Granting this permission is dangerous",
|
||||
Enabled: true, Default: "deny",
|
||||
}, rbac.Operation{
|
||||
Key: "audit",
|
||||
Name: "View Audit Log (@todo: add audit logs)",
|
||||
Title: "Members with this permission have access to view the servers audit logs",
|
||||
Enabled: false, Default: "deny",
|
||||
}, rbac.Operation{
|
||||
Key: "manage.organisation",
|
||||
Name: "Manage Organisation",
|
||||
Title: "Members with this permission can change the organisation name and other organisation details",
|
||||
Enabled: true, Default: "deny",
|
||||
}, rbac.Operation{
|
||||
Key: "manage.roles",
|
||||
Name: "Manage Roles",
|
||||
Title: "Members with this permission can create/edit/delete roles inside this organisation",
|
||||
Enabled: true, Default: "deny",
|
||||
}, rbac.Operation{
|
||||
Key: "manage.channels",
|
||||
Name: "Manage channels",
|
||||
Title: "Members with this permission can create/edit/delete channels inside this organisation",
|
||||
Enabled: true, Default: "deny",
|
||||
}, rbac.Operation{
|
||||
Key: "manage.webhooks",
|
||||
Name: "Manage webhooks (@todo: implement webhooks)",
|
||||
Title: "Members with this permission can create, edit and delete webhooks",
|
||||
Enabled: false, Default: "deny",
|
||||
},
|
||||
},
|
||||
}, rbac.OperationGroup{
|
||||
Name: "",
|
||||
Operations: []rbac.Operation{
|
||||
rbac.Operation{
|
||||
Key: "send",
|
||||
Name: "Send Messages",
|
||||
Title: "",
|
||||
Enabled: true, Default: "allow",
|
||||
}, rbac.Operation{
|
||||
Key: "embed",
|
||||
Name: "Embed Links",
|
||||
Title: "",
|
||||
Enabled: true, Default: "allow",
|
||||
}, rbac.Operation{
|
||||
Key: "attach",
|
||||
Name: "Attach Files",
|
||||
Title: "",
|
||||
Enabled: true, Default: "allow",
|
||||
}, rbac.Operation{
|
||||
Key: "manage.messages",
|
||||
Name: "Manage messages",
|
||||
Title: "Members with this permission can edit/delete messages inside channels",
|
||||
Enabled: true, Default: "deny",
|
||||
}, rbac.Operation{
|
||||
Key: "react",
|
||||
Name: "Manage reactions",
|
||||
Title: "Members with this permission can add new reactions to a message",
|
||||
Enabled: true, Default: "allow",
|
||||
},
|
||||
},
|
||||
},
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,19 @@
|
||||
package types
|
||||
|
||||
import (
|
||||
"github.com/crusttech/crust/internal/rbac"
|
||||
)
|
||||
|
||||
type (
|
||||
ResourceProvider interface {
|
||||
Scope() string
|
||||
Resource() string
|
||||
Operation(name string) string
|
||||
Permissions() []rbac.OperationGroup
|
||||
}
|
||||
)
|
||||
|
||||
// These entities create resources in RBAC
|
||||
var _ ResourceProvider = &Organisation{}
|
||||
var _ ResourceProvider = &Team{}
|
||||
var _ ResourceProvider = &Channel{}
|
||||
@@ -0,0 +1,86 @@
|
||||
[
|
||||
{
|
||||
"title": "General permissions",
|
||||
"operations": [
|
||||
{
|
||||
"key": "admin",
|
||||
"name": "Administrator",
|
||||
"title": "Members with this permission have every permission and also bypass channel specific permissions. Granting this permission is dangerous",
|
||||
"enabled": true,
|
||||
"default": "deny"
|
||||
},
|
||||
{
|
||||
"key": "audit",
|
||||
"name": "View Audit Log (@todo: add audit logs)",
|
||||
"title": "Members with this permission have access to view the servers audit logs",
|
||||
"enabled": false,
|
||||
"default": "deny"
|
||||
},
|
||||
{
|
||||
"key": "manage.organisation",
|
||||
"name": "Manage Organisation",
|
||||
"title": "Members with this permission can change the organisation name and other organisation details",
|
||||
"enabled": true,
|
||||
"default": "deny"
|
||||
},
|
||||
{
|
||||
"key": "manage.roles",
|
||||
"name": "Manage Roles",
|
||||
"title": "Members with this permission can create/edit/delete roles inside this organisation",
|
||||
"enabled": true,
|
||||
"default": "deny"
|
||||
},
|
||||
{
|
||||
"key": "manage.channels",
|
||||
"name": "Manage channels",
|
||||
"title": "Members with this permission can create/edit/delete channels inside this organisation",
|
||||
"enabled": true,
|
||||
"default": "deny"
|
||||
},
|
||||
{
|
||||
"key": "manage.webhooks",
|
||||
"name": "Manage webhooks (@todo: implement webhooks)",
|
||||
"title": "Members with this permission can create, edit and delete webhooks",
|
||||
"enabled": false,
|
||||
"default": "deny"
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"title": "Text Permissions",
|
||||
"operations": [
|
||||
{
|
||||
"key": "send",
|
||||
"name": "Send Messages",
|
||||
"enabled": true,
|
||||
"default": "allow"
|
||||
},
|
||||
{
|
||||
"key": "embed",
|
||||
"name": "Embed Links",
|
||||
"enabled": true,
|
||||
"default": "allow"
|
||||
},
|
||||
{
|
||||
"key": "attach",
|
||||
"name": "Attach Files",
|
||||
"enabled": true,
|
||||
"default": "allow"
|
||||
},
|
||||
{
|
||||
"key": "manage.messages",
|
||||
"name": "Manage messages",
|
||||
"title": "Members with this permission can edit/delete messages inside channels",
|
||||
"enabled": true,
|
||||
"default": "deny"
|
||||
},
|
||||
{
|
||||
"key": "react",
|
||||
"name": "Manage reactions",
|
||||
"title": "Members with this permission can add new reactions to a message",
|
||||
"enabled": true,
|
||||
"default": "allow"
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
@@ -0,0 +1,45 @@
|
||||
[
|
||||
{
|
||||
"title": "General permissions",
|
||||
"operations": [
|
||||
{
|
||||
"key": "manage.webhooks",
|
||||
"name": "Manage webhooks (@todo: implement webhooks)",
|
||||
"title": "Members with this permission can create, edit and delete webhooks",
|
||||
"enabled": false
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"title": "Text Permissions",
|
||||
"operations": [
|
||||
{
|
||||
"key": "send",
|
||||
"name": "Send Messages",
|
||||
"enabled": true
|
||||
},
|
||||
{
|
||||
"key": "embed",
|
||||
"name": "Embed Links",
|
||||
"enabled": true
|
||||
},
|
||||
{
|
||||
"key": "attach",
|
||||
"name": "Attach Files",
|
||||
"enabled": true
|
||||
},
|
||||
{
|
||||
"key": "manage.messages",
|
||||
"name": "Manage messages",
|
||||
"title": "Members with this permission can edit/delete messages inside channels",
|
||||
"enabled": true
|
||||
},
|
||||
{
|
||||
"key": "react",
|
||||
"name": "Manage reactions",
|
||||
"title": "Members with this permission can add new reactions to a message",
|
||||
"enabled": true
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
@@ -0,0 +1,45 @@
|
||||
[
|
||||
{
|
||||
"title": "General permissions",
|
||||
"operations": [
|
||||
{
|
||||
"key": "manage.webhooks",
|
||||
"name": "Manage webhooks (@todo: implement webhooks)",
|
||||
"title": "Members with this permission can create, edit and delete webhooks",
|
||||
"enabled": false
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"title": "Text Permissions",
|
||||
"operations": [
|
||||
{
|
||||
"key": "send",
|
||||
"name": "Send Messages",
|
||||
"enabled": true
|
||||
},
|
||||
{
|
||||
"key": "embed",
|
||||
"name": "Embed Links",
|
||||
"enabled": true
|
||||
},
|
||||
{
|
||||
"key": "attach",
|
||||
"name": "Attach Files",
|
||||
"enabled": true
|
||||
},
|
||||
{
|
||||
"key": "manage.messages",
|
||||
"name": "Manage messages",
|
||||
"title": "Members with this permission can edit/delete messages inside this channel",
|
||||
"enabled": true
|
||||
},
|
||||
{
|
||||
"key": "react",
|
||||
"name": "Manage reactions",
|
||||
"title": "Members with this permission can add new reactions to a message",
|
||||
"enabled": true
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
@@ -0,0 +1,58 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
"encoding/json"
|
||||
"flag"
|
||||
"fmt"
|
||||
"io/ioutil"
|
||||
"log"
|
||||
"os"
|
||||
"strings"
|
||||
|
||||
"github.com/crusttech/crust/internal/rbac"
|
||||
)
|
||||
|
||||
func main() {
|
||||
var (
|
||||
pkg = flag.String("package", "main", "Package name")
|
||||
input = flag.String("input", "", "Input .json filename")
|
||||
output = flag.String("output", "", "Output .go filename")
|
||||
fname = flag.String("function", "func Permissions() []rbac.OperationGroup", "Default function declaration")
|
||||
)
|
||||
flag.Parse()
|
||||
|
||||
export := func(s string) string {
|
||||
s = strings.Replace(s, "{", "{\n", -1)
|
||||
s = strings.Replace(s, "}", ",\n}", -1)
|
||||
s = strings.Replace(s, "\", ", "\",\n", -1)
|
||||
|
||||
var w bytes.Buffer
|
||||
|
||||
fmt.Fprintln(&w, "package", *pkg)
|
||||
fmt.Fprintln(&w)
|
||||
fmt.Fprintln(&w, "import \"github.com/crusttech/crust/internal/rbac\"")
|
||||
fmt.Fprintln(&w)
|
||||
fmt.Fprintln(&w, "/* File is generated from", *input, "& main.go */")
|
||||
fmt.Fprintln(&w)
|
||||
fmt.Fprintln(&w, *fname, "{")
|
||||
fmt.Fprintln(&w, "\treturn", s)
|
||||
fmt.Fprintln(&w, "}")
|
||||
|
||||
return w.String()
|
||||
}
|
||||
|
||||
var result []rbac.OperationGroup
|
||||
f, err := os.Open(*input)
|
||||
if err != nil {
|
||||
log.Fatal(err)
|
||||
}
|
||||
if err := json.NewDecoder(f).Decode(&result); err != nil {
|
||||
log.Fatal(err)
|
||||
}
|
||||
source := export(fmt.Sprintf("%#v", result))
|
||||
if err := ioutil.WriteFile(*output, []byte(source), 0644); err != nil {
|
||||
log.Fatal(err)
|
||||
}
|
||||
fmt.Println(*output)
|
||||
}
|
||||
@@ -0,0 +1,51 @@
|
||||
package types
|
||||
|
||||
import "github.com/crusttech/crust/internal/rbac"
|
||||
|
||||
/* File is generated from sam/types/permissions/2-team.json & main.go */
|
||||
|
||||
func (c *Team) Permissions() []rbac.OperationGroup {
|
||||
return []rbac.OperationGroup{
|
||||
rbac.OperationGroup{
|
||||
Name: "",
|
||||
Operations: []rbac.Operation{
|
||||
rbac.Operation{
|
||||
Key: "manage.webhooks",
|
||||
Name: "Manage webhooks (@todo: implement webhooks)",
|
||||
Title: "Members with this permission can create, edit and delete webhooks",
|
||||
Enabled: false, Default: "",
|
||||
},
|
||||
},
|
||||
}, rbac.OperationGroup{
|
||||
Name: "",
|
||||
Operations: []rbac.Operation{
|
||||
rbac.Operation{
|
||||
Key: "send",
|
||||
Name: "Send Messages",
|
||||
Title: "",
|
||||
Enabled: true, Default: "",
|
||||
}, rbac.Operation{
|
||||
Key: "embed",
|
||||
Name: "Embed Links",
|
||||
Title: "",
|
||||
Enabled: true, Default: "",
|
||||
}, rbac.Operation{
|
||||
Key: "attach",
|
||||
Name: "Attach Files",
|
||||
Title: "",
|
||||
Enabled: true, Default: "",
|
||||
}, rbac.Operation{
|
||||
Key: "manage.messages",
|
||||
Name: "Manage messages",
|
||||
Title: "Members with this permission can edit/delete messages inside channels",
|
||||
Enabled: true, Default: "",
|
||||
}, rbac.Operation{
|
||||
Key: "react",
|
||||
Name: "Manage reactions",
|
||||
Title: "Members with this permission can add new reactions to a message",
|
||||
Enabled: true, Default: "",
|
||||
},
|
||||
},
|
||||
},
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user