Service identity: identify service-to-service callers safely
A service identity distinguishes an application or job that calls an API on its own behalf. Design authentication, which proves which service is calling, separately from authorization, which defines what that identity may do. When the runtime supports it, consider short-lived platform-issued credentials or workload identity before long-lived shared keys; every option still needs least privilege and revocation.
A service identity distinguishes an application or job that calls an API on its own behalf. Design authentication, which proves which service is calling, separately from authorization, which defines what that identity may do. When the runtime supports it, consider short-lived platform-issued credentials or workload identity before long-lived shared keys; every option still needs least privilege and revocation.
Separate authentication from authorization
A service name or client_id is an identifier, not a secret or permission. Authentication proves the caller is the claimed service; authorization decides whether that identity may access a particular API, resource, or operation. A valid token must still have the right audience, scope, and resource-server policy. Avoid broad permissions shared by unrelated callers.
OAuth 2.0 Client Credentials applies to a confidential server-side client requesting protected resources under its own authority or a prior arrangement. The authorization server authenticates the client and issues an access token; the client should request only allowed scopes. This is not mandatory for every service environment. Follow the identity mechanisms supported by the runtime—such as cloud IAM, platform workload identity, or mutual TLS—and the actual threat model.
Choose an identity approach
| Environment or need | Approach to consider | Check before choosing |
|---|---|---|
| OAuth authorization server distributes API permissions through tokens | Server-to-server OAuth client authentication, such as Client Credentials | Is the client a confidential server component? Are token audience, scope, and lifetime appropriate? |
| Standard identity for dynamic Kubernetes or VM workloads | Platform identity or workload credentials based on SPIFFE/SPIRE | How are workloads attested? Are issuance, renewal, and revocation supported? What trust domains apply? |
| Existing API supports only static API keys or fixed secrets | Supply a restricted credential from a secrets manager | Are permissions, owner, expiry, rotation, revocation, and usage audit defined per key? |
SPIFFE defines identifying workloads with SPIFFE IDs and presenting identity through an SVID, a cryptographically verifiable document in X.509 certificate or JWT form. Operating SPIFFE/SPIRE requires configuring who issues that identity and which workloads may receive it. Implementations and trust settings vary by product and cloud; do not assume a document alone makes a setup work.
Introduce it safely
**Record the caller and purpose.** Define a service name separate from human accounts, its owning team, environment, target, and required operations. Keep development and production, and unrelated workloads, on separate identities where practical.
**Choose authentication supported by the runtime.** Use platform issuance and short-lived renewal where available. If OAuth or certificates are required, establish a dedicated issuance path. If only static keys are supported, retrieve a restricted credential at runtime from a secrets manager; keep it out of source control, images, and logs.
**Grant narrow permissions.** Allow only needed resources, operations, and time. Validate token issuer, signature or certificate chain, expiry, audience, and permissions; perform separate object-level authorization in the API.
**Plan renewal and incident response.** Renew before expiry and fail safely when issuance fails, a credential expires, or it is revoked. Document who revokes and replaces an exposed identity and how affected calls and audit records are investigated.
**Audit use and protect secrets.** Link issuance, use, denial, and revocation records to the calling identity, but never log tokens, private keys, or full secret values. Use TLS in transit across untrusted networks and track expiry, rotation, and revocation state.
Review checklist
Does each service identity have an owner and purpose, separate from human credentials and keys shared across unrelated services?
Are permissions limited to required targets and operations, with boundaries preventing access to other services’ resources?
Have credential lifetime, renewal, revocation, and exposure response been checked in the actual runtime?
Are tokens or certificates validated for the expected issuer, audience, and service?
Can successful and failed authentication/authorization be audited without recording secrets?
A sound service-identity design answers “which workload is verified, by whom, and what may it do for how long?” rather than merely “which secret should we put in configuration?” Check the runtime’s issuance and revocation capabilities, then design identity, permissions, lifetime, and audit together.
References
[RFC 6749: OAuth 2.0 Client Credentials Grant](https://www.rfc-editor.org/rfc/rfc6749.html#section-4.4)
[SPIFFE Concepts](https://spiffe.io/docs/latest/spiffe-about/spiffe-concepts/)
[OWASP Secrets Management Cheat Sheet](https://cheatsheetseries.owasp.org/cheatsheets/Secrets_Management_Cheat_Sheet.html)