host

package
v0.5.1 Latest Latest
Warning

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

Go to latest
Published: Aug 10, 2026 License: Apache-2.0 Imports: 50 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

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GetErrorResponseWriter

func GetErrorResponseWriter(w http.ResponseWriter) *errorResponseWriter

Types

type AnalysisCache

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

AnalysisCache stores the results of the InferenceEngine for a short period so that the redirected user can view the report.

func NewAnalysisCache

func NewAnalysisCache() *AnalysisCache

func (*AnalysisCache) Get

func (*AnalysisCache) Store

func (ac *AnalysisCache) Store(result *sniffer.AnalysisResult) string

type CheckRequest added in v0.2.9

type CheckRequest struct {
	Checks []string `json:"checks"`
}

type CheckResponse added in v0.2.9

type CheckResponse struct {
	Passed []string `json:"passed"`
}

type FeedbackTheme

type FeedbackTheme struct {
	// CLI Colors (ANSI)
	CLIHeader  string
	CLISuccess string
	CLIWarning string
	CLIDim     string
	CLILineNum string
	CLIReset   string

	// HTML Colors (CSS)
	BgPage        string
	BgSidebar     string
	BgCard        string
	BgCode        string
	Border        string
	TextPrimary   string
	TextSecondary string
	TextAccent    string
	TextLint      string
	TextCode      string
	MethodGet     string
	MethodPost    string
	MethodPut     string
	MethodDelete  string
	BtnSuccess    string
	BtnHover      string
}

type HostHandler

type HostHandler struct {
	Mux          *http.ServeMux
	Name         string
	Namespace    string
	Pages        *page.PageStore
	Translations Translations
	// contains filtered or unexported fields
}

func NewHostHandler

func NewHostHandler(c client.Client, name string, namespace string, log logr.Logger, cacheManager cache.CacheManager) *HostHandler

func (*HostHandler) AddOrUpdateTranslation

func (hh *HostHandler) AddOrUpdateTranslation(name string, translation *kdexv1alpha1.KDexTranslationSpec)

func (*HostHandler) AddOrUpdateUtilityPage

func (hh *HostHandler) AddOrUpdateUtilityPage(ph page.PageHandler)

func (*HostHandler) BuildMenuEntries

func (hh *HostHandler) BuildMenuEntries(
	ctx context.Context,
	entry *render.PageEntry,
	l *language.Tag,
	isDefaultLanguage bool,
	parent *page.PageHandler,
)

func (*HostHandler) CheckHandler added in v0.2.9

func (hh *HostHandler) CheckHandler(w http.ResponseWriter, r *http.Request)

func (*HostHandler) Checksum added in v0.2.7

func (hh *HostHandler) Checksum() string

func (*HostHandler) DesignMiddleware

func (hh *HostHandler) DesignMiddleware(next http.Handler) http.Handler

func (*HostHandler) FootScriptToHTML

func (hh *HostHandler) FootScriptToHTML(handler page.PageHandler) string

func (*HostHandler) GeneratePageCacheKey added in v0.2.7

func (hh *HostHandler) GeneratePageCacheKey(ph page.PageHandler, l language.Tag) string

func (*HostHandler) GetCacheManager

func (hh *HostHandler) GetCacheManager() cache.CacheManager

func (*HostHandler) GetOpenAPIBuilder

func (hh *HostHandler) GetOpenAPIBuilder() *ko.Builder

func (*HostHandler) GetStatus

func (hh *HostHandler) GetStatus() HostStatus

func (*HostHandler) GetUtilityPageHandler

func (hh *HostHandler) GetUtilityPageHandler(name kdexv1alpha1.KDexUtilityPageType) page.PageHandler

func (*HostHandler) HeadScriptToHTML

func (hh *HostHandler) HeadScriptToHTML(handler page.PageHandler) string

func (*HostHandler) InspectHandler

func (hh *HostHandler) InspectHandler(w http.ResponseWriter, r *http.Request)

InspectHandler serves the feedback UI

func (*HostHandler) IsAuthEnabled added in v0.2.10

func (hh *HostHandler) IsAuthEnabled() bool

func (*HostHandler) L10nRender

func (hh *HostHandler) L10nRender(
	handler page.PageHandler,
	pageMap map[string]any,
	l language.Tag,
	extraTemplateData map[string]any,
	translations *Translations,
) (string, error)

func (*HostHandler) L10nRenders

func (hh *HostHandler) L10nRenders(
	handler page.PageHandler,
	pageMaps map[language.Tag]map[string]any,
	translations *Translations,
) map[string]string

func (*HostHandler) LoginGet

func (hh *HostHandler) LoginGet(w http.ResponseWriter, r *http.Request)

func (*HostHandler) LoginPost

func (hh *HostHandler) LoginPost(w http.ResponseWriter, r *http.Request)

func (*HostHandler) LogoutPost

func (hh *HostHandler) LogoutPost(w http.ResponseWriter, r *http.Request)

func (*HostHandler) MetaToString

func (hh *HostHandler) MetaToString(handler page.PageHandler, l language.Tag) string

func (*HostHandler) NavigationGet

func (hh *HostHandler) NavigationGet(w http.ResponseWriter, r *http.Request)

func (*HostHandler) OpenAPIGet

func (hh *HostHandler) OpenAPIGet(w http.ResponseWriter, r *http.Request)

func (*HostHandler) RebuildMux

func (hh *HostHandler) RebuildMux()

func (*HostHandler) RemovePage added in v0.2.19

func (hh *HostHandler) RemovePage(name string)

func (*HostHandler) RemoveTranslation

func (hh *HostHandler) RemoveTranslation(name string)

func (*HostHandler) RemoveUtilityPage

func (hh *HostHandler) RemoveUtilityPage(name string)

func (*HostHandler) SchemaGet

func (hh *HostHandler) SchemaGet(w http.ResponseWriter, r *http.Request)

func (*HostHandler) SchemaListGet added in v0.2.30

func (hh *HostHandler) SchemaListGet(w http.ResponseWriter, r *http.Request)

func (*HostHandler) SecuritySchemes

func (hh *HostHandler) SecuritySchemes() *openapi.SecuritySchemes

func (*HostHandler) ServeHTTP

func (hh *HostHandler) ServeHTTP(w http.ResponseWriter, r *http.Request)

func (*HostHandler) SetHost

func (hh *HostHandler) SetHost(
	ctx context.Context,
	host *kdexv1alpha1.KDexHostSpec,
	status *kdexv1alpha1.KDexObjectStatus,
	packageReferences []kdexv1alpha1.PackageReference,
	themeAssets []kdexv1alpha1.Asset,
	scripts []kdexv1alpha1.ScriptDef,
	importmap string,
	paths map[string]ko.PathInfo,
	functions []kdexv1alpha1.KDexFunction,
	authExchanger *auth.Exchanger,
	authConfig *auth.Config,
	scheme string,
	snif *sniffer.RequestSniffer,
	reconcileTime time.Time,
)

TODO: add individual cache configurations

func (*HostHandler) SetProxyTimeouts added in v0.2.78

func (hh *HostHandler) SetProxyTimeouts(t ProxyTimeouts) *HostHandler

SetProxyTimeouts replaces the HostHandler's proxy transport timeouts. Method-chain return makes it composable with NewHostHandler. Zero-valued fields fall back to defaults inside newProxyTransport.

func (*HostHandler) ThemeAssetsToString

func (hh *HostHandler) ThemeAssetsToString() string

func (*HostHandler) TransferGet added in v0.4.20

func (hh *HostHandler) TransferGet(w http.ResponseWriter, r *http.Request)

TransferGet redeems a /-/transfer/<handle> capability: resolve the handle, spend one budget unit, inject the stored identity, and re-dispatch the bound target through the mux (which runs the proxy identity gate + per-op security against the injected entitlements). All non-redeemable cases return an identical 410 to preserve anti-enumeration.

func (*HostHandler) TranslationGet

func (hh *HostHandler) TranslationGet(w http.ResponseWriter, r *http.Request)

type HostStatus

type HostStatus string
const (
	HostStatusInitializing HostStatus = "Initializing"
	HostStatusReady        HostStatus = "Ready"
	HostStatusDegraded     HostStatus = "Degraded"
	HostStatusProgressing  HostStatus = "Progressing"
)

type KDexFunctionHandler

type KDexFunctionHandler struct {
	Function *kdexv1alpha1.KDexFunction
	Handler  http.Handler
	// contains filtered or unexported fields
}

func (*KDexFunctionHandler) ServeHTTP

func (h *KDexFunctionHandler) ServeHTTP(w http.ResponseWriter, r *http.Request)

type MintRequest added in v0.2.9

type MintRequest struct {
	// Action is the action of the tokens to mint (metadata-based revocation).
	Action string `json:"act"`
	// Audience is the audience of the tokens to mint (metadata-based revocation).
	Audience string `json:"aud"`
	// Scope is the scope of the tokens to mint (metadata-based revocation).
	Scope string `json:"scp"`
	// Sub is the subject of the tokens to mint (metadata-based revocation).
	Sub string `json:"sub"`
	// TTL is the duration for which the tokens should be valid (metadata-based revocation).
	// Default: 24h.
	TTL string `json:"ttl"`
}

type MintResponse added in v0.2.9

type MintResponse struct {
	Token string `json:"token"`
}

type MintTokenRequest added in v0.4.0

type MintTokenRequest struct {
	Entitlements []string        `json:"entitlements"`
	TTLSeconds   int             `json:"ttl_seconds,omitempty"`
	Uses         int             `json:"uses,omitempty"`
	Delivery     string          `json:"delivery,omitempty"`
	Target       *TransferTarget `json:"target,omitempty"`
}

MintTokenRequest is the argument shape of the mint_token MCP tool.

type MintTokenResult added in v0.4.0

type MintTokenResult struct {
	Token         string   `json:"token,omitempty"`
	URL           string   `json:"url,omitempty"`
	ExpiresAt     int64    `json:"expires_at"`
	Entitlements  []string `json:"entitlements"`
	UsesRemaining int      `json:"uses_remaining"`
}

MintTokenResult is the mint_token success payload.

type OAuth2Resource added in v0.3.0

type OAuth2Resource struct {
	BasePath string
	Resource string
	Scopes   []string
}

OAuth2Resource describes a KDexFunction basePath that an operation has opted into protecting with the built-in "oauth2" security scheme.

type ProtectedResourceMetadata added in v0.3.0

type ProtectedResourceMetadata struct {
	Resource               string   `json:"resource"`
	AuthorizationServers   []string `json:"authorization_servers"`
	ScopesSupported        []string `json:"scopes_supported,omitempty"`
	BearerMethodsSupported []string `json:"bearer_methods_supported,omitempty"`
}

ProtectedResourceMetadata is the RFC 9728 OAuth 2.0 Protected Resource Metadata document.

type ProxyTimeouts added in v0.2.78

type ProxyTimeouts struct {
	// DialTimeout caps the connection-establishment phase (TCP + TLS).
	DialTimeout time.Duration
	// ResponseHeaderTimeout caps the wait between sending the request and
	// receiving the first response byte from the backend. This is the knob
	// that matters for scale-from-zero Knative cold starts.
	ResponseHeaderTimeout time.Duration
	// IdleConnTimeout caps how long an unused keep-alive connection lingers
	// in the transport's pool before being closed.
	IdleConnTimeout time.Duration
}

ProxyTimeouts holds the http.Transport timeout knobs used when proxying to KDexFunction backends. Zero-value fields fall back to defaults at transport-construction time (see newProxyTransport in proxy.go), so callers can leave any subset unset.

type RevokeRequest added in v0.2.30

type RevokeRequest struct {
	// Action is the action of the tokens to revoke (metadata-based revocation).
	Action string `json:"act"`
	// Audience is the audience of the tokens to revoke (metadata-based revocation).
	Audience string `json:"aud"`
	// Sub is the subject of the tokens to revoke (metadata-based revocation).
	Sub string `json:"sub"`
	// TTL is the duration for which the revocation should be persisted in the cache (metadata-based revocation).
	// Default: 24h.
	TTL string `json:"ttl"`
	// Token is the full signed token to revoke.
	Token string `json:"token"`
}

RevokeRequest is the request body for the token revocation endpoint.

type RevokeResponse added in v0.2.30

type RevokeResponse struct {
	// Status is the result of the revocation request.
	Status string `json:"status"`
}

RevokeResponse is the response body for the token revocation endpoint.

type TransferTarget added in v0.4.20

type TransferTarget struct {
	Method string `json:"method"`
	Path   string `json:"path"`
}

TransferTarget is the single concrete operation a delivery:"url" capability authorizes. Download-only in this release: Method must be GET.

type Translations

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

func NewTranslations

func NewTranslations(defaultLanguage string, translations map[string]kdexv1alpha1.KDexTranslationSpec) (*Translations, error)

func (*Translations) Catalog

func (t *Translations) Catalog() *catalog.Builder

func (*Translations) Keys

func (t *Translations) Keys() []string

func (*Translations) Languages

func (t *Translations) Languages() []language.Tag

type VerifyRequest added in v0.2.9

type VerifyRequest struct {
	Token string `json:"token"`
}

type WhoamiResult added in v0.5.1

type WhoamiResult struct {
	Identity          string   `json:"identity"`
	Name              string   `json:"name,omitempty"`
	GivenName         string   `json:"given_name,omitempty"`
	FamilyName        string   `json:"family_name,omitempty"`
	PreferredUsername string   `json:"preferred_username,omitempty"`
	Entitlements      []string `json:"entitlements"`

	// EntitlementsWithheld reports that the credential currently presented
	// carries FEWER entitlements than the user effectively holds, so some of
	// the entitlements listed here cannot be exercised with it. Set whenever
	// the two differ — including for a deliberately attenuated capability
	// token, where it is expected rather than a misconfiguration.
	EntitlementsWithheld bool `json:"entitlements_withheld,omitempty"`

	// Hint is a short actionable explanation, present only when something is
	// actionable.
	Hint string `json:"hint,omitempty"`
}

WhoamiResult is the whoami success payload.

It describes what the USER can do. whoami is a reporting tool and hands out no authority by answering, so it reports effective entitlements rather than whatever the credential in hand happens to carry — see applyEffectiveEntitlements.

Identity and Entitlements are MANDATORY: whatever the scope, a caller must always learn who the server thinks they are and what they may do — that is the entire purpose of the tool. Identity falls back to the subject, which every credential carries, and an empty entitlement set serializes as `[]` rather than being dropped so a client can iterate without a nil check.

The profile fields ARE omitempty, and that is the privacy contract: they are scope-controlled claim families (see Signer.confineByScope), so absent means "this credential was not granted it" — which is information an empty string would not convey.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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