Skip to content
Role Management

Role Management

Role Management creates and maintains roles. A role bundles permissions; users which are members of a role get all of its permissions. Role memberships are managed in User Management.

Roles

Enable

roles := std.Must(cfg.RoleManagement()) // application.RoleManagement

Role Management is always enabled, because User Management depends on it. It has the fields UseCases role.UseCases and Pages uirole.Pages with the paths Roles and Role.

System roles

Declare roles which your application needs with DeclareSystemRole:

err := cfg.DeclareSystemRole(role.Role{
	ID:          "my.app.librarian",
	Name:        "Librarian",
	Description: "Manages the book inventory.",
}, PermCreateBook, PermDeleteBook)

The call is idempotent and needs a stable ID. Name and description are only written when the role is created, afterwards they belong to the operator. The permissions are a minimum: permissions which an administrator adds are kept. A system role cannot be deleted and its permissions cannot be replaced in the UI, but users can be assigned to it as usual.

Use cases

Use caseDescription
FindByIDLoads a role.
FindAllLists all roles.
CreateCreates a role.
UpdateUpdates a role, the system flag cannot be changed.
UpsertCreates or updates a role by its ID.
DeleteDeletes a role, system roles are refused.
FindMyRolesLists the roles the subject is a member of.
ListPermissionsLists the permissions of a role.
UpdatePermissionsReplaces the permissions of a role, refused for system roles.
UpsertPermissionsAdds permissions to a role and never removes any.

The events role.Updated and role.Deleted are published.

Permissions

PermissionAllows to
nago.role.find_by_idview a role
nago.role.find_alllist all roles
nago.role.createcreate roles
nago.role.updateupdate roles
nago.role.deletedelete roles

UI

admin/iam/roles lists the roles, admin/iam/roles/role?role=<id> edits a role and its permissions. The admin center shows the card Rollen in the group Nutzerverwaltung.

Related