control

module
v0.49.0 Latest Latest
Warning

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

Go to latest
Published: Nov 19, 2026 License: Apache-2.0

README

Hoplock Control

Open-source control plane for managing Hoplock proxies, identities, targets, routes, and access policies.

Hoplock Control is the Policy Decision Point (PDP) for a fleet of Hoplock Proxy instances. The proxy is deliberately thin — it terminates SSH, enforces a decision, and reports what happened. Everything that makes the decision lives here, along with everything that happens afterwards: the audit record, the replayable session, and the answer to "why was I denied?".

The architecture — the two API surfaces, decisions M1–M15, package layout, and the phased delivery plan — lives in docs/PLAN.md. Read it before reading the code.

Status: early. The scaffold (prompts/implemented/0001) is in — module, package layout, licence headers, config loader, Makefile and CI — and no product behaviour ships yet: the server loads its configuration, says who it is, and starts nothing. prompts/queued/ holds the phases still to come and docs/PROTOCOL.md explains how a session picks one up and delivers it.

Where this fits

Repository Role
hoplock/proxy Enforces access. SSH proxying, channel and command controls, port-forward policy, multi-hop relay, audit events.
hoplock/control (this repo) Manages access. Proxies, targets, identities, routes, policies, audit ingest and history, API, console.
hoplock/enterprise Governs access at organisational scale. Approvals, compliance, retention, SIEM/SOAR, HA.

Hoplock Proxy + Hoplock Control is a complete system. You can self-host both and have working identity-aware infrastructure access: policy authoring and simulation, OIDC/SAML login, RBAC, time-boxed grants, a proxy fleet with configuration distribution, an audit trail you can query, and a console. That is a design constraint (PLAN M15), not a marketing line — nothing core has been held back to create a paid limitation.

Hoplock Enterprise extends this repository rather than forking it: it imports Control as a library and implements the interfaces in ext/. Control never imports Enterprise, and a test enforces it.

Two surfaces

South-bound North-bound
Who calls it Hoplock Proxy instances operators, CI, the console
What for authenticate, authorize + route, host keys, log ingest, revocation stream, config distribution policy authoring and simulation, "explain this decision", time-boxed grants, inventory, audit query, fleet health
Auth bearer token → mTLS OIDC (humans) + scoped API tokens (automation)
Constraint a user's SSH handshake is held open while it answers interactive latency, rich responses

They never share a listener. A proxy token that could reach a policy-authoring endpoint would be an escalation from "may ask about decisions" to "may author them" (PLAN M2).

On the north-bound side a caller never asserts its own tenant (PLAN M18). A session or a token carries the set of tenants it may act in; a tenant named in a path, a header or a query is a selector within that set, refused before a handler runs. With one tenant configured nobody has to name one at all.

The contract is upstream

The proxy↔control contract is api/control.yaml in the Hoplock Proxy repository. This repo vendors a pinned copy under contract/ and treats it as read-only and generated (PLAN M1):

  • make contract-sync REF=<ref> pulls a revision and records the upstream commit, date, and checksum in contract/UPSTREAM.
  • make contract-check fails if the local copy was edited or drifted. CI runs it as a job of its own, so the failure names itself.
  • make conform BASE_URL=... TOKEN=... EXPECT=... runs cmd/pdpconform, a black-box conformance suite, against a running implementation. CI runs it against the proxy repo's mock control server today, and against this server once it serves anything — a suite only ever run against the implementation it was written beside proves agreement with itself. See cmd/pdpconform/README.md for the expectation-file format.

A contract change starts in the proxy repo, lands there, and arrives here through contract-sync. Never the other way around.

Repository layout

Path What lives there
cmd/hoplock-control the server binary (both listeners and the operator subcommands): one call to server.Main
cmd/pdpconform black-box contract conformance suite
cmd/policyctl CLI: validate, simulate, explain, apply a policy bundle
ext/ public extension points — the seam Hoplock Enterprise implements
server/ public — how a host binary such as Hoplock Enterprise's starts Control, with its own config section and routes (ext/README.md)
ui/ management console, embedded into the binary
internal/ implementation packages (see docs/PLAN.md §3), including the forward-only SQL in internal/store/migrations/
contract/ vendored contract from the proxy repo — never edited here
deploy/ the end-to-end topology: this server, Postgres, a real proxy and a protected-zone proxy, real sshd targets (deploy/README.md)
test/e2e/ the cross-repository scenario suite that drives it (build tag e2e)
docs/ plan, session protocol, and per-phase learnings
prompts/ queued and implemented phase prompts, audits, and the cross-repo request queues (upstream/, downstream/)

Building and running

Go is the only build dependency. make lint additionally needs golangci-lint v2, built with a Go release at least as new as the go directive — it type-checks with the go/types of the Go it was compiled with, so an older linter cannot read a newer stdlib. CI pins the version that satisfies this.

make build                 # -> bin/hoplock-control
bin/hoplock-control --version   # the version Go stamps from the repository's tags

cp config.example.yaml config.yaml
make run                   # or: bin/hoplock-control --config config.yaml

config.example.yaml documents every key. Decoding is strict: a key the schema does not define is a startup error, because a typo in a security-relevant setting that boots happily is worse than one that refuses to. Your own config.yaml is gitignored — it carries a database DSN.

Useful targets (make help lists them all):

Target What it does
make build compile into bin/; VERSION=… only for a build outside a git checkout
make test unit tests with the race detector
make vet / make lint go vet, then golangci-lint
make license-check verify the per-file SPDX header on every Go file
make fmt / make tidy format sources; reconcile go.mod/go.sum
make check everything CI runs, in CI's order
make contract-check / contract-sync / conform the contract workflow above
make release-check say what merging the tree releases, and refuse a wrong version number
make release-check-guard prove the release check refuses what it must

The daemon also carries the operator commands the north-bound API does not yet cover, and the two bootstrap ones it never will — a deployment with no principals has nobody who can call an authenticated route:

bin/hoplock-control migrate                        # apply the schema; never on boot
bin/hoplock-control identity roles                 # the fixed role set and its permissions
bin/hoplock-control identity token-issue \
    --name ci --scope 'default=policy-author'      # printed once, stored as a digest
bin/hoplock-control identity role-bind \
    --group sre --role fleet-admin
bin/hoplock-control identity mapping-put --file mapping.yaml [--dry-run]
bin/hoplock-control identity connector-put --name okta --kind oidc --file okta.json
bin/hoplock-control ca show                        # the TrustedUserCAKeys to publish
bin/hoplock-control ca rotate [--compromise]       # routine, or revoke what is outstanding
bin/hoplock-control audit-verify --tenant default   # exit 1 on a break, retention seals included
bin/hoplock-control audit-retention key            # the tenant's retention key and its public half
bin/hoplock-control audit-retention rotate-key     # a new generation; older markers still verify

The end-to-end suite runs a real Hoplock Proxy against this server (deploy/README.md): make e2e builds, starts, runs and tears it down, and needs Docker, git and ssh-keygen besides Go. make vulncheck runs the govulncheck gate CI runs on every pull request.

The go directive in go.mod is a floor, not a preference: CI builds on both it and the latest stable release with GOTOOLCHAIN=local, so the floor is enforced rather than quietly satisfied by a toolchain download. It moves only when a dependency moves it.

Depending on Control

Hoplock Enterprise, and any other program built around this server, depends on a released version of github.com/hoplock/control:

go get github.com/hoplock/control@v0.1.0

A release is an immutable tag vMAJOR.MINOR.PATCH, cut by CI from a merged change, and every phase is one (docs/PLAN.md M23). Pin a release, never a pseudo-version of main and never a replace directive. A replace is fine while you develop against a local checkout, but a binary built with one is a working copy, and it reports dev rather than a version. Before you bump the pin, read what changed in CHANGELOG.md. A MINOR release contains a phase or an incompatible change to a public package, and lists every incompatible change under ### Breaking. A PATCH release contains neither. ext has no version of its own: it is released with the module.

Contributing

Read docs/PROTOCOL.md in full before doing any work. It defines how a session picks up a prompt, branches, what "done" means, and how work is handed off to the next session. docs/KICKOFF.md has the exact prompts to start a session with, including the one that answers queued cross-repo work: the downstream syncs a cross-repo change owes, and the upstream requests that turn a need this repository cannot meet into work in the repository that owns the shape — each queued as a file in prompts/downstream/ or prompts/upstream/ and answered oldest first across all three repositories. If your change touches a surface another Hoplock repository consumes — or needs one that does not exist yet — docs/CROSS-REPO-PROTOCOL.md covers that too.

Four rules are worth knowing before you read anything else:

  1. Never edit contract/ — it is vendored from the proxy repo (M1).
  2. Never import Hoplock Enterprise (M15). The dependency runs one way. If you need something from Enterprise, you need an extension point in ext/ with a real default here.
  3. 401 means deny, deliberately. Every other failure is a 5xx. A proxy turns a 401 into "access denied" for a real user, so returning one for a database timeout sends an operator to debug permissions during an outage (M11).
  4. Migrations are forward-only and every table carries the tenant column, even though the prototype is single-tenant (M12).

Directories

Path Synopsis
cmd
hoplock-control command
Command hoplock-control is the Hoplock Control server: both listeners (M2) and the operator subcommands.
Command hoplock-control is the Hoplock Control server: both listeners (M2) and the operator subcommands.
pdpconform command
Command pdpconform is the black-box conformance suite for the south-bound contract (PLAN M1).
Command pdpconform is the black-box conformance suite for the south-bound contract (PLAN M1).
policyctl command
Command policyctl is the policy lifecycle from a terminal: validate, diff, simulate, apply and explain, plus the version history and activation.
Command policyctl is the policy lifecycle from a terminal: validate, diff, simulate, apply and explain, plus the version history and activation.
Package ext is the public extension seam of Hoplock Control: the only package in this module that is importable from outside it.
Package ext is the public extension seam of Hoplock Control: the only package in this module that is importable from outside it.
internal
access
Package access owns time-boxed grants (PLAN M10): creating one, reading it, revoking it, and the requests that precede one when a Hoplock Enterprise approval workflow is registered (ext.GrantWorkflow).
Package access owns time-boxed grants (PLAN M10): creating one, reading it, revoking it, and the requests that precede one when a Hoplock Enterprise approval workflow is registered (ext.GrantWorkflow).
accessctx
Package accessctx is external access context (PLAN M16): the framework around ext.AccessContextProvider that lets a system outside Hoplock open a time-boxed, target-scoped window — by push, by probe, or by both — without that system's software becoming an unaudited access-granting API.
Package accessctx is external access context (PLAN M16): the framework around ext.AccessContextProvider that lets a system outside Hoplock open a time-boxed, target-scoped window — by push, by probe, or by both — without that system's software becoming an unaudited access-granting API.
accessctx/declarative
Package declarative is Control's own access-context provider (M16, M15): a probe and a push mapping configured rather than coded, sufficient for most scanners and ITSM systems.
Package declarative is Control's own access-context provider (M16, M15): a probe and a push mapping configured rather than coded, sufficient for most scanners and ITSM systems.
action
Package action is Control's side of the inbound action channel (0039, M15): the ext.ActionExecutor a registered ext.ActionHandler acts through, and the lifecycle that starts that handler.
Package action is Control's side of the inbound action channel (0039, M15): the ext.ActionExecutor a registered ext.ActionHandler acts through, and the lifecycle that starts that handler.
archive
Package archive feeds a registered ext.ArchiveStore everything the audit store records (0025, PLAN §7, M8): every committed record, per tenant and stream in ascending sequence, at least once, and each session capture once its record is confirmed.
Package archive feeds a registered ext.ArchiveStore everything the audit store records (0025, PLAN §7, M8): every committed record, per tenant and stream in ascending sequence, at least once, and each session capture once its record is confirmed.
audit
Package audit is the append-only, tamper-evident record: ingest that is idempotent on the client-assigned record id, the per-stream hash chain, the verifier, the query API, and retention (PLAN M8).
Package audit is the append-only, tamper-evident record: ingest that is idempotent on the client-assigned record id, the per-stream hash chain, the verifier, the query API, and retention (PLAN M8).
authoring
Package authoring is the policy lifecycle behind the north-bound surface (0019): validate, upload, diff, activate and apply a bundle, and say — before anything is published — what the fleet and the estate can actually serve.
Package authoring is the policy lifecycle behind the north-bound surface (0019): validate, upload, diff, activate and apply a bundle, and say — before anything is published — what the fleet and the estate can actually serve.
config
Package config loads the server's YAML configuration file (PLAN §8).
Package config loads the server's YAML configuration file (PLAN §8).
console
Package console serves the operator console (phases 0049–0060, PLAN M20, M21, M27): the single-page app built from ui/ into dist/, embedded in the binary so that a deployment is still one process, and served under /console/ on the north-bound listener and nowhere else.
Package console serves the operator console (phases 0049–0060, PLAN M20, M21, M27): the single-page app built from ui/ into dist/, embedded in the binary so that a deployment is still one process, and served under /console/ on the north-bound listener and nowhere else.
contract
Package contract holds the generated Go types and handler plumbing for the south-bound API vendored under contract/ (PLAN M1).
Package contract holds the generated Go types and handler plumbing for the south-bound API vendored under contract/ (PLAN M1).
credential
Package credential brokers the credentials a proxy uses to reach a target, including the SSH certificate authority (proxy D6a).
Package credential brokers the credentials a proxy uses to reach a target, including the SSH certificate authority (proxy D6a).
credential/credentialtest
Package credentialtest is a key store for tests: what a host registers as its ext.KeyStore, held in memory, with the two ways a real one fails that the certificate authority must tell apart — a key it does not hold, and a store that cannot be asked (0062).
Package credentialtest is a key store for tests: what a host registers as its ext.KeyStore, held in memory, with the two ways a real one fails that the certificate authority must tell apart — a key it does not hold, and a store that cannot be asked (0062).
daemon
Package daemon is Hoplock Control's command line and its bring-up: the daemon that serves both listeners (M2), and the operator subcommands — migrate, seed, audit-verify, audit-retention, identity and ca.
Package daemon is Hoplock Control's command line and its bring-up: the daemon that serves both listeners (M2), and the operator subcommands — migrate, seed, audit-verify, audit-retention, identity and ca.
decision
Package decision is the composition root for an authorize call: gather identity, target labels, grants, the fleet path, and connection metadata, evaluate, build the snapshot, write the decision record, and decide whether to issue a cache hint.
Package decision is the composition root for an authorize call: gather identity, target labels, grants, the fleet path, and connection metadata, evaluate, build the snapshot, write the decision record, and decide whether to issue a cache hint.
export
Package export delivers the audit store to every registered ext.AuditSink (0026, PLAN §7, M8): every committed record of every tenant, per tenant and stream in ascending sequence, at least once, from a position Control keeps in the store per sink, tenant and stream.
Package export delivers the audit store to every registered ext.AuditSink (0026, PLAN §7, M8): every committed record of every tenant, per tenant and stream in ascending sequence, at least once, from a position Control keeps in the store per sink, tenant and stream.
extdefault
Package extdefault is Control's own side of the extension seam: the implementations this repository registers into an ext.Registry before the server starts, so that a deployment with no Hoplock Enterprise present is a complete product rather than a set of holes (PLAN M15).
Package extdefault is Control's own side of the extension seam: the implementations this repository registers into an ext.Registry before the server starts, so that a deployment with no Hoplock Enterprise present is a complete product rather than a set of holes (PLAN M15).
fleet
Package fleet owns the proxy graph: enrollment, heartbeat, zones, reachability, declared capabilities, and the pathfinding that turns "user here, target there" into a route (PLAN M6, M17).
Package fleet owns the proxy graph: enrollment, heartbeat, zones, reachability, declared capabilities, and the pathfinding that turns "user here, target there" into a route (PLAN M6, M17).
httpapi
Package httpapi holds the two HTTP surfaces and nothing they share by accident.
Package httpapi holds the two HTTP surfaces and nothing they share by accident.
httpapi/north
Package north serves the operator-facing API on the north-bound listener: policy authoring and lifecycle, inventory, simulation, explanation, and audit query (PLAN M2).
Package north serves the operator-facing API on the north-bound listener: policy authoring and lifecycle, inventory, simulation, explanation, and audit query (PLAN M2).
httpapi/south
Package south serves the proxy-facing contract on the south-bound listener (PLAN M2).
Package south serves the proxy-facing contract on the south-bound listener (PLAN M2).
identity
Package identity resolves who is asking, and owns the MFA conversation end to end (PLAN §6, M7).
Package identity resolves who is asking, and owns the MFA conversation end to end (PLAN §6, M7).
instance
Package instance is this deployment's own identity, its health at every level it has, and the outbound registration that makes it supervisable (0046, PLAN M19).
Package instance is this deployment's own identity, its health at every level it has, and the outbound registration that makes it supervisable (0046, PLAN M19).
notify
Package notify delivers operator notifications: Control's own outbound webhook, and every ext.Notifier a host binary registered (M15).
Package notify delivers operator notifications: Control's own outbound webhook, and every ext.Notifier a host binary registered (M15).
policy
Package policy is the pure policy pipeline: parse and validate a bundle (model), compile it into a decision program (compile), and evaluate that program against a closed input vocabulary (eval).
Package policy is the pure policy pipeline: parse and validate a bundle (model), compile it into a decision program (compile), and evaluate that program against a closed input vocabulary (eval).
policy/compile
Package compile turns a validated policy bundle into a decision program (PLAN M3).
Package compile turns a validated policy bundle into a decision program (PLAN M3).
policy/eval
Package eval executes a compiled decision program and produces the decision record that explains it: the inputs seen, the rules matched, the obligations emitted, and the resulting snapshot (PLAN M4).
Package eval executes a compiled decision program and produces the decision record that explains it: the inputs seen, the rules matched, the obligations emitted, and the resulting snapshot (PLAN M4).
policy/model
Package model is the policy bundle as data: parsing, validation, and versioning of the authored document (PLAN M3).
Package model is the policy bundle as data: parsing, validation, and versioning of the authored document (PLAN M3).
provision
Package provision is Control's side of identity provisioning (0040, M15): the ext.SyncSink a registered ext.IdentitySync applies what it learned through, and the lifecycle that starts that sync.
Package provision is Control's side of identity provisioning (0040, M15): the ext.SyncSink a registered ext.IdentitySync applies what it learned through, and the lifecycle that starts that sync.
report
Package report serves every registered ext.ReportProvider (PLAN M15, §7 "Reports"): it lists what each provider offers a tenant, and generates one report on request.
Package report serves every registered ext.ReportProvider (PLAN M15, §7 "Reports"): it lists what each provider offers a tenant, and generates one report on request.
revoke
Package revoke owns the event bus that fans an operator action out to every proxy that needs it: subscriptions, event ids, the replay buffer, and the resync answer when a subscriber has fallen too far behind (PLAN M9).
Package revoke owns the event bus that fans an operator action out to every proxy that needs it: subscriptions, event ids, the replay buffer, and the resync answer when a subscriber has fallen too far behind (PLAN M9).
standing
Package standing places and lifts the standing denials Control applies above the policy engine: a subject lock and a target quarantine (PLAN M28).
Package standing places and lifts the standing denials Control applies above the policy engine: a subject lock and a target quarantine (PLAN M28).
store
Package store holds the Postgres repositories and the forward-only SQL migrations that back them (PLAN M13).
Package store holds the Postgres repositories and the forward-only SQL migrations that back them (PLAN M13).
store/migrations
Package migrations holds the forward-only SQL that builds the Postgres schema, embedded so that the server is one binary with nothing to install beside it (PLAN §3, M13).
Package migrations holds the forward-only SQL that builds the Postgres schema, embedded so that the server is one binary with nothing to install beside it (PLAN §3, M13).
store/storetest
Package storetest is the Postgres-backed test harness every phase from 0003 onwards builds its store fixtures with.
Package storetest is the Postgres-backed test harness every phase from 0003 onwards builds its store fixtures with.
Package server starts Hoplock Control from a host binary (M15).
Package server starts Hoplock Control from a host binary (M15).
ui
e2e/fixture/host command
Command host is the server the console's browser checks run against (0050, 0055, 0056): Hoplock Control exactly as hoplock-control is, plus one identity sync and the extensions in extensions.go, registered in the host's registry as a host registers its own (M15).
Command host is the server the console's browser checks run against (0050, 0055, 0056): Hoplock Control exactly as hoplock-control is, plus one identity sync and the extensions in extensions.go, registered in the host's registry as a host registers its own (M15).

Jump to

Keyboard shortcuts

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