app

package
v1.76.10 Latest Latest
Warning

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

Go to latest
Published: Oct 15, 2026 License: MIT Imports: 51 Imported by: 0

Documentation

Overview

Package app assembles the directory hub from its configuration: the stores, the snapshot cache, the backends, the policy, the connectors, the recovery path and the three listeners.

It is a package rather than the body of main because this is where the service's behaviour is decided — which store, which shape of recovery, who may call the API listener, what URL the OAuth redirects are built from — and every one of those is somewhere a deployment can be quietly wrong. Four of them were, and none of it was reachable by a test while it lived in main().

The API listener carries DirectoryService for consumers on the cluster network. The console listener carries the operator services, the login routes and the consent callback, behind an authenticating gateway or behind the hub's own sign-in. `demo` gives two tenants held in memory, which need no credential and no network.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func FallbackPolicy added in v1.62.0

func FallbackPolicy(demonstration bool) (policy.Policy, error)

FallbackPolicy is what a service whose document names no policy decides by: the demonstration's policy under `demo`, and the built-in two groups otherwise. The composition root hands it to config.LoadConfig.

Types

type App

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

App is an assembled hub: three handlers and the background loops.

func New

func New(ctx context.Context, cfg Config, st *store.Stores, log *slog.Logger) (*App, error)

New assembles the hub. The caller runs it with App.Run and releases it with App.Close.

func (*App) Audit

func (a *App) Audit() audit.Recorder

Audit is the service's one recorder, for the half assembled after this one: both halves write one history.

func (*App) AuditQuery

func (a *App) AuditQuery() (queryURL, audience string)

AuditQuery is the audit installation's query service and the audience the console's tokens for it carry, or an empty URL when none is connected. The merged service wires it to the issuer, which mints them.

func (*App) AuditRequests

func (a *App) AuditRequests(next http.Handler) http.Handler

AuditRequests puts what an audit record keeps of each request into the context of everything next serves, with this deployment's decision on X-Forwarded-For. The merged service wraps the issuer's whole origin in it, so a token exchange records where it came from as a console call does.

func (*App) Close

func (a *App) Close()

Close releases what New opened.

func (*App) ConsoleHandler

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

ConsoleHandler is the operator listener: services, login, the SPA.

func (*App) ConsoleServer

func (a *App) ConsoleServer() *server.ConsoleServer

ConsoleServer is the console's own server, for a caller that has to finish wiring it after both halves exist.

func (*App) GitHubCatalogue

func (a *App) GitHubCatalogue() *catalogue.Catalogue

GitHubCatalogue is every GitHub App the deployment declares, for the half that mints their installation tokens under its grants.

func (*App) GitHubCatalogueApps

func (a *App) GitHubCatalogueApps() server.GitHubCatalogueApps

GitHubCatalogueApps is where created catalogue Apps and their keys are kept, or nil where the deployment keeps none: what the issuer half reads an App's key from to mint a token.

func (*App) GitHubMints

func (a *App) GitHubMints() *mints.Ring

GitHubMints is the ring of recent installation token requests, for the half that mints them to write into. The console reads the same ring: an App's page shows what this service minted without asking the audit trail for a listing narrowed to one App, which is a scan.

func (*App) HealthHandler

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

HealthHandler is liveness and readiness.

func (*App) Hub

func (a *App) Hub() *hub.Hub

Hub is the directory hub itself, for a caller that drives it directly.

func (*App) Policy

func (a *App) Policy() *policy.Set

Policy is the policy in force, for a caller that has to act on the SAME one.

The merged service loads it once and hands it to both halves. Two halves loading it independently is precisely the class of failure the merge existed to end: they read the same file today, but their fallbacks differ, so a deployment that configured neither would run a directory answering from a built-in policy and an issuer refusing to start — or worse, two policies that agree until one of them is changed.

func (*App) Readiness

func (a *App) Readiness() health.Dependency

Readiness is the snapshot store as a dependency, for a caller that assembles a health endpoint of its own. The merged service has one /readyz answering for both halves, and a half that cannot read a snapshot cannot answer anything.

func (*App) Run

func (a *App) Run(ctx context.Context) error

Run serves the three listeners and drives the hub's background loops until the context is done.

func (*App) RunLoops

func (a *App) RunLoops(ctx context.Context) error

RunLoops drives the refresher and the probes, and serves nothing.

It is what the merged service runs: one process, one set of listeners, and this half contributing its background work rather than three listeners of its own.

type Config

type Config struct {
	// Reader makes the hub only read snapshots: the directory is another
	// module's (`google.remote`), whose schedule refreshes them. No workspace is
	// adopted, attached or reopened here, and no sign-in, request or loop
	// refreshes or reads a directory. Unset keeps the hub that owns its
	// directory, which is a local install with no remote.
	Reader bool
	// GoogleIssuer and GoogleConsole reach the Google module when it is another
	// function (`google.remote`): the first signs people in (`google.identify`,
	// caller class `issuer`), the second asks it the console's questions (caller
	// class `console`). Nil is the module in this process. They are set with
	// Reader: a hub that holds no workspaces has no connector of its own.
	GoogleIssuer, GoogleConsole modcall.Caller
	// GitHubRemote, SlackRemote and CloudflareRemote say that the module runs as
	// another function (`<module>.remote`). The hub then opens none of that
	// module's stores, blobs, credentials or maintenance gate: every operation on
	// them is the module's, asked over modcall, and this process holds no access
	// to its data (v1.76 E-FIN). Unset is the module in this process, as the
	// demonstration and the tests have it.
	GitHubRemote, SlackRemote, CloudflareRemote bool
	// contains filtered or unexported fields
}

Config is the whole of the hub's configuration. The chart sets it from the values; the defaults are what a laptop needs.

Built from the service's configuration file (see FromConfig).

func FromConfig

func FromConfig(f *config.Serve, p *config.PolicyDocument) (Config, error)

FromConfig builds the hub's settings from the service document and the policy document, which the caller has already held to their schemas and checks. p is nil for the built-in policy (or the demonstration's). What a schema cannot say is checked here, before anything starts.

func (Config) AuditConfig added in v1.76.0

func (c Config) AuditConfig() audit.Config

AuditConfig is the audit configuration the legacy `audit` keys say, before the resolved adapter table is applied to it (audit.FromPlan).

func (Config) LogLevel

func (c Config) LogLevel() slog.Level

LogLevel is the level the process should log at.

Jump to

Keyboard shortcuts

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