- moved Access type from system to internal/rules, - moved Resource from system to internal/rules, - update imports for new type locations, - add scope list container to inject permissions, - update permissions API call to return default perms, - update codegen for generated Rules types
38 lines
621 B
Go
38 lines
621 B
Go
package rules
|
|
|
|
type (
|
|
scope struct {
|
|
providers []ScopeItem
|
|
}
|
|
|
|
ScopeItem struct {
|
|
Scope string `json:"scope"`
|
|
Permissions []OperationGroup `json:"permissions"`
|
|
}
|
|
|
|
ScopeProvider interface {
|
|
Resource() Resource
|
|
Permissions() []OperationGroup
|
|
}
|
|
|
|
ScopeInterface interface {
|
|
Add(ScopeProvider)
|
|
List() []ScopeItem
|
|
}
|
|
)
|
|
|
|
func NewScope() ScopeInterface {
|
|
return &scope{}
|
|
}
|
|
|
|
func (s *scope) Add(p ScopeProvider) {
|
|
s.providers = append(s.providers, ScopeItem{
|
|
Scope: p.Resource().Scope,
|
|
Permissions: p.Permissions(),
|
|
})
|
|
}
|
|
|
|
func (s *scope) List() []ScopeItem {
|
|
return s.providers
|
|
}
|