AccessControl: Remove package lists for roles and grants (#47141)
* AccessControl: Remove package variables for roles and grants Co-authored-by: Jguer <joao.guerreiro@grafana.com> * Check for inheritance during role registration Co-authored-by: Jguer <joao.guerreiro@grafana.com> * Moving back role definition to accessscontrol * Make settings reader role public Co-authored-by: Jguer <joao.guerreiro@grafana.com> * Nits Co-authored-by: Jguer <joao.guerreiro@grafana.com> * Forgot to update this * Account for declaration error * Fixing pkg/api init ossac * Account for error in tests * Update test to verify inheritance * Nits. * Place br inheritance behind a feature toggle * Parent -> Parents * Nit. Co-authored-by: Jguer <joao.guerreiro@grafana.com>
This commit is contained in:
@@ -49,6 +49,17 @@ func (r RoleType) Children() []RoleType {
|
||||
}
|
||||
}
|
||||
|
||||
func (r RoleType) Parents() []RoleType {
|
||||
switch r {
|
||||
case ROLE_EDITOR:
|
||||
return []RoleType{ROLE_ADMIN}
|
||||
case ROLE_VIEWER:
|
||||
return []RoleType{ROLE_EDITOR, ROLE_ADMIN}
|
||||
default:
|
||||
return nil
|
||||
}
|
||||
}
|
||||
|
||||
func (r *RoleType) UnmarshalJSON(data []byte) error {
|
||||
var str string
|
||||
err := json.Unmarshal(data, &str)
|
||||
|
||||
Reference in New Issue
Block a user