Commit Graph

1776 Commits

Author SHA1 Message Date
Paul Lorenz 942d1a72bc Stop routers dropping controllers on a follower's stale controller list. Fixes #4573
- applies controller lists, leader announcements, controller address changes and index resets on one
  goroutine in arrival order, so checking an update's index, applying it and recording it is one
  step and no control channel's receive goroutine waits on another controller's update
- lets only a leader's list at a newer index replace the controller set; any other list at or above
  the recorded version only adds, merging into the router's stored details and connected controllers
- applies a leader's list at the recorded version as additions, so a router missing controllers
  recovers when the leader resends
- keeps an inbound controller's socket address out of the saved endpoints, and fills in a saved
  controller that has no endpoints when a later list gives some
- orders leadership claims by raft term: adds a raftTerm field to UpdateCtrlAddresses and
  UpdateClusterLeader, which controllers read together with leadership so both describe the same raft
  term; claims without one, from older controllers, still apply as they arrive
- folds the cluster leader handler into the same worker
- asks every connected controller for its list while waiting for the leader's, without waiting on a
  full send queue, one request run at a time, stopping when the router closes
- bounds the waiting updates: past the bound it drops waiting lists and announcements, keeps each
  controller's latest address change, and requests the leader's list
- fixes a router crash applying a controller's new address before any controller details were
  stored, and keeps connected controllers the router has no details for
- stops clustered controllers sending the newListener address, which the cluster's controller lists
  would undo, warns when it is configured, and notes this in the sample configs
- tests list handling, leadership ordering, overflow, the request loop, address changes and the
  controller's raft term read
- notes the fix in the changelog
2026-11-04 12:38:24 -05:00
Paul Lorenz a716939dcc Keep a service policy's posture check roles when its type changes. Fixes #4726
- writes the posture check roles back after a type change re-links the policy, as it already does for identity and service roles
- tests that a full update and a type-only patch keep the stored roles, and that a posture check created afterwards links by them
2026-11-04 11:24:11 -05:00
Paul Lorenz 6a0ed68266 Add policy write benchmarks at the store and management API levels. For #4513
- benchmarks policy-evaluating writes at 1K and 10K entities without fsync
- adds a perftests scenario driving the automation create and delete sequence through the typed management API client with concurrent clients
- adds typed management client helpers that delete services, service policies and service edge router policies
- repairs the existing perftests scenario, which no longer compiled
2026-11-04 11:24:11 -05:00
Paul Lorenz 13adb7cda8 Maintain the posture check to service tables from both sides. Fixes #4515
- feeds the posture check to service reference counts from service links as well as posture check links
- gives the service store its own view of those tables, replacing the identity tables as the reverse side
- validates the posture check pairs in the service policy integrity check
- rebuilds the tables and removes posture check ids from the services' identity tables in migration 50
- expands a service's updated event to its identities once per write, not once per posture check
2026-11-04 11:24:11 -05:00
Paul Lorenz 4d45c45aec Re-evaluate policy links when only the semantic changes. Fixes #4514
- evaluates every roles field of a policy when its semantic changes
- adds a matrix test driving every role-set and attribute-set transition for each policy type
2026-11-04 11:24:11 -05:00
Paul Lorenz f8be418b33 Evaluate policies against candidate entities and policies instead of scanning. Fixes #4513
- selects the entities a policy change can affect from its ids, the entity role attribute index and its current links
- selects the policies an entity change can affect from its current links and the policy role attribute index
- indexes the #all wildcard in the policy role attribute indexes and skips it in the role attribute usage query
- adds DB version 50, which backfills the wildcard entries
- adds transition tests across all three policy types
2026-11-04 11:24:11 -05:00
Paul Lorenz 54bfb3ca21 Return a readable 503 when an API request times out. Fixes #4509
- extends the per-request write deadline in TimeoutHandler when the server's write timeout would expire before the timeout response can be written, so clients get the 503 instead of a TLS error
- passes the server's write timeout from each API's xweb server config into TimeoutHandler through a shared helper
- carries the request context on REST change contexts and refuses to dispatch a command once that request's deadline has passed
- updates xweb to v3.0.6, whose compression middleware supports http.ResponseController and keeps the response status for Brotli
- tests timeout responses over HTTP/1.1 and h2 for each compression encoding, and the dispatcher deadline check
2026-11-03 23:29:55 -05:00
Paul Lorenz 2349cc921b Record ER/T health check cost and precedence for terminator re-creates. Fixes #4596
- records the cost and precedence a health check sends on the router's tunnel terminator, starting from the host config
- builds terminator creates and inspect output from the recorded values, so a re-created terminator keeps the health check's precedence
- notes why the controller leaves cost and precedence alone when a tunnel create targets an existing terminator
- tests that creates carry the configured values until an update replaces them, including an update that fails
2026-11-03 20:53:57 -05:00
Paul Lorenz 05a6bc23bb Reconcile terminator cost, precedence and peer data after a takeover or update. Fixes #4580
- records update bind cost and precedence on the router's terminator, so retries and reconnect re-creates carry them
- sends an update to the controller only for an established terminator with no create outstanding, and otherwise lets a create carry the values
- re-creates a terminator taken over by listener id when the new bind's cost, precedence or peer data differ
- follows a create built from values that have since changed with another create once it completes
- queues a taken-over terminator whose create had not been sent yet, rather than leaving it for the retry scan
- re-creates the terminator when an update to the controller fails
- applies peer data, along with cost and precedence, when a create targets an existing terminator, including one found after losing a concurrent create
- skips the terminator write when a create or update changes nothing, but only on a caught-up leader or a controller without raft, since a follower's copy may be stale
- sends sdk terminator updates to the leader when one is reachable, as creates already are
- dispatches a tunnel create for a terminator the controller already holds unless it is a caught-up leader, since a leader still applying a committed delete would report a deleted terminator as created
- adds router and controller tests for each of these
2026-11-03 20:53:57 -05:00
Paul Lorenz ae367195a4 Decide delete existence in Apply and add DeleteIfExists. Fixes #4571
- checks the deleting manager's own store for the target inside the delete transaction, before DeleteById, so a child store delete never reaches the parent's record of another type
- moves the edge service manager's fabric-only check from a pre-dispatch read into an ApplyDelete override
- makes IsEntityPresent on an extended child store match FindById, so a router created through the fabric is deletable through the transit router manager, which excludes edge routers explicitly
- adds a flags field to the delete command and DeleteIfExists on the base manager, under which an absent target is a no-op
- routes identity deletes through the base ApplyDelete after the admin precondition, so identities get the presence check and DeleteIfExists
- gives the API session, session and API session certificate managers a direct DeleteIfExists, since they register no delete decoder
- tests cross-type router deletes, the fabric-only check at apply time, base router deletes, and DeleteIfExists on present, absent, fabric-only, wrong-type, identity and local-only targets, at the model level and through the management API
2026-11-03 00:50:37 -05:00
Paul Lorenz 3057b1e6fe Merge pull request #4562 from openziti/identity-admin-precondition
Decide identity admin protection inside Apply, gate granular permissions on MFA, and keep the default admin an admin
2026-11-03 00:50:33 -05:00
Paul Lorenz 843cfd2375 Merge pull request #4477 from openziti/ha.reconcile-advertise-address
Reconcile the raft advertise address with the controller config on startup. Fixes #3588
2026-10-28 23:18:32 -04:00
Paul Lorenz 7f2f619e88 Reconcile the raft advertise address with the controller config on startup. Fixes #3588
- adds a startup reconcile that asks the leader to move this node's stored raft address to its configured advertise address, retrying with jittered backoff until the change is visible locally
- wakes the running reconcile on leader events instead of starting a second one, and jitters the first attempt and each wake so controllers reconciling after the same event spread their requests
- keeps checking a node whose copy of the configuration doesn't list it yet, as after a restart before any of the log reached it, instead of treating it as reconciled
- adds an UpdatePeerAddressRequest peer message carrying the member id, the address the node believes is stored and the new address; the leader accepts it only from the node it names and does not forward it
- adds updateMemberAddressAsLeader, which changes a member's address in place, keeping its suffrage, after refusing non-members, addresses held by another member and stale from addresses
- probes the new address as a sanity check, refusing the change if a different controller answers and making it with a warning if the address can't be reached, since some controllers only dial out
- conditions the update on a configuration index read from the raft log and snapshot stores, since GetConfiguration().Index() is always zero in the pinned raft version
- routes AddPeer requests that find an existing member at a new address to the in-place update instead of remove and re-add, identifying the member through GetPeerInfo rather than the request id
- falls back to the member id when the raft transport dials a stored address with no peer connected at it
- adds a probe hello header so probe connections are closed without registering a peer
- excludes self by server id in GetPeerAddresses
- corrects the inverted voter flag in the peer AddPeer log and removes the unused ctrlAddress field
- tests single-node, follower, non-voter and leader address changes, refused and unverified addresses, requests from the wrong sender, membership changes made while a member is offline or during the probe, and configuration lookup across snapshots and log gaps
- tests the reconcile starting on an empty log and waiting until the configuration lists the node
- waits in the HA test harness for a restarted peer's own configuration to list it before restarting it
- adds a changelog entry describing the address update and the leader version requirement
2026-10-28 20:54:56 -04:00
Paul Lorenz 4ba730569d Merge pull request #4532 from openziti/raft-dispatch-hardening
Validate commands on the raft leader before they enter the log
2026-10-28 20:07:52 -04:00
Paul Lorenz 9ca996e3c4 Validate commands on the raft leader before they enter the log. Fixes #4531
- decodes and validates every command in ApplyTwoPhase, the one path to Raft.Apply for local and forwarded commands, before a rate limiter slot is taken
- adds the same Validatable call to LocalDispatcher.Dispatch so non-HA controllers validate commands too
- halts a member on a committed entry it cannot decode instead of logging and advancing past it, through the hook the critical command path now shares
- passes rate limiter and validation errors from the peer handler through as they are
- states on Validatable that Validate reads only the command and local configuration
- tests the halt, the ordinary error path, the submission check and the local dispatcher
2026-10-28 19:45:24 -04:00
Paul Lorenz a827bfbe14 Carry structured API error causes across the peer channel. Fixes #4538
- maps UniqueIndexDuplicateError and ReferenceExistsError in ToApiError, so forwarded duplicate-name creates and referenced deletes return 400 and 409 from a follower instead of 500
- replaces the hand-written error switches in the create, delete, update and patch route helpers with ToApiError
- moves the peer channel API error encoding and decoding into one cause codec registry in the raft package, covering not-found, field, duplicate index, reference exists and schema validation errors
- parses both shapes ValidationErrors marshals to, one error bare or several under Reason and Errors
- sends an unregistered cause as its message on both sides instead of a raw JSON object
- tests each mapping, a round trip for every cause class, and a duplicate-name service create through the API
2026-10-28 17:22:07 -04:00
Paul Lorenz 53c05e38ed Merge pull request #4549 from openziti/swallowed-errors
Return errors from identity creation with authenticators and from name validation on update
2026-10-28 17:16:13 -04:00
Shawn Carey 7115f3ff74 Allow case-insensitive terminator addressing via host.v1 (#4528)
* add listenIdentityType field to host.v1 schema

* handle ListenOptions.ListenIdentityType for DNS

* update changelog

* schema test for listenIdentityType
2026-10-28 11:34:30 -04:00
Paul Lorenz 757e42a774 Remove the edge router API proxy. Fixes #4645
- removes the router's `edge.apiProxy` listener; a router whose config still has the section logs a warning and ignores it
- removes proxied client certificate handling from controller cert authentication, which uses only the certificates from the TLS handshake
- removes the `X-Client-CertPem` and `X-Edge-Router-Proxy-Request` header constants and the `COULD_NOT_PARSE_PROXY_CERT` error code
- removes the `apiProxy` blocks from the sample router configs
- adds a Removed Features CHANGELOG entry
2026-10-26 17:36:46 -04:00
Paul Lorenz 9a8e49af51 Merge pull request #4405 from openziti/converge-rdm-ca-intermediates
Publish first-party CA roots without intermediates. Fixes #4406
2026-10-26 12:06:18 -04:00
Paul Lorenz 43751ef84a Fix lint failures in the edge ctrl handlers and quickstart
- removes the unused baseSessionRequestContext.apiSessionLoggingFields
- returns the error when quickstart stops waiting for the controller, instead of continuing as though the controller came online
2026-10-19 13:12:13 -04:00
Paul Lorenz 3e674aadb2 Stop posture data updates deadlocking the controller database. Fixes #4611
- runs the session query and policy posture check lookup in postureDataUpdated on its open read transaction instead of opening nested ones
- adds SessionManager.queryInTx and EdgeServiceManager.getPolicyPostureChecksInTx
- tests posture updates against commits that grow the db file, holding the updater inside its transaction for each commit
- adds a changelog entry
2026-10-17 17:08:19 -04:00
Andrew Martinez 8415a7dbf6 Merge commit from fork
* The controller and the router wrote the complete service session token, an OIDC
  service session JWT or a legacy session token, into structured log fields during
  edge control operations. Several of the sites logged at Error or Info, so the
  values reached logs at default verbosity during ordinary operation.
* Adds LoggingFields to the session and api session types in common, controller/model
  and router/state, so a logging site asks for the session fields or the api session
  fields instead of picking values by hand. Ids, type, identity, service and the
  token's validity window go in; the token does not. Empty values are dropped, so the
  sets merge over each other.
* AddLoggingFields in router/state now delegates to LoggingFields. Its output moves
  from a nested field to flat prefixed keys.
* The edge control handlers log the session field set on the shared returnError and
  logResult paths, on circuit setup and on terminator update. The terminator removal
  paths log the terminator id, since they never load a session.
* Adds unit tests over returnError and logResult that fail if a session token reaches
  a log entry, covering the loaded-session, failed-to-load and JWT-claims cases.
2026-10-14 13:53:50 -04:00
Shawn Carey 8ab2bf0860 add l2 config types (#4051) 2026-10-13 14:25:41 -04:00
Paul Lorenz 566c09c7b2 Keep the default admin an admin. Fixes #4561
- rejects, in the identity store, any create or update whose result would be a default admin without admin rights
- counts an identity as admin by either flag in the apply-time admin precondition, matching how a session's permissions are resolved, so a default admin whose flag was cleared before the guard existed still has and receives admin protection
- tests the rejection on create and update, the legacy-data case at the manager level, and the rejected patch through the API
2026-10-07 14:56:34 -04:00
Paul Lorenz 50f4f016c1 Grant granular permissions only to fully authenticated sessions. Fixes #4560
- resolves an identity's granular permissions inside the fully authenticated branch, so a session with MFA pending holds only the partial authentication permission
- tests permission resolution in both states, and drives a real MFA-pending session against the management API to show it is refused until the challenge is answered
2026-10-07 14:41:09 -04:00
Paul Lorenz f86f0102b5 Decide identity admin protection inside Apply. Fixes #4559
- reads the author identity and the target inside the transaction in identity ApplyUpdate and a new ApplyDelete, refusing a non-admin author's change to an admin target with the same unauthorized error the routes produced
- exempts authors that are not identities and treats a deleted author as not admin
- stops the identity delete and patch routes from reading the target before dispatch, keeping the body-based field restriction for non-admins
- tests the refusal and permissive cases at the manager level
2026-10-07 14:29:01 -04:00
Paul Lorenz ad540d9988 Return errors from identity creation with authenticators and from name validation on update. Fixes #4548
- returns the dispatch error from CreateWithAuthenticators instead of a nil tuple, so CA and token enrollment no longer treat a failed identity create as success
- returns the ValidateNameOnUpdate error from updateEntity and updateEntityBatch, so a rename to a taken or empty name is rejected instead of silently skipped
- tests both at the manager level and the rename through the service API
2026-10-06 16:49:23 -04:00
Paul Lorenz e0a0945042 Stop disabling a connected router from deadlocking the controller. Fixes #4542
- closes a disabled router's control channel after the connected map's RemoveCb returns, rather than
  inside its callback; the channel's close handler runs DisconnectRouter synchronously, which reads
  and removes the same map entry and self-deadlocked on the shard lock, wedging the raft apply
  goroutine and every path selection behind it
- logs any error from closing the channel
- adds godoc for UpdateCachedRouter
- tests that disabling a connected router completes and tears the connection down
- notes the fix in the changelog
2026-10-06 11:23:46 -04:00
Paul Lorenz a4285af743 Deliver link listeners to every controller until written. Fixes #4456
- tracks the link listener set owed to each controller in the link registry, marked on a listener change and after each reconnect
- sends the listener set from the registry loop with wait-for-wire once the controller's reconnect link announcement is written, retrying every tick until the write succeeds, replacing the fire-and-forget send to controllers connected at the time of the change
- fences listener completions with the reconnect generation so a send that reached an earlier connection does not count for a later one
- keeps sync state for controllers absent from a controller snapshot while they still owe the listener set
- stamps the listener set sent to controllers with the config generation read in the same snapshot, matching the hello
- makes the controller skip the peer fan-out for an UpdateLinkListeners message whose set matches the one it replaced, still recording the message generation
- makes Router.SetLinkListeners return the set it held, read under the same lock as the update
2026-09-29 15:23:45 -04:00
Paul Lorenz f37ab93389 Retry the reconnect link announcement until it is written. Fixes #4453
- tracks a full link refresh owed to each controller after a reconnect, sent from the link registry loop through the rate limiter pool and retried every tick until written, instead of giving up after three attempts
- holds incremental new-link reports and faults to a connected controller until its refresh is written, so they cannot be pruned by or race ahead of the refresh, while disconnected controllers keep their existing skip and fault expiry handling
- fences refresh completions with a reconnect generation so a refresh written to an earlier connection does not satisfy a later one
- keeps sync state for controllers absent from a controller snapshot while they still owe a refresh
- snapshots the link set under the registry lock and sends outside it
- stops raft before closing the controller database on shutdown, so an in-flight apply cannot fail against a closed store and halt the process
2026-09-29 10:30:48 -04:00
Paul Lorenz 667436b3b6 Stop the controller panicking on a tunnel v2 dial to an unknown service. Fixes #4442
- uses the nil-safe getApiSessionId() in loadServiceForName, matching loadServiceForId; the v2
  tunnel circuit handler never establishes an api session, so the lookup-failure branch
  dereferenced a nil apiSession and took the controller down on any unresolvable service name
- makes the default admin check log a read failure and return instead of panicking; the check is
  advisory and runs in a goroutine that can observe a datastore the shutdown path has closed,
  turning a controlled exit into exit 2
- adds godoc for checkEdgeInitialized covering the advisory contract and the remaining fatal case
- notes both in the changelog
2026-09-28 20:51:28 -04:00
Paul Lorenz c4b5a96ab5 Merge pull request #4215 from openziti/router-link-runtime-config
Apply managed link heartbeat and queue settings at runtime
2026-09-28 17:46:38 -04:00
Paul Lorenz 444999bc5b Break the SDK terminator removal retry storm. Fixes #4156
- adds RemoveTerminatorsV2, an asynchronous control-channel removal, so a router
  no longer holds a request slot open waiting for a synchronous reply; gated on a
  new capability so routers fall back to the synchronous path against controllers
  that do not advertise it
- paces establish and remove retries with a per-terminator exponential backoff
  after a controller rejection, so a rejected operation is not re-sent on the next
  event-loop tick, which is what let a rate-limited removal sustain itself
- routes v2 removes to the leader and skips the ordered delete for a terminator the
  router confirms it created that no longer exists, so a storm of no-op retries
  cannot consume the command rate limiter
- gates that skip on the leader having applied everything committed when it took
  leadership, since a leader reports itself elected before those applies finish and
  would otherwise read a committed create as absent and drop its delete
- guards the leader term and every write to the caught-up flag with a dedicated
  lock, so a barrier completing alongside a leadership change cannot record a result
  for a term that has already ended
- scopes v2 removals to the requesting router, so a router can only remove
  terminators it owns on the asynchronous path as well as the synchronous one
- tracks in-flight removal batches on the router, resolving or requeueing them when
  the response arrives; lost responses self-heal via rate-limiter expiry and the
  retry scan
- waits for an outstanding operation before sending a terminator delete, and checks
  that before dequeuing, so a delete neither races a create the controller has
  committed but not applied nor falls out of the queue until the retry scan finds it
  minutes later
- matches a create response to the attempt that produced it, by control channel and
  reply sequence, since attempts overlap once one overruns the establishment timeout
  and every attempt carries the same terminator id; only the outstanding attempt's
  response may confirm the create or report the terminator idle
- records the attempt as the sender assigns its sequence, so a response cannot be
  processed before the request it answers is known, and withdraws an attempt whose
  send never queued
- reports a removal that succeeds past the establishment timeout as congestion
  rather than success, matching how the establish path classifies its own latency,
  since both resolve into the same limiter
- extracts the transient-error test both remove handlers share, so the v2 path
  treats a leaderless cluster as busy like v1 does instead of as a permanent
  failure, and the two cannot drift again
- applies the same delete sequencing and response correlation to the router-hosted
  (ER/T) registry, which cleared the same in-flight marker unguarded and dropped a
  deferred delete from its queue rather than leaving it there
- bounds the v2 response send with a timeout, so a router that stops draining its
  send queue cannot accumulate blocked responder goroutines on the controller
2026-09-24 13:24:51 -04:00
Paul Lorenz 6c20e68038 Apply managed link heartbeat and queue settings at runtime. For #3743
- applies the router.link.v1 heartbeat settings (sendInterval, checkInterval,
  closeUnresponsiveTimeout) and payload/ack sender queue sizes at runtime,
  replacing the hardcoded 10s/1s link heartbeat intervals and the ignored fields;
  new links take them at bind time, established links are re-tuned in place
  through the channel HeartbeatControl, and queue sizes reach new links only
- publishes heartbeat settings as an immutable generation in one atomic swap, so
  no reader pairs one generation's interval with another's timeout, and has each
  link enforce the timeout belonging to its own intervals
- pushes a generation and its intervals as one step under the link's lock and
  ignores a generation at or below the one applied, so an overtaken update cannot
  roll a link back; reconciles every channel of a link, including a split link
  whose channels bind on either side of a config change, to the newest generation
- adopts the first registered settings explicitly, since a router with no managed
  link config publishes its defaults at generation 0
- re-arms a link's liveness deadline when its generation changes, so age
  accumulated under the previous intervals cannot close a healthy link when a
  timeout is shortened
- honors a closeUnresponsiveTimeout below 30s, which previously sat behind the
  unhealthy threshold; treats a zero timeout as closing nothing, and reports a
  closing link unhealthy
- scales the unhealthy threshold with the intervals, to max(30s, 2 x (send +
  check)): reporting unhealthy poisons the latency metric the controller routes
  on, so a fixed 30s priced healthy links with a long send interval out of
  routing every cycle
- validates heartbeat timing on the controller and the router: durations must be
  positive, their sum representable, and the timeout at least 10s and greater
  than sendInterval + checkInterval; a timeout under two heartbeat cycles is
  accepted with a warning
- adds a per-config-type semantic validator registry to ConfigManager, run after
  schema validation, and moves the router.link config definition to
  common/config/routerlink so the controller applies the same rules
- treats a link section in router YAML, of any content, as local config that
  takes precedence over the controller's for the whole router.link type, since
  the loader defaults every field and so now records presence separately; warns
  at startup when that section has no listeners or dialers
- translates local heartbeat timing leniently, since a local failure stops the
  router from starting: keeps an explicit zero, raises a timeout below the floor
  to it, and falls back to the defaults for other invalid timing, each with a
  warning
- stamps UpdateLinkListeners with the config generation it came from and has the
  controller drop superseded sets, which a multi-underlay control channel can
  deliver out of order and which would otherwise send peers to withdrawn
  addresses
- logs every successful link config apply, including those that dispatch no work,
  and pins that a queue-size-only change triggers no GC pass
- deprecates split links, documents the feature in the changelog and the router
  config design doc, and brings both up to date

Builds on the channel/v5 HeartbeatControl from openziti/channel#265.
2026-09-23 13:35:30 -04:00
Paul Lorenz de01dd226f Merge pull request #4381 from openziti/fix/api-session-enforcer-delete-meter
Mark the api session enforcer delete meter on every delete attempt
2026-09-22 13:52:53 -04:00
Paul Lorenz ffea337b92 Log the REST error responder's application code, not a method value. Fixes #4410
- the debug field bound the Code method left behind by the AppCode rename, rendering a function
  value and failing to marshal under the JSON formatter; it now logs AppCode
2026-09-16 11:57:11 -04:00
Paul Lorenz 179f586abb Publish first-party CA roots without intermediates. Fixes #4406
- publishes each first-party root CA key without intermediates, since a root's kid is shared by every controller and the intermediates in a controller's bundle are its own, so the same kid carried different content on each controller
- gives each ha-3 test controller only its own signing intermediate and asserts the first-party CA keys are identical across all controllers and the router
- syncs zititest module dependencies with the root module
2026-09-16 10:31:12 -04:00
Andrew Martinez 2096a8b4b8 fixes openziti/ziti#4348 process check with no signer fingerprint always fail (#4386)
- sends no signer fingerprints in the router data model when a process check has none configured,
  the single stored fingerprint was wrapped into a one-element list holding an empty string
- treats an empty configured signer fingerprint as no constraint when evaluating a process check,
  routers require a reported signer to match any entry in the list
- reports the configured fingerprints in the signer failure message, it reported the hashes
2026-09-16 09:48:28 -04:00
Paul Lorenz a0e53e29d4 Auto-GC stale router links. Fixes #4005
- adds a structured xlink.LinkKey ({DialerBinding, Protocol, DestId,
  ListenerBinding}) used by all staleness and GC checks, replacing the
  pre-rendered key string each side used to pass around
- adds the CheckStaleLinks ctrl message and the `ziti ops verify stale-links`
  CLI for operator-driven, two-sided staleness verification with optional --gc,
  which acts only when both endpoints agree
- implements auto-GC via the router.link.v1 gcMode (preserve/orphaned/changed):
  the router walks its xlinks after each Apply that mutates listeners, dialers,
  or gcMode and closes one-sided-stale entries under the configured mode
- sweeps a removal under orphaned whatever the removed config said, including
  preserve, since a removal leaves no listeners and no dialers and every
  remaining link is one the router can never re-establish
- reports staleness as a three-state verdict (unknown/notStale/stale) so a side
  that cannot judge a link abstains instead of guessing; a destination absent
  from the registry's listener snapshot means "listeners unknown", not "peer has
  none", which keeps a briefly unhealthy peer from losing its live links
- rebuilds the link surface only when a listener or dialer definition actually
  moves, so a gcMode-only change no longer rebinds every listen socket
- gates CheckStaleLinks on a new RouterStaleLinkCheck capability and explains
  each unqueryable endpoint, including one left unasked by the filter, so a
  partial verdict says which of the three causes applies
- detects a peer re-advertising the address a link was dialed to from the
  dialing side, not just from the peer's own listener side
- pins every verdict to the link iteration it was computed against, faults that
  iteration rather than the current one, and takes the conditional removal's
  result as the decision, so a link re-dialed while the sweep was running is
  neither closed nor reported as collected
- resolves which side a report speaks for from the sending router against the
  controller's link map rather than from the side the report names, so one
  router cannot fill both sides and satisfy the both-agree rule --gc depends on
- bounds the query fan-out with a semaphore, matching the other validation
  sweeps, since each query carries a minute-long reply timeout
- fails the CLI when the result stream ends before every link is reported, and
  drains results already buffered before declaring any missing
- rejects an unrecognized match mode rather than resolving it to changed, the
  broadest removal criterion
- consolidates the controller-managed router configuration changelog into one
  section, replacing the status that said routers do not yet consume configs at
  runtime, and documents the per-config-type opt-in
- restores the Current Beta Features section, dropped when the 2.0 changelog was
  archived, and lists controller-managed router configuration in it
- adds unparseable to the codespell ignore list, a spelling variant the
  dictionary flags as a typo

For #3743.
2026-09-11 15:56:22 -04:00
Paul Lorenz 929ea54eaf Index links by router id, and serialize the two structures that index. Fixes #4246
BuildRouterLinks runs once per router connect and scanned the whole link table to
find the connecting router's links. The table is proportional to the square of the
router count in a full mesh, so a wave in which every router reconnects walks the
cube of it in link visits. That never shows in steady state; it arrives during a
mass reconnect, when the connect path is already the bottleneck.

Indexing every link under both endpoint router ids fixes the cost, and introduces
the problem that the table and the index are two structures written in sequence.
Three things follow from that, and the destination repair below turned out to
depend on the connect path's ordering as well.

Performance:

- indexes every link under both endpoint router ids, maintained in the add and
  remove paths all link mutations funnel through, so a connect costs its own
  router's link count rather than the whole table
- prunes a full refresh against the reporting router's own links. That report is
  what every reconnect sends, and it walked the whole table to find the router's
  stale links, so the cost the connect path shed was still being paid one message
  later
- indexes link ids rather than link pointers, so a per-router query resolves each
  id against the table and hands back whatever it currently holds. A reconnect
  replaces a link's Router object and a higher iteration replaces the Link object,
  but neither replaces the id, which is exactly why the scan existed
- holds each router's link ids in a LockedSet rather than a sharded map, which
  cost a map and a mutex per shard for an index that is usually empty and is held
  for as long as the router has existed: 2.9KB per router id against 150 bytes
- drops a router's index when the router is deleted, guarded on the store still
  having no router under that id and checked inside the index map's removal
  callback. A router id can come back, since fabric router ids are the enrollment
  certificate's common name, and nothing orders the cleanup against that: store
  event handlers run after bolt has released the writer lock, so one can execute
  after the id was recreated, connected and reported links. Indexing a link takes
  the same shard as the guarded read, so an entry for a live router cannot appear
  without its create having committed first, which the read then sees, and an entry
  arriving later blocks and lands in a freshly created index
- keeps an index when the store cannot be read, since that is not evidence the
  router is gone, and dropping one otherwise could discard a link another goroutine
  had already fetched the index to record

Keeping the two structures agreeing:

- serializes Add and Remove on the link's id. Without it a removal running between
  an add's two writes takes the table entry, finds nothing yet in the index, and
  lets the add index a link the table no longer holds, which nothing cleans up.
  Only RouterReportedLink held that lock before; the four other removal paths held
  nothing
- serializes the connect-time pairing on that id as well, which was the last writer
  left outside it. A removal reading no destination could complete while the
  pairing was still deciding, leaving the link in the destination's link set after
  the table had dropped it, where path computation still routed over it
- unindexes an id only when the table no longer holds a link under it, so a
  replacement that has taken the table slot is not unindexed by the older link's
  removal. A stale id is the safe direction to err in, since a query filters it,
  where an id wrongly dropped leaves a live link no per-router query finds
- has per-router queries resolve ids against the table, so an id it no longer
  holds is not handed out as a live link

Pairing a link with its destination:

- re-resolves the destination once the link is in the table, and on every later
  report, so a link that reached a bad state heals. A report resolves the
  destination before the link is in the table and a router's connect repairs links
  already in it, so a router connecting between those two moments was seen by
  neither, leaving a link with no adjacency that every operator-facing view still
  called healthy
- makes that re-resolve unconditional rather than only for a link holding no
  destination. The resolve happens under the source router's connect stripe, not
  the destination's, so the destination can be replaced between the resolve and the
  report landing, and a link left on a connection that is no longer registered
  carries no adjacency just as one holding none does
- registers a connecting router before building its links, which is what makes
  that re-resolve close the window rather than narrow it
- adds Link.PointDestAt so the two repair paths cannot both index the link on the
  destination, since that index is a slice that does not deduplicate

Also here:

- logs the link count on both sides of the reconnect exchange, and why a report was
  discarded. A router announces its links once per reconnect and is not asked
  again, so a discarded report left it with no links for a router that believed it
  had announced them, with nothing recorded to compare. The discard reports the
  state it decided on, read once, since a reconnect landing between the decision
  and the log would otherwise have it name a state that discards nothing
- gives test routers version info, which a connected router always has because the
  accept path refuses a hello without it, and which the router sync path
  dereferences with no nil check

The destination repair is backported from the gossip link-state branch, where the
connect path registers before building links for unrelated reasons. That ordering
is load-bearing here and is now explicit at the call site.
2026-09-10 19:55:32 -04:00
Paul Lorenz 419dfd46b4 Merge pull request #4366 from openziti/legacy-api-session-activity
Restore legacy API session activity marking for REST requests
2026-09-10 14:55:03 -04:00
Paul Lorenz e134383b29 Mark the api session enforcer delete meter on every delete attempt. Fixes #4378
- moves the delete meter mark out of the batch-delete error branch so successful batches are counted
- counts only the fallback deletes that succeed when the batch delete fails
- asserts the meter count in the session enforcer test
2026-09-09 18:16:47 -04:00
Paul Lorenz 110db6623b Merge pull request #4353 from openziti/fix/policy-enforcer-metric-refs
Hold the policy enforcers' meters rather than resolving one per run
2026-09-09 17:37:48 -04:00
Paul Lorenz f1264086d4 Restore legacy API session activity marking for REST requests. Fixes #4365
- resolves zt-session tokens eagerly when the request context is created, so every request carrying one marks activity and gets session lifetime headers, regardless of endpoint
- marks last activity in SecurityCtx.resolveZtSession once the session is loaded
- adds SecurityTokenCtx.HasZtSessionHeader, a header-only check that does not parse bearer tokens
- emits only session lifetime headers from the API wrappers and drops the unused session-error header branch, so a stale token on an anonymous endpoint stays silent as it did on 1.6.x
- tests that requests to authenticated and anonymous endpoints with a zt-session mark activity, carry lifetime headers, and are reflected by current-api-session
2026-09-09 17:20:50 -04:00
Andrew Martinez b4f6223ad1 fixes openziti/ziti#4321 compare process hashes and fingerprints case… (#4344)
* fixes openziti/ziti#4321 compare process hashes and fingerprints case-insensitively

- normalizes configured hashes and signer fingerprints to lowercase unseparated hex in the
  PROCESS and PROCESS_MULTI stores, on load as well as on save, so values stored before this
  change read back normalized without a migration
- replaces the PROCESS store's lowercase-only pass, PROCESS_MULTI stored its values verbatim
- adds store tests for both types covering configured values and values written straight to bolt
- updates the process multi patch round-trip test, the management API now returns normalized
  values rather than the submitted strings
- removes the trailing newline from the signer fingerprint literal in the process and
  process-multi OIDC posture tests
2026-09-08 13:45:15 -04:00
Paul Lorenz 49fdd2c0a1 Hold the policy enforcers' meters rather than resolving one per run. Fixes #4350
Registry.Meter is reference counted: every call takes a reference, including calls
that find the meter already present, and only Dispose releases one. The enforcers
resolved a meter inside Run, so each run took a reference it never shed. Disposing
such a meter decrements the count instead of stopping it, so it leaves the registry
and keeps sampling.

- resolves each enforcer's meter once, where the enforcer is built, and holds it
- holds the timers alongside, though Timer is not reference counted, so a reader
  is not left working out why one of two adjacent lookups was cached
- supplies the metrics in the session enforcer test, which builds the enforcer
  directly to get a negative session timeout that NewSessionEnforcer refuses

Per enforcement cycle rather than per event, so the growth was one reference per
run. Unbounded over a controller's lifetime, but slow.

grep -rnE '\.(Meter|Histogram)\([^)]*\)\.(Mark|Update)' finds this shape; there are
no others left outside tests.
2026-09-03 17:18:29 -04:00
Andrew Martinez b1454c6d63 fixes openziti/ziti#4320 normalize reported MAC addresses on the router (#4328)
- normalizes reported MAC addresses in Instance.Apply to lowercase unseparated hex,
  the form MAC posture check values are persisted in
- stores a new PostureResponse_Macs rather than mutating the incoming protobuf message
- compares the normalized addresses when deciding whether posture data changed, so a
  re-reported separated address no longer reads as an update
- moves the normalizer to a new common/posture package, shared by controller/db and
  router/posture, and hoists its regexp out of the per-call path
2026-09-02 18:34:26 -04:00
Paul Lorenz 1b2ea0c224 Merge pull request #3836 from openziti/oidc-auth-test
OIDC authentication fablab test
2026-08-31 22:39:24 -04:00
Paul Lorenz e8b42b89ae Add OIDC auth fablab test and supporting test infrastructure
- adds an oidc-auth-test fablab model that exercises OIDC authentication end to end, with an event-forwarder component, an oidc-test-client, a ziti-prox-c component, and OIDC event/gossip/traffic validations
- moves zitirest out of the public API into separate test-only shims: an integration-test shim (tests/restclient.go) and a fablab shim (zititest/zitirest), and repoints upgrade-test at the fablab shim
- adds region-isolation network partitioning and packet capture on all interfaces to the chaos toolkit
- queues oidc-test-client results reporting on a single sender goroutine with a bounded write deadline, so a stalled results circuit can't block the traffic loops
- counts results events dropped when that queue fills and reports them to the collector as errors, so a reporting outage fails validation instead of looking like a clean run
- bounds the event forwarder's event and keepalive writes, and checks for shutdown on every send attempt, so an unreadable destination can't park the forward loop holding its lock
- logs read errors on collector connections instead of ending collection for that client silently
- bounds the oidc-auth-test debug server's header and body reads
- matches ziti-prox-c process matching to the version-agnostic binary name, so a version change still finds the running process
- points upgrade-test's per-service terminator count at the shared validations helper
- adds a fablab design summary doc
2026-08-28 22:00:01 -04:00