How integration credentials are stored, scoped, signed and egress-controlled, and what belongs in a log versus what must never appear.
Every integration is a trust boundary: a point where your system reaches into one you do not own, and something comes back that you may not expect. Most incidents in connected systems do not start at the screen the user sees. They start with an old key copied into a configuration file, an integration account holding more permission than its job needs, or a webhook endpoint that accepts any sender because it never checks a signature. The practical question is not whether the API is documented. It is what this credential can do at three in the morning, and who can read the record of what it did.
This article is not about rate limits or quota design; that is a separate subject we covered in rate limiting and quotas for APIs. Here we deal with the layer before every request: who holds the key, what that key is allowed to do, how we know a request came from the party it claims, and what gets written down afterwards. None of this shows up in a demo, and all of it is the first thing asked about after an incident.
An integration is a trust boundary, not a feature
A team adds an integration because it needs data, then forgets that it added a door. The door does not only open from outside; it can be used from inside once a credential is stolen or sold. So integrations are designed like login surfaces: a clear identity, a bounded permission, a reviewable record, and a path to revoke access in a minute rather than a week. The difference is that a login screen is seen by users who complain when it fails, while an integration runs silently until it stops or is abused.
The common mistake is to treat an integration as a small side project: one engineer, one key, no document. A year later the question of who uses that key has no answer, so it is left alone because it works. A key nobody owns is the most dangerous kind of technical debt, because it appears on no dashboard, nobody complains about it, and it stays valid long after the team has forgotten it exists.
Credentials: who holds them and what they open
The table below is not an academic taxonomy. It is the set of questions we ask of every integration before signing off on it. The last column matters most, because it names what the design must prevent rather than what a document recommends. The general rule is single: credentials are read at runtime from a dedicated store, and never appear in source code, a container image, or a shell history.
| Credential type | Where it lives | What it must never do |
|---|---|---|
| Static API key | A secret manager read at runtime, one copy per environment | Never written into source or a committed file, never shared across teams |
| OAuth client credentials | The identity server, with the secret held only by the server-side system | Never used in an app running on a user device, where it can be extracted |
| Webhook signing secret | A secret manager, a distinct value per environment and per counterparty | Never reused between production and test, never accepted without verification |
| Personal access token | Avoided where a service identity exists; if used, short-lived | Never granted the owner account's rights, never left alive after its holder leaves |
Notice that every row assumes one place to read secrets from and one path to revoke them. If revocation means editing a file on a server and restarting by hand, you do not have revocation; you have a procedure people forget. Test revocation before you need it: create a trial key, revoke it, and confirm that requests fail within minutes. That single test exposes most secret-management problems before they become an incident.
Least privilege, measured rather than declared
Least privilege is not a phrase in an architecture document; it is a measurable difference. Compare what a credential can do with what its job actually requires. A key that reads, updates and deletes while its only task is to read one report is risk with no return. Start by listing the operations the integration performs, then create a service identity that holds those operations on the named resource, not on the whole account. That alone shrinks the impact of a leak from everything to one list.
Separation is not only between systems but inside one: a key to read and a key to write, a key per tenant where the product is multi-tenant, a key per environment. We covered how this sits inside an identity system in enterprise identity and access management, because permission that is not managed centrally is managed from memory, and memory fails on the first holiday.
Signing and replay: why a shared secret is not enough
A shared secret proves the other side knows the secret. It does not prove that this particular message is the one it sent now. A valid message can be captured and replayed an hour or a day later, and it will look genuine because the signature is genuine. So the signature covers the message rather than the secret: the raw body as received, the timestamp, and a unique request identifier. Anything outside a short time window is rejected, and the identifier is stored so the same request cannot be accepted twice.
Implementation details differ between systems, but the principle does not: verify the signature over the bytes that arrived, before parsing them, because re-serialising after parsing can change ordering or encoding and either break the signature or let a wrong one pass. RFC 9421 defines HTTP message signatures and their time parameters, and RFC 2104 defines the HMAC construction most of these signatures use. Read them as written, not as an old blog post summarised them.
The time window is not decoration. Without one, every old request log becomes valid for replay forever. With a short one, you need trustworthy clock synchronisation on both sides and a written decision about what happens when the clocks disagree: reject and ask for a resend, or widen the window and lose some protection. Write the decision down, because whoever handles the incident at night will not read your intentions.
Egress: controlling what leaves the network
Most discussion of integration security focuses on what comes in, while the real damage may go out. An integration that builds a URL from user input and fetches it hands an attacker the ability to read internal services that are not exposed to the internet, a pattern known as server-side request forgery. The fix is not clever string filtering but an allow-list of hosts per integration, plus an explicit block on internal network addresses and cloud instance metadata.
From reading to shipping
Want this built, not just explained?
Bring us the problem behind the article. We will tell you what it takes, what it costs, and whether we are the right team.
The stronger control is to route outbound traffic through a single observable point: an egress proxy that knows the permitted destinations, logs what it blocked, and refuses anything undeclared. In an incident this is worth more than any written policy, because you can answer in a minute that this integration has not contacted a host outside its list for months. The alternative, allow everything and search the logs later, means discovering the incident after it is over.
What to log and what you must never log
A good log answers three questions: who asked, what we decided, and why. A bad log answers them and then leaves a copy of the key somewhere readable. The practical rule is to write the identifier of a secret rather than its value, because the identifier is enough to trace and useless to exploit. Review logs the way you review code, because logs are read by more people and more systems than code ever is.
Separate keys per environment so a test never reaches production data and production never reaches a trial account.
Rotate with two overlapping keys, then revoke the old one only after the new one is proven on every path.
Keep secrets out of code and history, and block them from logs and from error messages shown to users.
Scope permission to the resource, not the account, and grant write only to the path that truly writes.
Verify signatures over the raw body before parsing, and reject anything unsigned or mismatched.
Reject stale and replayed requests with a time window and a request identifier stored long enough.
Restrict egress to an allow-list and block internal network addresses and cloud metadata explicitly.
Log the decision, not the secret: request id, party, outcome and timing, with no authorization headers and no full identity numbers.
What to do this week
Start with an inventory, not a policy. Collect every API key, service key and webhook secret into one table: who owns it, which system uses it, what it can do, and when it last rotated. Then take the most broadly permissioned integration and fix it first, because it carries the largest risk and the clearest result. That same inventory is what any later security reviewer will ask for, so you are not adding work; you are doing deferred work early.
Where you have many integrations and outside vendors, separate what you own from what you do not: you cannot impose a signature on a party that does not support one, but you can limit what it can reach and document the exception with a date and an owner. You can look at how we run cybersecurity solutions or integrations if you want to see these controls translated into a delivery plan. For the contractual side, we keep a security requirements checklist for tender documents.
Frequently asked questions (FAQ)
Is a secret API key enough instead of OAuth?
It depends on who is calling. Between two systems on servers you control, a service key in a secret manager can be enough if it is resource-scoped and rotatable. If the call acts on behalf of a user, you need authorisation that can be withdrawn without changing a shared secret, which is what OAuth provides. The mistake is not choosing a key; it is giving that key a full user's rights.
How do I know the logs contain no secrets?
By testing, not by reading. Send a request carrying an authorization header with known values, then search the log for those values. Repeat on the error paths, because most leaks happen when a system dumps the whole request into an exception message. Add that test to the deployment pipeline so the mistake does not return after it is fixed.
Does signing replace TLS?
No. TLS protects the connection in transit; a signature protects the message after arrival and lets you verify who sent it. If TLS terminates at a proxy or gateway, the message may reach your service without that protection, and the signature still holds. That is why the two are used together rather than interchangeably.
What do we do with an old key nobody can trace?
Do not delete it at once, and do not leave it. First mirror or trace the traffic using it, or search gateway logs for its source, then notify the likely owner with a written revocation date. If nobody appears, revoke it in an announced window with a rollback plan. An unknown key is a reason to investigate quickly, not a reason to wait.
Sources
OWASP API Security Project — the most common API risks and how they are addressed.
OWASP Application Security Verification Standard — testable requirements for authentication and access control.
RFC 6749 — the OAuth 2.0 authorization framework.
RFC 9421 — HTTP message signatures and their time parameters.
RFC 2104 — HMAC keyed message authentication.
Cover image: Vishnu Mohanan, Unsplash License, via Unsplash.

