add(sam): resource hints for org/chan/team
This commit is contained in:
@@ -2,6 +2,7 @@ package types
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
"time"
|
||||
)
|
||||
|
||||
@@ -53,6 +54,21 @@ type (
|
||||
ChannelMemberSet []*ChannelMember
|
||||
)
|
||||
|
||||
// Scope returns permissions group that for this type
|
||||
func (r *Channel) Scope() string {
|
||||
return "channel"
|
||||
}
|
||||
|
||||
// Resource returns a RBAC resource ID for this type
|
||||
func (r *Channel) Resource() string {
|
||||
return fmt.Sprintf("%s:%d", r.Scope(), r.ID)
|
||||
}
|
||||
|
||||
// Operation returns a RBAC resource-scoped role name for an operation
|
||||
func (r *Channel) Operation(name string) string {
|
||||
return fmt.Sprintf("%s/%s", r.Resource(), name)
|
||||
}
|
||||
|
||||
func (cc ChannelSet) Walk(w func(*Channel) error) (err error) {
|
||||
for i := range cc {
|
||||
if err = w(cc[i]); err != nil {
|
||||
|
||||
@@ -37,9 +37,9 @@ type (
|
||||
|
||||
const (
|
||||
MessageTypeSimpleMessage MessageType = ""
|
||||
MessageTypeChannelEvent MessageType = "channelEvent"
|
||||
MessageTypeInlineImage MessageType = "inlineImage"
|
||||
MessageTypeAttachment MessageType = "attachment"
|
||||
MessageTypeChannelEvent = "channelEvent"
|
||||
MessageTypeInlineImage = "inlineImage"
|
||||
MessageTypeAttachment = "attachment"
|
||||
)
|
||||
|
||||
func (mm MessageSet) Walk(w func(*Message) error) (err error) {
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
package types
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"time"
|
||||
)
|
||||
|
||||
@@ -20,3 +21,18 @@ type (
|
||||
Query string
|
||||
}
|
||||
)
|
||||
|
||||
// Scope returns permissions group that for this type
|
||||
func (r *Organisation) Scope() string {
|
||||
return "organisation"
|
||||
}
|
||||
|
||||
// Resource returns a RBAC resource ID for this type
|
||||
func (r *Organisation) Resource() string {
|
||||
return fmt.Sprintf("%s:%d", r.Scope(), r.ID)
|
||||
}
|
||||
|
||||
// Operation returns a RBAC resource-scoped role name for an operation
|
||||
func (r *Organisation) Operation(name string) string {
|
||||
return fmt.Sprintf("%s/%s", r.Resource(), name)
|
||||
}
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
package types
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"time"
|
||||
)
|
||||
|
||||
@@ -20,3 +21,18 @@ type (
|
||||
Query string
|
||||
}
|
||||
)
|
||||
|
||||
// Scope returns permissions group that for this type
|
||||
func (r *Team) Scope() string {
|
||||
return "team"
|
||||
}
|
||||
|
||||
// Resource returns a RBAC resource ID for this type
|
||||
func (r *Team) Resource() string {
|
||||
return fmt.Sprintf("%s:%d", r.Scope(), r.ID)
|
||||
}
|
||||
|
||||
// Operation returns a RBAC resource-scoped role name for an operation
|
||||
func (r *Team) Operation(name string) string {
|
||||
return fmt.Sprintf("%s/%s", r.Resource(), name)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user