Help us shape the future of Go! Take the 2026 Go Developer Survey

tenancy

package
v0.1.0-rc.1 Latest Latest
Warning

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

Go to latest
Published: Sep 9, 2026 License: Apache-2.0 Imports: 3 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrNoMembership      = errors.New("no tenant membership")
	ErrAmbiguousTenant   = errors.New("ambiguous tenant membership")
	ErrInvalidMembership = errors.New("invalid tenant membership")
)

Functions

func WithContext

func WithContext(ctx context.Context, tenant *Context) context.Context

WithContext stores a resolved tenant context in a context.Context.

Types

type Context

type Context struct {
	TenantID           string
	ExternalIdentityID string
	Roles              []string
}

Context is the resolved tenant scope for one authenticated request.

func FromContext

func FromContext(ctx context.Context) (*Context, bool)

FromContext returns the resolved tenant scope when present.

func Resolve

func Resolve(externalIdentityID string, memberships []Membership) (*Context, error)

Resolve converts memberships for one external identity into a single tenant scope. Multiple memberships are allowed only when they all belong to the same tenant. Roles are deduplicated and sorted. Any ambiguity fails closed.

type Membership

type Membership struct {
	TenantID string
	Role     string
}

Membership is the provider-neutral membership input used during resolution.

Jump to

Keyboard shortcuts

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