scope

package
v1.8.2 Latest Latest
Warning

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

Go to latest
Published: Nov 11, 2026 License: MIT Imports: 1 Imported by: 0

Documentation

Overview

Package scope provides context-based request scoping for Vault operations. It extracts and injects identifiers (app ID, tenant ID, user ID, IP) used across secrets, flags, config, and audit.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func FromContext

func FromContext(ctx context.Context) (appID, tenantID, userID, ip string)

FromContext extracts all scope values from the context. Missing values are returned as empty strings.

func WithAppID

func WithAppID(ctx context.Context, appID string) context.Context

WithAppID returns a new context with the given app ID.

func WithIP

func WithIP(ctx context.Context, ip string) context.Context

WithIP returns a new context with the given client IP.

func WithScope

func WithScope(ctx context.Context, appID, tenantID, userID, ip string) context.Context

WithScope returns a context with all scope values set.

func WithTenantID

func WithTenantID(ctx context.Context, tenantID string) context.Context

WithTenantID returns a new context with the given tenant ID.

func WithUserID

func WithUserID(ctx context.Context, userID string) context.Context

WithUserID returns a new context with the given user ID.

Types

type ContextKey

type ContextKey string

ContextKey is the type for context value keys used by scope.

const (
	KeyAppID    ContextKey = "vault.app_id"
	KeyTenantID ContextKey = "vault.tenant_id"
	KeyUserID   ContextKey = "vault.user_id"
	KeyIP       ContextKey = "vault.ip"
)

Standard scope context keys. flag.ContextKey and override.contextKey are aliases of ContextKey, so a value set through the scope helpers below is the same context entry the flag engine and override resolver read under their own key names.

Jump to

Keyboard shortcuts

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