role

package
v0.3.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 27, 2026 License: MIT Imports: 6 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

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

View Source
var ErrNoRole = errors.New("no such role")

ErrNoRole is a role that neither the built-in roles nor the config have.

View Source
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 ListInput

type ListInput struct{}

ListInput is the input of roles list, which has none.

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.

func List

func List(
	_ context.Context,
	d Deps,
	_ ListInput,
) (ListOutput, error)

List is each built-in role, then each custom role of the config, by name, with what each grants.

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.

func Get

func Get(
	ctx context.Context,
	d Deps,
	in GetInput,
) (Role, error)

Get is one role, built-in or of the config, with what it grants.

Directories

Path Synopsis
Package mocks is a generated GoMock package.
Package mocks is a generated GoMock package.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL