permissions

package
v0.7.0 Latest Latest
Warning

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

Go to latest
Published: Sep 24, 2026 License: GPL-3.0, LGPL-3.0 Imports: 13 Imported by: 0

Documentation

Overview

Package permissions handles peer user detection and permissions.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func WithUnixPeerCreds

func WithUnixPeerCreds() grpc.ServerOption

WithUnixPeerCreds returns a ServerOption that sets credentials for server connections.

func Z_ForTests_DefaultCurrentUserAsRoot

func Z_ForTests_DefaultCurrentUserAsRoot()

Z_ForTests_DefaultCurrentUserAsRoot mocks the current user as root for the permission manager.

nolint:revive,nolintlint // We want to use underscores in the function name here.

func Z_ForTests_IdempotentPermissionError

func Z_ForTests_IdempotentPermissionError(msg string) string

Z_ForTests_IdempotentPermissionError strips the UID from gRPC peer credential messages (format: "uid: <number>, pid: <number>") to make test output deterministic regardless of which user runs the tests.

nolint:revive,nolintlint // We want to use underscores in the function name here.

Types

type Manager

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

Manager is an abstraction of permission process.

func New

func New(args ...Option) Manager

New returns a new Manager.

func (Manager) CheckRequestIsFromRoot

func (m Manager) CheckRequestIsFromRoot(ctx context.Context) (err error)

CheckRequestIsFromRoot checks if the current gRPC request is from a root user and returns an error if not. The pid and uid are extracted from peerAuthInfo in the gRPC context.

type Option

type Option func(*options)

Option represents an optional function to override Manager default values.

func Z_ForTests_WithCurrentUserAsRoot

func Z_ForTests_WithCurrentUserAsRoot() Option

Z_ForTests_WithCurrentUserAsRoot returns an Option that sets the rootUID to the current user's UID.

nolint:revive,nolintlint // We want to use underscores in the function name here.

Jump to

Keyboard shortcuts

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