Documentation
¶
Overview ¶
Package keyoprbac is the rbac policy of the object configuration keywords: which of them a user holding no root grant may set, and with which values.
The policy is a table rather than a function body because two callers need it. The api enforces it on every keyword of a configuration a user sends, and the keyword documentation explains it, so a keyword whose rule lives here is documented and enforced from one text: neither can drift from the other, and a driver keyword added later needs no edit in a second place to be documented.
Index ¶
- func Denied(grants rbac.Grants, kind naming.Kind, section, option, value string, ...) error
- func DeniedByDriver(grants rbac.Grants, kind naming.Kind, section, option, value, typ string, ...) error
- func DeniedUnset(grants rbac.Grants, kind naming.Kind, section, option, value string, ...) error
- func Doc(kind naming.Kind, section, option string) string
- type Group
- type Rule
- type Section
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Denied ¶
Denied returns the reason these grants are not enough to set this keyword to this value, or nil when they are.
The caller has already let a user holding the root grant through, so a rule naming that grant is a refusal here. The reason is returned bare, for the caller to prefix with the operation it refuses. The set callback answers what else the section holds, for the rules that are about the setup rather than the keyword. A rule needing it and given none refuses: a check that could not run is not a check that passed.
func DeniedByDriver ¶
func DeniedByDriver(grants rbac.Grants, kind naming.Kind, section, option, value, typ string, set Section) error
DeniedByDriver returns the reason these grants are not enough to change a keyword of a section running the driver typ, or nil when they are.
The policy of a group names the keywords it guards, and the type is guarded by value: the container group opens the types an engine confines, and says nothing of the keywords only the other types read, as the rcmd of a kvm or the command of a task running on the node. Root writing such a section does not make those keywords the namespace administrator's: a section running a driver the writer may not choose is root's whole, but for the common keywords, which are about the lifecycle of the object and not what the resource takes from the node.
A kvm section is opened by its type, and answers keyword by keyword: see kvmKeywords.
typ is the driver the section runs where the keyword changed, the one its group falls back to when it names none, and "" when it runs none. value is what the keyword takes there.
func DeniedUnset ¶
func DeniedUnset(grants rbac.Grants, kind naming.Kind, section, option, value string, set Section) error
DeniedUnset returns the reason these grants are not enough to take this keyword away from this value, or nil when they are. A keyword a user may not set is one they may not unset either, but for a keyword om writes the record of what it gave in.
Types ¶
type Group ¶
type Group struct {
// KindRules is what the policy says about the keywords of one object
// kind, for a keyword one kind gives a reach another does not. A pg
// limit set on a namespace caps every object of that namespace, where
// the same keyword on a service caps that service alone.
//
// A kind naming a keyword here answers for it, whatever Rules says.
KindRules map[naming.Kind]map[string]Rule
// Rules is what the policy says about the keywords it names. A zero
// Rule is a keyword any user may set, which is how a group whose
// Default asks for a grant opens a few of its keywords.
Rules map[string]Rule
// Default is the rule of every keyword the group does not name. A nil
// Default leaves them to any user, which suits a group whose keywords
// describe what the object runs. A group whose keywords describe what
// the object takes from the node names a Default instead, so a
// keyword added to one of its drivers later is refused until the
// policy has weighed it.
Default *Rule
// KindDefaults is Default for the kinds it names, for a group whose
// sections mean one thing on one kind and another on the next. A
// volume section of a service is the consumer asking a pool for
// storage; the same section of a volume is part of the storage.
//
// It answers for every keyword of the group on that kind except the
// ones KindRules or Rules name, and except the keywords every section
// carries, which no group takes away.
KindDefaults map[naming.Kind]*Rule
}
Group is the policy of one driver group.
type Rule ¶
type Rule struct {
// Grant is the grant a user must hold to set the keyword.
Grant rbac.Grant
// Reason ends the denial the api returns, after the keyword operation
// it refuses, and is also the sentence the keyword documentation
// shows. It is written to read after "denied: <section>.<option>=…: ".
Reason string
// Values, when not empty, is the values a user holding no grant may
// set anyway. Any other value needs the grant.
//
// A keyword converted to a list holds several values at once, so
// every value the keyword names must be in here, and a keyword
// naming none is not a keyword naming an allowed one.
Values []string
// Denies, when not nil, reports whether a value needs the grant. It
// is for the rules a value list cannot express: a shape of the value
// rather than the whole of it, or the setup the rest of the section
// describes.
//
// A rule with a Denies writes its whole sentence in Reason, values
// included, because the policy cannot derive one from a function.
Denies func(value string, section Section) bool
// MayUnset says a user holding no grant may take the keyword away,
// whatever it holds. It is for a keyword om writes itself, as the
// record of something it gave the object: taking the record away
// gives the object nothing, while setting it chooses what it gets.
MayUnset bool
}
Rule is what the policy says about one keyword.
A rule with neither Values nor Denies needs the grant whatever the value. The two are the way a rule can be about the value instead: a keyword can be harmless with one value and a way to run arbitrary code on the node with another.
func Lookup ¶
Lookup returns the rule of a keyword, and whether the policy has one.
A keyword of a driver group the policy says nothing about has the group rule, which needs the root grant: the answer is never "no rule" because the table forgot a group. Neither is it "no rule" for a keyword of a group whose Default asks for a grant.
type Section ¶
Section answers whether an option is set in the section the keyword being checked belongs to, whatever node it is scoped to.
It is a callback because the policy is asked about one keyword at a time, while some setups are only safe or unsafe as a whole: an address a user may not choose is not a keyword of its own, it is a name set where a network to draw one from should have been.