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 ¶
const ( ModeNone = "none" ModeOIDC = "oidc" )
Auth modes.
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 ¶
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.
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 ¶
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 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.