rbac

package
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Jul 29, 2026 License: Apache-2.0 Imports: 7 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 rbac answers what this reader may do, per context.

Every control kubeside disables is disabled because the cluster said so, not because a role name looked wrong. The question goes to the apiserver as a SelfSubjectAccessReview, which is the only authority on the answer.

The product rule this serves is "disable, never hide". A control that vanishes teaches nothing and leaves somebody wondering whether the feature exists; one that is visible, disabled, and says "needs create on pods/exec in team-a" tells them exactly what to ask for. So every denial carries the verb.

Answers resolve per context. The same control on the same screen is enabled in qa and disabled in prod within one session, because permissions are a property of the cluster and not of the tool.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Action

type Action struct {
	Verb        string
	Resource    string
	Subresource string
	Name        string
	Namespace   string
	Group       string
}

Action is one question: may I do this verb, to this resource, here.

func (Action) Key

func (a Action) Key() string

Key reads like the question it asks, so a refusal can be shown to a human. The browser also matches capability entries on its prefix, which makes the phrasing a wire contract. It is deliberately not the cache key.

type KubeReviewer

type KubeReviewer struct {
	// ClientFor returns the client for one context. A context with no client is
	// one kubeside has not connected, and an unconnected cluster cannot grant
	// anything.
	ClientFor func(contextName string) (kubernetes.Interface, bool)
}

KubeReviewer asks the apiserver, which is the only authority on what this reader may do.

func (KubeReviewer) Review

func (k KubeReviewer) Review(ctx context.Context, contextName string, a Action) (bool, error)

Review runs a SelfSubjectAccessReview.

type Permission

type Permission struct {
	Allowed bool   `json:"allowed"`
	Reason  string `json:"reason,omitempty"`
}

Permission is the answer, with the reason a denial happened.

type Resolver

type Resolver struct {
	// contains filtered or unexported fields
}

Resolver caches answers for the session.

func New

func New(r Reviewer) *Resolver

New builds a resolver.

func (*Resolver) Can

func (r *Resolver) Can(ctx context.Context, contextName string, a Action) Permission

Can answers one question, asking the cluster at most once per session.

func (*Resolver) CanAll

func (r *Resolver) CanAll(ctx context.Context, contextName string, actions []Action) map[string]Permission

CanAll answers several questions, which is what a screen actually asks.

func (*Resolver) Forget

func (r *Resolver) Forget(contextName string)

Forget drops one context's answers.

A reconnect can mean new credentials, and new credentials can mean different permissions. Keeping the old answers would disable a control the user has just earned, or worse, enable one they have not.

type Reviewer

type Reviewer interface {
	Review(ctx context.Context, contextName string, a Action) (bool, error)
}

Reviewer asks the cluster. Keeping it an interface lets the caching and the phrasing be tested without an apiserver.

Jump to

Keyboard shortcuts

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