Documentation
¶
Overview ¶
Package authz decides what an operator may do, once auth has decided who they are.
Permissions are closed: each one names something the code actually checks, so one that nothing enforces cannot be invented. Roles are open: a role is a name for a set of permissions, and that is configuration.
Index ¶
Constants ¶
const ( Viewer = "viewer" Operator = "operator" Admin = "admin" Owner = "owner" )
The roles a new tenant starts with. They are seeded, not enforced: a deployment is free to change or remove any of them.
const Least = "viewer"
Least is what somebody holds in a tenant when their membership states no role: belonging without a role stated is belonging as a viewer.
Variables ¶
var ( // ErrDenied is what a handler turns into a refusal. ErrDenied = errors.New("the role does not allow that") // ErrUnknownPermission guards against storing a permission nothing checks, // which would look granted and do nothing. ErrUnknownPermission = errors.New("no such permission") )
Functions ¶
func Described ¶
func Described() map[Permission]string
Described is every permission with what granting it allows, so a role can be built without reading the code.
func Known ¶
func Known(permission Permission) bool
Types ¶
type Group ¶
type Group struct {
Area string
Permissions []Permission
}
Group is one area with everything it allows.
type Permission ¶
type Permission string
const ( EventsRead Permission = "events.read" EventsReplay Permission = "events.replay" EventsForce Permission = "events.force" RoutesRead Permission = "routes.read" RoutesWrite Permission = "routes.write" VerificationRead Permission = "verification.read" VerificationWrite Permission = "verification.write" OperatorsRead Permission = "operators.read" OperatorsWrite Permission = "operators.write" RolesWrite Permission = "roles.write" TenantsWrite Permission = "tenants.write" )
func All ¶
func All() []Permission
func (Permission) Action ¶
func (p Permission) Action() string
func (Permission) Area ¶
func (p Permission) Area() string
Area is the part of Charon a permission is about, and Action is what it allows there. Splitting the name is how the panel groups them instead of listing ten strings in a row.
type Role ¶
type Role struct {
Name string
Description string
// BuiltIn marks the roles shipped with the project. They are editable like
// any other; the flag only lets the panel say so.
BuiltIn bool
Grants []Permission
}
Role is a name and what it allows. It is data: a deployment defines its own.
func Everything ¶
func Everything() Role
Everything is what a system administrator holds: not a role stored anywhere, because a role belongs to a tenant and this deliberately does not.
func (Role) Allows ¶
func (r Role) Allows(permission Permission) bool
func (Role) Authorize ¶
func (r Role) Authorize(permission Permission) error