Select a standby API credential at runtime from a versioned control record to change tenant access without a deploy. Make each switch attributable to an authorized actor. The deciding constraint is access auditability: a developer tools service must explain which scoped key a tenant used, why a standby became active, and whether revocation prevented subsequent use.

Short answer: keep the running Node.js application independent of the active key value. Resolve a tenant's approved credential reference through a runtime selector, record the selection revision, and bound how long any worker may retain that decision. A deployment should not be the mechanism that activates a standby API credential. This is a proposed architecture; the local interface below illustrates its acceptance-test contract rather than an existing service's API.

The useful audit artifact is a chain of decisions, not a copy of every request. Retain the evidence needed to reconstruct changes in access. Keep secrets out of that evidence.

How should a standby API credential preserve tenant access without a deploy?

Consider a developer tools service that issues and revokes a scoped key per tenant. Its disaster plan includes a standby credential for the same authorized operation. OWASP's Secrets Management Cheat Sheet provides the relevant lifecycle foundation: least privilege, rotation, revocation, auditing, and careful handling of secret material. The selection mechanism described here applies those principles to a specific design problem.

The proposed invariants are strict. A selector may return only a credential associated with the authenticated tenant and permitted operation. A standby must satisfy the same authorization checks as the primary; availability does not justify broader scope. A revoked credential must be ineligible for new selection. Every change to the selected reference must identify its actor, reason, previous revision, and resulting revision. None of those requirements calls for storing the credential value in a log.

Identity precedes selection.

Derive tenant identity from the application's authenticated context. Do not let a request body select another tenant's key. The example later includes a tenant identifier because the test harness needs an explicit input, but the production adapter must compare it with authenticated authorization context. Otherwise, a traceable switch can still grant the wrong access. An audit trail documents a decision; it does not make that decision legitimate.

Revocation also has a boundary. Marking a key revoked in the selector prevents future resolutions under that state; it does not revoke a credential at its issuer or cancel a request already sent upstream. The runbook must distinguish local ineligibility, issuer revocation, and outstanding requests. Declare what each action guarantees before treating a switch as containment.

Decision record: preserve the access history

The decision is to use a versioned runtime selector with a separate, access-controlled secret lookup. Its control record contains references and authorization metadata. The application receives the secret only when it needs to authenticate an approved operation. This separation is a proposed implementation boundary, rather than a property guaranteed by the word selector.

One table makes the alternatives comparable on the actual decision axis.

Proposed mechanism Evidence available for a switch Principal boundary
Deployment-bound environment value Release history can identify a change if the release process records it Changing the active value requires a new process configuration or rollout
Versioned runtime selector Actor, tenant, scope, reason, and revision can form one change record Cached selections require an explicit freshness and revocation policy
Broker that authenticates upstream requests Selection and credential use can be observed at one enforcement point The broker enters the request path and needs its own availability plan

For this scenario, the selector offers a useful division of responsibility: the access control plane authorizes transitions, while application workers execute requests. A broker is a valid alternative when centralized enforcement of credential use matters more than keeping that additional service out of the data path. Neither mechanism supplies auditability automatically. Someone must define which events are durable, who may modify them, and what happens when a record cannot be written.

For the proposed design, acknowledge an administrative switch only after its revision and audit event are durably committed together, or through an equivalent recoverable protocol. If durable recording is unavailable, reject the administrative change. This deliberately sacrifices switching availability to preserve attributable changes in access. Request-level diagnostic logging can have a different policy; conflating the two would turn a verbose log pipeline into an authorization dependency.

The critical path in a running application

In Node.js, place credential resolution at the outbound request boundary. A process-wide variable populated during module initialization cannot implement this design by itself. Each operation needs an authenticated tenant context, a permitted scope, and a selection revision that remains attached to that operation. An internal cache may reduce lookups, but its maximum staleness becomes part of the revocation contract.

The following curl commands describe a local acceptance-test contract to implement around that boundary. They assume a separately running test harness on the loopback interface, test-only credentials, and the three routes shown here. These routes are illustrative, not standardized or publicly hosted APIs. The harness must authenticate its control endpoint and enforce tenant authorization; the placeholder bearer values are not working credentials. No command prints an actual tenant key.

curl --fail-with-body --silent --show-error \ --request POST 'http://127.0.0.1:8080/credential-selection' \ --header 'Authorization: Bearer LOCAL_TEST_CONTROL_TOKEN' \ --header 'Content-Type: application/json' \ --data '{"tenant_id":"tenant-042","scope":"artifacts:read","expected_revision":7,"active_ref":"standby-b","reason":"authorized-drill"}' curl --fail-with-body --silent --show-error \ --request POST 'http://127.0.0.1:8080/artifact-check' \ --header 'Authorization: Bearer LOCAL_TEST_TENANT_TOKEN' \ --header 'Content-Type: application/json' \ --data '{"tenant_id":"tenant-042","artifact_id":"artifact-017"}' curl --fail-with-body --silent --show-error \ --get 'http://127.0.0.1:8080/access-audit' \ --header 'Authorization: Bearer LOCAL_TEST_AUDITOR_TOKEN' \ --data-urlencode 'tenant_id=tenant-042' 

The first operation proposes a transition from revision 7. The harness should accept it only if that revision is current, the actor has switch authority, and standby-b remains eligible for artifacts:read under tenant-042. A successful transition creates revision 8. A stale revision must cause a conflict rather than silently overwriting another operator's change. These are acceptance criteria for the proposed contract, not reported observations. The second operation exercises the application path without restarting its process. The test should inspect the controlled upstream receiver and the audit evidence to establish that revision 8 supplied the selected reference. Merely receiving a successful application response is insufficient: a stale worker could still have used the primary. The third operation lets the test correlate the switch with the operation using identifiers and revisions, without exposing either credential.

Success needs attribution.

Extend that drill with an unauthorized tenant, a standby missing the requested scope, a concurrent switch, and a revoked reference held in a worker cache. For the cache case, define a measurable bound first. As an illustrative requirement, a 30-second selection lifetime allows up to 30 seconds of stale selection unless another mechanism invalidates it sooner. That is a design allowance, not a measured revocation result. If the required local containment interval is shorter, shorten the lifetime or validate eligibility at a stronger enforcement boundary.

Be precise about retries. An authentication rejection, a transport timeout, and an authorization denial carry different information. Do not switch credentials merely because a request failed. A timeout can leave the operation's outcome unknown; replaying a mutation through the standby can duplicate work unless the operation has an appropriate deduplication contract. A permission denial should trigger investigation of scope and tenant binding. It must not become an invitation to try a more privileged key.

Count the evidence before choosing retention

The observability budget starts with event classes. Keep the administrative transition, issuance, and revocation records needed for the access history under a defined retention policy. Treat request diagnostics separately. OWASP's guidance supports auditing secret lifecycle activity and protecting secrets; the numerical model below is an explicit planning example, not a reported production workload or a prescribed retention period.

Suppose the design serves 2,000 tenants with 2 credential slots each. That is 4,000 tenant-slot combinations before adding scope, revision, actor, or request dimensions. Putting tenant identifiers and revisions on a broadly aggregated metric can multiply the number of label combinations. Prefer aggregate counters with bounded dimensions for routine monitoring, and keep tenant-specific evidence in an appropriately protected event store where it can be queried deliberately. Count combinations first.

For a hypothetical 10,000 administrative events per day, at 600 bytes per serialized event and 90 days of retention, the raw payload is 540,000,000 bytes: 540 MB in decimal units. Indexes, replication, storage formatting, and backups are additional. They are excluded from that calculation because their contribution depends on the chosen implementation. A retention decision based only on payload bytes would understate the storage requirement.

Request diagnostics can dominate even when the access history is small. At an assumed 1,000,000 requests per day, 1% sampling, 400 bytes per retained event, and 7 days, the sampled payload is 28,000,000 bytes. Those figures describe a planning scenario. They do not establish that 1% sampling is sufficient to investigate a tenant's missing request.

It isn't complete evidence.

Random sampling can support diagnosis, but it cannot promise a complete reconstruction of credential use. Preserve every authorized control transition if complete transition history is the requirement. If complete per-request attribution is also mandatory, budget for it explicitly instead of relabeling a sample as an audit trail. Retention should follow the documented investigation and access-governance requirements; lowering bytes is useful only while those requirements remain satisfied.

Secret values never belong in either stream. Record an opaque credential reference and the selection revision, restrict access to the event store, and define deletion and retention behavior. Tenant identifiers, actor identifiers, and timestamps can still reveal sensitive operational relationships even after the credential itself is excluded.

Rejected option and its valid use case

For this disaster plan, reject deployment-bound credential selection as the primary switching mechanism. It ties an access change to process configuration and makes the rollout path part of the recovery dependency. A small service with infrequent, planned rotations and an acceptable restart window may reasonably choose that simpler model. Its validity depends on those requirements.

The selector's main limitation is cached state. This trade-off makes it unsuitable for a requirement that every request immediately reflect issuer revocation unless a stronger enforcement mechanism is added. For that requirement, evaluate a broker that checks eligibility on every operation and explicitly coordinates issuer revocation. It adds a request-path dependency; it cannot cancel an upstream request already accepted.

Also reject unrestricted automatic fallback on every request error. A standby is an approved access path, not a second chance at authorization. Automatic selection can be appropriate when eligibility, switching authority, failure classification, and retry safety have all been specified and tested. Otherwise, prefer an explicit, attributable switch with a clear rollback decision.

The acceptance criterion is concrete: a running worker selects an authorized standby without deployment, the access history explains that selection, and revocation has a documented enforcement boundary. Retain enough evidence to prove those properties. Additional telemetry should earn its storage.

References