Documentation
¶
Overview ¶
Package role is the role group of local commands: osapi controller role list and get, which read the built-in roles and the custom roles of the controller's config, with what each grants. They run in the CLI, and call no API.
Index ¶
Constants ¶
This section is empty.
Variables ¶
var ErrNoRole = errors.New("no such role")
ErrNoRole is a role that neither the built-in roles nor the config have.
var Group = command.Register(command.Define( "role", "Read the roles and what each grants", command.Under(command.ParentController), command.Uses[Deps](), command.Method[ListInput, ListOutput]("list"). Short("List the roles and the permissions each grants"). Long("The list has the permissions of each behavior, so it is correct for the\n"+ "binary that you run. A custom role from the config's\n"+ "`controller.api.security.roles` gets a column of its own. Without a config\n"+ "file it shows the built-in roles only. A behavior's permissions are\n"+ "`<name>:<verb>`, such as `dns:read` and `dns:write`. A rule gives each\n"+ "built-in role its permissions. Use this list, not a table in the docs."). Example(""). Prints(sampleRoles). Example("--json"). Handle(List), command.Method[GetInput, Role]("get"). Short("Show a role and each permission it grants"). Example("--name admin"). Prints(sampleRole). Fails("no name", GetInput{}). Handle(Get), ))
Group is the role group's definition. The commands, their flags, their help and their pages come from it. osapi dsl command spec get lists every option.
Functions ¶
This section is empty.
Types ¶
type Config ¶
type Config interface {
// CustomRoles are the roles of controller.api.security.roles, each with
// its permissions. Without a config file there are none.
CustomRoles() (authtoken.CustomRoles, error)
}
Config is what the methods read from the osapi config.
type Deps ¶
type Deps struct {
// Config is what the methods read from the osapi config.
Config Config
}
Deps is what the role group's methods use. The CLI gives it with command.Provide in cmd/commands.go; a test gives fakes.
type GetInput ¶
type GetInput struct {
Name string `json:"name" validate:"required" doc:"The role, such as admin, or a custom role of the config."`
}
GetInput names the role to read.
type ListOutput ¶
type ListOutput struct {
Roles []Role ` json:"roles"`
// contains filtered or unexported fields
}
ListOutput is each role: the built-in ones, then those of the config.
type Role ¶
type Role struct {
// Name is the role's name, such as admin.
Name string `json:"name"`
// Source is built-in, or config for a custom role of the config.
Source string `json:"source"`
// Permissions are what the role grants. roles get shows them; a table
// of roles leaves them out, because they are many.
Permissions []string `json:"permissions" table:"-"`
// contains filtered or unexported fields
}
Role is one role, with what it grants.