evalapi

package
v0.16.0 Latest Latest
Warning

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

Go to latest
Published: Nov 27, 2026 License: MIT Imports: 29 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 evalapi is the evolve-facing HTTP surface of the evaluation controller: bearer-authenticated workspace upload (streamed through to source-controller's blob cache), submission, snapshot, SSE monitoring, and cancellation, speaking the pkg/evaluation wire contract.

Authentication is OIDC bearer verification (go-oidc issuer discovery; no provider is assumed) mapping claims through the same web/auth ClaimsConfig semantics as the status server; authorization is SubjectAccessReview on the evaluations resource with native verbs only (create/get/delete), so RBAC bindings are the entire authorization surface. Mode "none" (dev/e2e) short-circuits both with a fixed identity.

The mux is plain net/http in the internal/web style: these routes are synchronous request/response plus SSE, nothing webhook-shaped.

Index

Constants

View Source
const (
	ModeNone = "none"
	ModeOIDC = "oidc"
)

Auth modes.

View Source
const (
	VerbCreate = "create"
	VerbGet    = "get"
	VerbDelete = "delete"
)

Verbs the API access-reviews on the evaluations resource.

Variables

This section is empty.

Functions

This section is empty.

Types

type Authenticator

type Authenticator interface {
	Identify(r *http.Request) (*auth.Identity, error)
}

Authenticator resolves a request to an identity. A nil identity with a nil error means no usable credential was presented (→ 401).

func NewAuthenticator

func NewAuthenticator(ctx context.Context, cfg *Config) (Authenticator, error)

NewAuthenticator builds the mode's authenticator. Mode oidc runs issuer discovery, bounded by ctx.

type BearerAuthenticator

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

BearerAuthenticator verifies Authorization: Bearer ID tokens against the configured issuer and maps claims to an identity.

func (*BearerAuthenticator) Identify

func (b *BearerAuthenticator) Identify(r *http.Request) (*auth.Identity, error)

Identify verifies the bearer token. Absent header → (nil, nil); a present but invalid token is an error.

type Config

type Config struct {
	// Mode is "none" (dev/e2e: fixed identity, authorization bypassed at
	// wiring) or "oidc".
	Mode string `yaml:"mode"`
	// OIDC configures bearer verification; required for mode oidc.
	OIDC *OIDCConfig `yaml:"oidc"`
}

Config is the evaluation API's auth configuration, a trimmed sibling of web/auth.Config: no sessions, no cookies, no client secret (evolve is a public PKCE client; the API only verifies tokens).

func LoadConfig

func LoadConfig(path string) (*Config, error)

LoadConfig reads and validates the auth config. Unlike the status server there is no unconfigured fallback: every route except auth/info is authenticated, so a missing file is a startup error.

func (*Config) AuthInfo

func (c *Config) AuthInfo() evaluation.AuthInfo

AuthInfo renders the discovery document served at /api/v1/auth/info.

type FullAccess

type FullAccess struct{}

FullAccess grants everything: the mode-none bypass.

func (FullAccess) Allowed

Allowed always says yes.

type Granter

type Granter interface {
	Allowed(ctx context.Context, id auth.Identity, verb string) (bool, error)
}

Granter answers whether an identity may verb evaluations; satisfied by authz.ResourceReviewer.

type Limits

type Limits struct {
	// MaxUnits per submission (default 200, and the CRD caps there too).
	MaxUnits int
	// MaxSubmissionBytes caps a POST body.
	MaxSubmissionBytes int64
	// MaxWorkspaceBytes caps a workspace upload.
	MaxWorkspaceBytes int64
	// MaxEvaluationBytes caps the marshalled Evaluation object (etcd's cap
	// with headroom).
	MaxEvaluationBytes int
}

Limits bound the API's request surface.

type OIDCConfig

type OIDCConfig struct {
	// IssuerURL for discovery.
	IssuerURL string `yaml:"issuerURL"`
	// ClientID the token audience must match: the public client evolve
	// logs in as.
	ClientID string `yaml:"clientID"`
	// Scopes advertised to clients via /auth/info.
	Scopes []string `yaml:"scopes"`
	// Claims maps token claims to username/groups (web/auth semantics).
	Claims auth.ClaimsConfig `yaml:"claims"`
}

OIDCConfig verifies bearer tokens against one issuer.

type Server

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

Server is the evaluation API.

func NewServer

func NewServer(c client.Client, namespace string, authn Authenticator, info evaluation.AuthInfo,
	granter Granter, workspaces WorkspaceClient, limits Limits, log *slog.Logger) *Server

NewServer builds the API server.

func (*Server) Handler

func (s *Server) Handler() http.Handler

Handler is the API mux.

func (*Server) StartWatch

func (s *Server) StartWatch(ctx context.Context, c cache.Cache) error

StartWatch wires informer events into the broker. Registered as a manager runnable; blocks until ctx is done.

type WorkspaceClient

type WorkspaceClient interface {
	Stat(ctx context.Context, digest string) (bool, error)
	Put(ctx context.Context, digest string, r io.Reader, size int64) error
}

WorkspaceClient is the blob cache surface (source-controller's internal endpoint); satisfied by *artifact.Client.

Jump to

Keyboard shortcuts

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