ui

package
v0.44.1 Latest Latest
Warning

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

Go to latest
Published: Sep 23, 2026 License: Apache-2.0 Imports: 27 Imported by: 0

Documentation

Overview

Package ui is the central UI service: a single pane of glass over the tier serves. It is a stateless aggregator — no domain state of its own — with Google OAuth login for humans (encrypted session cookie; the SPA never sees tokens) and Google OIDC service identity toward the tier serves. Routing and shapes for its JSON API come from api/ui.openapi.yaml (internal/uiapi).

Index

Constants

View Source
const SessionCookie = "tfsp_ui_session"

SessionCookie is the browser session cookie name (also named as the security scheme in api/ui.openapi.yaml).

Variables

This section is empty.

Functions

This section is empty.

Types

type App

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

App is the central UI HTTP service.

func New

func New(cfg Config) (*App, error)

New builds the App. The session secret is required — every surface except /healthz sits behind the login.

func (*App) Routes

func (a *App) Routes() http.Handler

Routes assembles the full HTTP surface: public health, the OAuth browser flow, the session-authed JSON API (generated router), and the SPA fallback.

type Config

type Config struct {
	PublicBaseURL string // external base; the OAuth redirect URI is <base>/auth/callback
	SessionSecret string
	// GitHubWebhookSecret optionally verifies GitHub App webhook deliveries
	// at the relay before fan-out (defense in depth — each serve verifies the
	// HMAC itself either way; empty forwards blindly).
	GitHubWebhookSecret string
	AllowedDomain       string // required id_token hd claim, lowercase
	// OAuth is the Google authorization-code client. Endpoint is overridable
	// so tests run against a fake token server.
	OAuth *oauth2.Config
	// QuotaProject rides x-goog-user-project on user-token PAM calls (user
	// credentials attribute API quota to the OAuth client's project; empty
	// sends no header). PAMBaseURL overrides the PAM endpoint for tests.
	QuotaProject string
	PAMBaseURL   string
	// VerifyIDToken validates the id_token from the code exchange and returns
	// its claims (signature + audience checked; claim semantics enforced by
	// the login handler). Injectable for offline tests.
	VerifyIDToken gauth.VerifyClaimsFunc
	Tiers         []Tier
}

Config carries the wiring the ui face resolves from the `ui {}` block and its env-var secrets.

type Session

type Session struct {
	Email   string    `json:"email"`
	Expires time.Time `json:"expires"`
}

Session is the server-side state carried by the encrypted cookie — identity only, no tokens (the SPA never sees Google credentials, and the UI backend stores none).

func SessionFrom

func SessionFrom(ctx context.Context) Session

SessionFrom returns the verified session riding the request context (zero value outside sessionAuth-guarded routes).

type Tier

type Tier struct {
	Name  string
	URL   string
	Token gauth.TokenFunc
}

Tier is one tier serve the UI aggregates. Token mints the Google OIDC ID tokens the tier's api_auth accepts (nil = unauthenticated — local/dev against an auth-disabled serve).

Jump to

Keyboard shortcuts

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