on-premise

A door on someone else's network

A door on someone else's network

A cloud platform that manages clubs eventually has to open a physical door, on a site, wired to a controller that was installed years before anybody wrote the platform, sitting on a private network with no route to the internet and no cloud API of its own.

You can't solve that from the cloud. Something has to run there. So what you end up with is a small piece of software installed on the customer's network, which speaks one stable contract upwards and whatever the access-control system speaks downwards:

1Club Server
  → @1club/access-bridge-sdk        typed TypeScript client
    → Access Bridge API             a versioned OpenAPI contract
      → vendor integration          one binary per access-control system
        → vendor API / controller / hardware

A customer installs one integration, the one that matches the system they already own. Everything above that line is ours and deploys on our schedule. Everything below it is theirs and doesn't.

That asymmetry drives most of the design, and it's why the language for the bottom half wasn't really a matter of taste.

The deployment target picks the language

This is the constraint list I had before I had any opinion about syntax:

  • It installs on a Windows Server in a plant room as often as on Linux.
  • The customer isn't going to install a runtime for us. Not a JVM, not .NET, not Node. "Please have your IT department provision a runtime on the machine that runs your security system" is a sentence that loses deals.
  • I'll never have a shell on it. When it misbehaves, a support engineer who isn't me has to diagnose it from logs and a health endpoint.
  • It holds a credential that can open every door on the site, so the amount of third-party code in the process is a security number before it's a convenience one.
  • It has to keep an eye on a long-lived vendor session while serving concurrent HTTP requests, and be able to shut that session down cleanly on SIGTERM.

Go answers all five, and as far as I can tell it's the only mainstream option that answers the first two without an asterisk.

Go produces one static binary, cross-compiled from CI. The build line in the integration's manifest is a single go build:

build:
  setup: go mod download
  lint:  gofmt -l . && go vet ./...
  test:  go test -race ./...
  build: go build -trimpath -o ../../bin/impro ./cmd/impro
platforms: [linux/amd64, linux/arm64, windows/amd64, darwin/arm64]

Four platforms, no cross toolchain, no runtime to match, no .dll to bundle. It's one GOOS/GOARCH pair per matrix cell over the same source, built with CGO_ENABLED=0 inside a digest-pinned container so the toolchain is identical every time. That's what makes a native package per platform affordable at all. It's also why the default artefact type is native-binary and not container, because access-control systems live on machines where mandating Docker would simply exclude the site.

What cross-compiling does not hand you is a service. For most of this project's life its own documentation said installation was install -m 0755 on Linux and a copy plus an sc.exe create on Windows. Both of those were wrong, and I'll come back to why.

The dependency surface is close to zero. The module requires one third-party package:

require (
    github.com/1club-ai/.../bridgeapi   v0.0.0   // ours
    github.com/1club-ai/.../bridgehttp  v0.0.0   // ours
    gopkg.in/yaml.v3                    v3.0.1
)

A YAML parser. Everything else (the HTTP server, the HTTP client, TLS, XML decoding, structured logging, signal handling, the test harness) is the standard library. Both shared libraries have empty require blocks. For software that holds the keys to a building I'll take a one-line answer to "what is the supply chain" over any amount of framework ergonomics.

The concurrency is easy to reason about. The vendor session is shared mutable state behind a mutex, the HTTP host serves requests on goroutines, and context.Context threads cancellation from the request all the way down to the vendor call. This is the boring, well-trodden part of Go, and boring is what I wanted here. go test -race runs in CI and has caught things reading never would.

One smaller thing. The systemd unit sets MemoryDenyWriteExecute=true, which a JIT runtime cannot tolerate, and a statically linked Go binary doesn't care. The hardening options you'd like to set on a process that can open doors tend to be the same options that fight a managed runtime.

Where Go made me work for it

I'd rather write this down than pretend the choice was free.

The vendor's write API is lenient by design. You send only the attributes you want to change, and omitting one means "leave it alone", so attribute presence carries meaning. encoding/xml can't express that for scalar fields without making every one of them a pointer, and ,omitempty is actively dangerous here because it would drop current="0", which is the documented way to deactivate a cardholder. A departed member would keep working access, and the call would return success.

So the encoder is hand-rolled around an ordered, presence-tracking attribute bag. Decoding stays on encoding/xml, which is fine at it. That's perhaps three hundred lines I wouldn't have written in a language whose serialisation library models optionality properly. Then again, three hundred lines I can read in one sitting, and when the failure mode is a door I want to be able to.

The communication hiccups

I expected the difficulty to be in the domain (doors, credentials, entitlements). It wasn't. A twenty-year-old on-premise product has opinions, and none of them look the way you assume.

One API session, at most

The vendor meters concurrent API sessions. On the lowest licence tier the customer's own system permits a single concurrent API login. So the Bridge holds one session for its entire lifetime, and three things follow from that:

  • Logout is mandatory on shutdown. A session that isn't released stays held until the vendor times it out, and until then nothing else can authenticate, including the site's own staff at their own console. Killing the process with SIGKILL locks the customer out of their security system.
  • That logout needs a context detached from the shutdown signal. By the time shutdown runs, the ambient context is already cancelled, so the logout request is cancelled with it and the session leaks anyway. context.WithoutCancel is the fix, and there's a test asserting the fake portal's session count returns to zero.
  • Authentication is rate-limited. A crash loop that retries login aggressively would burn the customer's licence. The limiter is enforced while holding the session lock, so a burst of concurrent callers can't each independently decide a login is due. And a Bridge that cannot log in degrades to 503, it doesn't take the site down with it.

"Not authenticated" in three forms

A 401 is the easy one. But a servlet container that has forgotten the session answers with an HTML login page and HTTP 200, which without a guard surfaces as an unintelligible XML parse error:

switch {
case resp.StatusCode == http.StatusUnauthorized, resp.StatusCode == http.StatusForbidden:
    return nil, errSessionExpired
case looksLikeLoginPage(resp, body):
    // 200 OK with a login page is still a dead session.
    return nil, errSessionExpired
case isWrongEndpoint(resp.StatusCode):
    return nil, ErrEndpointNotFound

The third form cost me an afternoon. The product remounted its XML servlet between generations, so one serves it at /portal/api/xml and the newer one at /api/xml. Point at the wrong path on the newer one and you reach the web app's static handler, which accepts GET, HEAD, OPTIONS and refuses the login POST with 405. The credentials are never examined. Diagnosed naively that's "check your password", and the password is fine. So 405 is classified as wrong path and reported as such. It also does not arm the login rate limiter, because a request that never reached the authentication code consumed no licence session. If it did arm it, the one diagnostic the operator needs would get replaced on every later attempt by "waiting before reconnecting", which is unhelpful and also untrue.

Success with no records

A query that matched nothing replies with a result attribute reading Success : No records found. Compare that string against Success and every empty table becomes a vendor error. On the event stream that means a night with no events fails every single poll. The predicate now lives in one place and every reply type that carries the attribute uses it.

Sessions are bound to the URL

The session is bound to the URL verbatim. Reaching the same server as https://localhost and then https://127.0.0.1 doesn't work, it's treated as a different route. So the configured base URL is used exactly as given, redirects are refused, and a URL carrying a query string or fragment is rejected at startup rather than at 3am.

Two units bugs

Both were silent, and both only turned up against real hardware. The schedule primitive stores start time and duration as HHMM, not as minutes since midnight. Read as minutes, a group configured for 10:00-16:00 was published as 16:40-24:00, so two windows that never overlap, returned as a success. A duration of 2400 is what settles it, because forty hours is not a number. The parser now refuses a malformed value and publishes no schedule, which I prefer to a plausible one that isn't the vendor's.

The other is the classic. One entity is written in local ISO time and stored as UTC (the vendor documents this as an explicit exception to its own rule). Get the zone wrong and every access window shifts by the offset with no error at all - the grant syncs cleanly and the member is denied at the door. There are three defences. The time zone is required configuration with no default, because a container almost always runs UTC and defaulting to it is silently wrong at every site outside it. It's measured against the vendor's own data on every event poll, since each transaction carries both a UTC and a local timestamp for the same instant. And the result is published in the capability document, so a Bridge that can't prove its time zone says so out loud.

Errors leak

Vendor error payloads carry a full Java stack trace in one attribute and, in another, human-readable text that can quote a card number. The stack trace is attached as the error's cause so it reaches the local debug log and never a response body, a metric label or an upstream log line. Digit runs of four or more are redacted before any of it is surfaced. Both directions of the wire log go through the same redaction, because a write carrying a tag has a card number in it too.

Events are ordered by insertion

Controllers buffer transactions while they're offline and upload them later, so a higher row id can carry an earlier timestamp. The cursor is a keyset scan on the primary key. There's no OFFSET, so it can't skip or duplicate rows while new ones are being inserted underneath it. The capability document states the ordering is ingestion so the consumer knows it must sort itself. Claiming chronological order would have caused silent event loss after every controller outage, on an audit trail, which is about the worst failure this software could have.

Installation is a feature

I underestimated this one. It's also where the distance between what the documentation promised and what the software could do was widest. installation.md told operators to download a versioned artefact and check its checksum against the release page. There was no release page. There were no tags either, and make build stamped every binary 0.1.0-dev into a gitignored directory that CI threw away. Everything below existed on paper first and had to be made true.

When the software runs on hardware you'll never touch, installation is a designed surface with nine steps: install, configure, start, stop, check health, view logs, upgrade, roll back, uninstall. I want to defend a few of the decisions in there.

The release pipeline doesn't know what Go is. On merge, every integration whose code changed is cross-compiled once, packaged, checksummed, attested and published, always to a rolling prerelease and also to a versioned release when the manifest's version changes. The workflow never says go, impro or nfpm, because both matrices are read out of the integration's own manifest:

packaging:
  - format: deb
    targets: [linux/amd64, linux/arm64]
    setup:   packaging/setup-nfpm.sh
    command: packaging/build-nfpm.sh
  - format: msi
    targets: [windows/amd64]
    runsOn:  windows-latest
    setup:   packaging/setup-wix.ps1
    command: packaging/build-msi.ps1
    sign:    windows-authenticode

Validation fails if a platform is declared and never packaged. A .NET integration shipping an MSI joins by adding a manifest, and the contributing guide had been promising that all along. Each release also carries an operator handbook as a PDF. Its settings reference is generated by running the binary, so it can't document a variable that does not work.

The copy-the-binary story was silently wrong on both platforms. A console process never answers the Windows Service Control Manager, so sc query misreported state, failure-restart never fired, and Stop-Service killed the process when it should have stopped it. That leaves a vendor session held, and on the single-session tier that's the lockout described above. The documented systemd unit had the mirror-image defect, Type=notify-reload with nothing ever sending READY=1, so systemd would have waited out TimeoutStartSec and killed it. Neither had been noticed, and for the same reason: nothing had ever been installed as a service. So the artefacts are now a .deb, an .rpm, an .msi with a configuration wizard, and a .pkg inside a .dmg. Each one installs a service its own platform recognises, and there are archives and a container image for the hosts none of those suit.

Configuration is one command. --configure asks for every setting, mints the API key, validates the answers against the vendor (including checking the configured time zone against the system's own data) and only then writes anything and enables the service. It's one implementation, used on all three platforms.

The Bridge mints its own API key. There's no default credential and nothing to generate in the cloud first. It writes a key readable only by the service user, prints it exactly once, and the operator pastes that value into the app:

──────────────────────────────────────────────────────────────
  This Bridge generated its own API key. Nothing else has it yet.

      <48 hex characters>

  Paste it into the 1Club app to finish connecting this site.
  Print it again with:  impro --show-api-key
──────────────────────────────────────────────────────────────

The direction matters. A secret that travels from the site to the cloud never needs a channel into the site to be established first, so enrolment doesn't depend on the connectivity question being settled. A Bridge that can neither mint a key nor be handed one refuses to start. And minting only ever happens because a person asked, never on a service start, because that would print the credential into the journal and leave a Bridge listening on a key no one had read.

Commission before you start. --selftest is read-only, takes about a minute, and answers the questions that otherwise become support tickets: do the credentials work, which licence tier is in force, does the configured time zone match what the system reports, and which doors have more than one reader and therefore need their unlock target pinned by hand. That last one is a real ambiguity. The unlock command addresses a reader, not a door, and a door commonly has two. The integration picks deterministically, then flags the door as ambiguous and publishes every candidate, instead of guessing silently.

Upgrades are always operator-initiated. A Bridge that updated itself would be a remote code execution path into a physical security system. So an upgrade is the platform's own package command, which stops the service, swaps the binary and starts it again. The environment file is marked as configuration so no package manager overwrites it, and the key file isn't in the package at all. Rolling back is installing the version you came from, so the instruction is to keep that package on the host (a rollback during an incident should not begin with a download). It's safe by construction, because the Bridge holds only regenerable state: an idempotency record, an event cursor, a session token. The access-control system holds the real state and the cloud holds the desired state. The one cost is those idempotency records. Lose them and a command retried across the rollback can run twice, so mid-unlock-burst is the wrong moment.

The fleet is also permanently version-skewed, since customer binaries update on the customer's schedule. So the cloud branches on a capability document fetched at runtime and never on the API version. A version number tells you nothing useful when one system can enumerate a person's permissions and another can't. 501 unsupported_operation is a first-class answer and it's kept distinct from 404, so a capability gap never looks like a data problem.

The decision I deliberately did not make

Who dials whom is still open. Today the cloud calls the Bridge. That's an ordinary HTTPS API, debuggable with curl, and it costs an inbound firewall rule and a certificate on customer hardware. The alternative is the Bridge dialling out and holding a persistent connection, which removes the single largest deployment obstacle and replaces it with a bespoke tunnel protocol to design, test and support (multiplexing, correlation, backpressure, reconnection), where a defect hits every customer at once instead of one site.

I didn't want to build that on a guess, so the code is arranged to keep the choice cheap. The integration interface contains no HTTP at all, just methods over context.Context, and the HTTP host is a seperate package that happens to serve it. Outbound mode is a second host package over the same unchanged integration. The idempotency key is already required on unlock, because a reconnecting tunnel needs replay protection just as much as a retried request does.

What will settle it is arithmetic. Record, for the first ten installations, whether an inbound rule was granted, how long it took, and who had to approve it. Ten data points will answer it better than more discussion will, and with the transport already split from the behaviour there's time to collect them.

Deyan Peev

Founding Engineer in Sofia, Bulgaria. Currently at 1club.

© 2026 Deyan Peev