modelaccesspolicy

package
v0.25.1 Latest Latest
Warning

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

Go to latest
Published: Aug 3, 2026 License: MIT Imports: 15 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func IsAllowedDefaultModelAlias added in v0.25.0

func IsAllowedDefaultModelAlias(alias string) bool

IsAllowedDefaultModelAlias reports whether alias can be granted by a model access policy.

func IsAllowedModelUsage added in v0.25.0

func IsAllowedModelUsage(usage types.ModelUsage) bool

IsAllowedModelUsage reports whether usage can be granted by a model access policy.

func IsInvalidModelResource added in v0.25.0

func IsInvalidModelResource(err error) bool

IsInvalidModelResource reports whether err identifies a model resource that cannot be used in a model access policy.

func ValidateModelResource added in v0.25.0

func ValidateModelResource(
	ctx context.Context,
	reader kclient.Reader,
	namespace string,
	resource types.ModelResource,
) error

ValidateModelResource validates one model access policy resource.

func ValidateModelResources added in v0.25.0

func ValidateModelResources(
	ctx context.Context,
	reader kclient.Reader,
	namespace string,
	resources []types.ModelResource,
) error

ValidateModelResources validates all explicit models and default aliases in a policy. Wildcard selectors are allowed because they are selection rules rather than concrete model additions.

Types

type Helper

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

func NewHelper

func NewHelper(ctx context.Context, backend backend.Backend) (*Helper, error)

func (*Helper) GetUserAllowedModels

func (h *Helper) GetUserAllowedModels(user kuser.Info) (map[string]bool, bool, error)

GetUserAllowedModels returns the model IDs that a user can access. Model access policies only grant models with an allowed usage, including when a policy contains a wildcard or suffix selector.

func (*Helper) GetUserAllowedTargetModels added in v0.23.0

func (h *Helper) GetUserAllowedTargetModels(user kuser.Info, provider, dialect string) (allowed map[string]bool, allowAll bool, _ error)

GetUserAllowedTargetModels returns the set of provider-native target model ids (v1.Model.Spec.Manifest.TargetModel) for provider that the user is allowed to use. When dialect is non-empty, only models using that dialect are returned. A target is included iff a configured, active model maps to it and the user is allowed that model. This mirrors the access check enforced by the LLM passthrough: a target appears here iff a request for it would succeed.

allowAll reports that the user may use every model without a usage restriction. Policy wildcards are enumerated by GetUserAllowedModels instead, so they only include eligible usages. When dialect is empty and allowAll is true, there is nothing to enumerate, so the returned map is nil and callers should skip filtering rather than treat the nil map as "allow nothing". A dialect filter always returns an enumerated target set and allowAll=false.

func (*Helper) ResolveModelReference added in v0.25.0

func (h *Helper) ResolveModelReference(ctx context.Context, client kclient.Client, namespace, provider, reference string) (*v1.Model, error)

ResolveModelReference resolves a model reference for provider. References may be default model aliases, Model resource names, or provider-native target model IDs. Alias and resource references take precedence over target IDs.

func (*Helper) UserHasAccessToModel

func (h *Helper) UserHasAccessToModel(user kuser.Info, modelID string) (bool, error)

UserHasAccessToModel returns true if the user has access to the model. Access is granted when: - The user is an admin or owner - A ModelAccessPolicy with wildcard subject selector (*) includes the model (or uses wildcard model selector) - A ModelAccessPolicy directly references the user and includes the model (or uses wildcard model selector) - A ModelAccessPolicy references a group the user belongs to and includes the model (or uses wildcard model selector)

Jump to

Keyboard shortcuts

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