You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I want to completely delete role2, so that policy becomes:
p, role1, data1, read
p, role1, data2, read
The problem is, DeleteRole method in enforcer only deletes grouping policies, where role is inherited by others, so I need to call RemoveFilteredGroupingPolicy(0, role) manually. I think it is a good idea to include this to DeleteRole:
// DeleteRole deletes a role.
// Returns false if the role does not exist (aka not affected).
func (e *Enforcer) DeleteRole(role string) (bool, error) {
var err error
res1, err := e.RemoveFilteredGroupingPolicy(0, role)
if err != nil {
return res1, err
}
res2, err := e.RemoveFilteredGroupingPolicy(1, role)
if err != nil {
return res1, err
}
subIndex, err := e.GetFieldIndex("p", constant.SubjectIndex)
if err != nil {
return false, err
}
res3, err := e.RemoveFilteredPolicy(subIndex, role)
return res1 || res2 || res3, err
}
The text was updated successfully, but these errors were encountered:
Marif226
changed the title
[Question] Why doesn't DeleteRole delete role completely from the table?
[Question] Why doesn't DeleteRole delete role completely from the policies?
Feb 22, 2024
Want to prioritize this issue? Try:
What's your scenario? What do you want to achieve?
Your answer here
Your model:
Your policy:
Your request(s):
I want to completely delete role2, so that policy becomes:
The problem is,
DeleteRole
method in enforcer only deletes grouping policies, where role is inherited by others, so I need to callRemoveFilteredGroupingPolicy(0, role)
manually. I think it is a good idea to include this toDeleteRole
:The text was updated successfully, but these errors were encountered: