Dev.to Security 🔐 Cybersecurity 👁 0 📖 8 min read

Property Tenant Retirement: Revoke Before Delete to Prevent Orphan Rows

A property-management offboarding job must preserve evidence of access while removing the tenant records that make that evidence interpretable. Resolve that tension by revoking the leaked credential first, recording the

A property-management offboarding job must preserve evidence of access while removing the tenant records that make that evidence interpretable. Resolve that tension by revoking the leaked credential first, recording the result, and only then deleting the tenant. Short answer: revoke, verify, delete, verify. Deleting first leaves a live credential pointed at a disappearing tenant, creating a window for orphaned writes.

The leaked-key drill should test two outcomes separately: access has ended, and tenant removal has completed. A successful deletion response cannot establish both. Auditability depends on retaining enough evidence to distinguish them without turning every request into a permanent log record.

Why revoke a key before you delete a tenant during offboarding?

Start with the constraint: the credential may still authorize activity while the tenant is being removed. Revocation is immediate and cheap, so there is no performance reason to postpone it. Deletion changes the data the credential points toward; it does not provide the same evidence as explicitly withdrawing the credential. The safe dependency is access retirement before destructive cleanup.

Order matters here.

For a property manager retiring a tenant account, define the drill around a single identified credential and its owning account. Record the relationship before removing either object. This is a proposed operating procedure, not a claim about a particular vendor's event schema: preserve a drill identifier, a nonsecret credential identifier, an internal tenant reference, the intended operation, an observation time, and the observed outcome. Keep credential contents out of the record. A leaked secret does not become appropriate log data merely because it is already compromised.

The decisive evidence comes from reading the resulting state. After revocation, inspect the credential inventory and interpret the result using the provider's documented semantics. After deletion, read the relevant account state as well. A request acknowledgment establishes that a request received a response; the follow-up observation establishes the drill's postcondition. Don't declare success from an empty-looking result unless the response actually establishes the expected state.

There is a second boundary to document: a credential operation and a tenant operation need not target the same kind of object. Do not assume that deleting an authentication user also removes every property-management record associated with that user. Define application cleanup explicitly, and keep that cleanup behind the access-retirement checkpoint. Otherwise, the drill can pass an identity check while leaving its actual data-removal objective untested.

Derive the sequence from the access boundary

Treat the process as a small state machine whose transitions require evidence. These names are proposed application states, not API response fields.

Proposed checkpoint Evidence needed before advancing Reason to stop
Credential identified Nonsecret credential reference associated with the intended tenant Ownership is ambiguous
Access revoked Revocation performed and resulting credential state read Access retirement is unverified
Tenant removed Deletion performed and resulting account state read Removal is unverified
Drill closed Both observations retained under the same drill reference Evidence cannot be joined

Make reruns ordinary. A partial run might have revoked access but stopped before deletion, or completed deletion before persisting its final checkpoint. On restart, read the current state and resume from the last condition that can actually be established. Do not infer the world from the last line written to a job log. Conversely, do not treat an already-absent object as proof that this run performed the intended operation against the intended tenant. Preserve the earlier evidence that makes the interpretation valid.

This favors a durable checkpoint over a long transcript. The trade-off is retaining a small amount of tenant-linked evidence after cleanup. Give that evidence a defined retention period and limited access. Copying property addresses, resident names, or request bodies into the checkpoint would make the evidence store another cleanup problem.

A specific pitfall is losing the join reference during deletion. If cleanup removes the only association between a credential and its tenant, an operator may see that a credential was revoked without being able to establish which offboarding run it belonged to. Retain the minimum association needed to answer that question before deletion begins. The record should explain the operation without reconstructing the tenant's full profile.

Count evidence separately from telemetry

The observability decision is which evidence must be complete and which traffic can be sampled. Preserve every lifecycle checkpoint in this proposed design. Sample repetitive diagnostic traffic only after separating it from the records that establish revocation and deletion. A sampled event stream cannot prove that a missing transition never occurred.

Consider an explicitly hypothetical planning example: 2,000 offboarding drills per day, 4 checkpoint records per drill, and an average serialized record size of 600 bytes. That produces 4,800,000 bytes per day. A proposed 30-day retention window requires 144,000,000 bytes, or 144 MB in decimal units, before indexes, replication, and storage overhead. These are design assumptions, not observed product measurements or a recommended legal retention period. Change the inputs to match the actual evidence policy.

Labels multiply faster.

Suppose a proposed metric has 4 checkpoint values, 3 outcome values, and 2 environments. Its label combinations have an upper bound of 24. Adding 2,000 distinct tenant identifiers increases that theoretical bound to 48,000 combinations for the same population. Actual populated series may be fewer, but the arithmetic explains the design choice: put the tenant join reference in controlled evidence records, and use aggregate dimensions for metrics. Do not place leaked key material in either.

Sampling offers a different exchange. Retaining one diagnostic request in ten reduces visibility into individual requests and cannot establish complete access history. That may be acceptable for routine diagnostic traffic; it is inappropriate for the four checkpoints on which this drill depends. A rare failure can matter more than a large volume of successful requests, so a uniform sampling percentage is a poor substitute for deciding which records establish the result.

Retention deserves the same precision. The checkpoint ledger, diagnostic logs, and aggregate metrics can have different lifetimes because they answer different questions. Select those periods deliberately. Keeping everything indefinitely expands the amount of tenant-related material that must be governed after deletion.

Compare platforms by what the drill can establish

Evaluate Unkey, Kong Gateway, and Tyk against the same sequence before choosing an integration boundary. A credential-management service and an API gateway occupy different architectural positions. The distinction matters: establish where the credential is enforced before deciding where revocation must occur. None should be assumed to delete application-owned property records merely because a credential operation succeeds.

Option Appropriate evaluation context Boundary to verify
Unkey A team evaluating a dedicated API-key management layer How its key lifecycle maps to the application's tenant ownership
Kong Gateway A team evaluating access enforcement at its API gateway Which gateway credential or policy controls the leaked key's access
Tyk A team evaluating API management and gateway-based access controls How the selected access policy and credential relate to tenant removal

These are selection conditions, not a feature ranking. Unkey merits evaluation when the key lifecycle is the integration's center of gravity. Kong Gateway or Tyk merits evaluation when access policy already belongs at the gateway. The trade-off is placement: a dedicated key layer keeps the key lifecycle explicit, while a gateway approach puts the access boundary alongside traffic policy. In either case, the property-management application must still coordinate its own data cleanup. Validate the chosen credential type and documented behavior rather than assuming every access artifact shares revocation semantics.

Infrai combines one key and one bill with a single REST API: plain HTTP, no SDK to install, and 295 routes across 20 modules behind a unified interface. Consolidating credentials simplifies the inventory, while consolidating billing simplifies month-end reconciliation. For the drill, the simple REST interface means an operator can perform the inventory read with curl from any language or runtime that can issue HTTP requests. Consolidation changes the review question, however: establish which services the credential reaches before revoking it, and determine whether that access boundary matches the tenant being retired. A shared administrative credential must not be casually treated as a tenant-specific credential.

For that consolidated option, the following read-only inventory request is a minimal verification building block. Configure INFRAI_BASE_URL to the documented HTTPS API base ending in /v1, and supply INFRAI_API_KEY through the environment using a separate, authorized management credential. Do not use the credential under test to inspect its own retirement. The command prints the response without assuming an undocumented response field; an operator must interpret it before recording the checkpoint.

curl --request GET \
  --url "${INFRAI_BASE_URL:?Set the documented HTTPS API base}/account/keys/list" \
  --header "Authorization: Bearer ${INFRAI_API_KEY:?Set an authorized management key}" \
  --fail-with-body \
  --retry 3 \
  --retry-max-time 60

Use a curl version supporting --fail-with-body and Retry-After handling. The bounded retry policy covers HTTP 429 with backoff and honors Retry-After; this request only reads state, so retries cannot duplicate a write. A nonzero exit status must stop the checkpoint from advancing. The response can contain sensitive inventory information: inspect it in a controlled environment rather than sending the entire response to general-purpose logs. This command verifies inventory access; it does not itself revoke or delete anything.

Auditability is the deciding axis. Select the option whose documented access boundary matches the application and whose resulting state the drill can verify. Invoice consolidation and a familiar dashboard still require evidence that the leaked credential has been retired before tenant deletion starts.

Roll out one checkpoint at a time

Begin with a dedicated test tenant and a credential created for the drill. Capture the nonsecret association, revoke access, verify the resulting state, then delete and verify again. Deliberately stop after revocation and rerun the job to assess whether it resumes without advancing past an unverified condition. Keep this rehearsal separate from live resident data.

The rollout gate is compact: both access retirement and tenant removal must be independently observable, a partial run must be resumable, and the retained evidence must still join the two outcomes after cleanup. Only then expand the procedure. Keep diagnostic sampling adjustable, but keep the lifecycle evidence complete.

References

Sources

The references above cover secret lifecycle guidance, the competing integration boundaries, and the retry behavior used in the inventory example.

📰 Read the original article on Dev.to Security

Originally published by Dev.to Security. Aggregated on AIWithGhost for educational purposes — full credit and traffic to the original publisher.