RBAC: Add origin column to seed_assignment (#80326)

* RBAC: Add origin column to seed_assignment

* Add OnCall permission migration
This commit is contained in:
Gabriel MABILLE
2024-01-11 18:43:43 +01:00
committed by GitHub
parent c40b2f90ba
commit c9ac069076
2 changed files with 40 additions and 0 deletions
@@ -60,6 +60,22 @@ func ToRegistrations(pluginID, pluginName string, regs []plugins.RoleRegistratio
return res
}
// PluginIDFromName extracts the plugin ID from the role name
func PluginIDFromName(roleName string) string {
if !strings.HasPrefix(roleName, ac.PluginRolePrefix) {
return ""
}
pluginID := strings.Builder{}
for _, c := range roleName[len(ac.PluginRolePrefix):] {
if c == ':' {
break
}
pluginID.WriteRune(c)
}
return pluginID.String()
}
func roleName(pluginID, roleName string) string {
return fmt.Sprintf("%v%v:%v", ac.PluginRolePrefix, pluginID, strings.Replace(strings.ToLower(roleName), " ", "-", -1))
}