Cloud & Infrastructure

Managed Identity & Least-Privilege Access

Intermediate

The best secret is the one that does not exist. Managed identities let services authenticate to each other and to the platform with no stored credential at all. Least privilege makes sure that whatever an identity can do is the minimum it needs. Together they remove both the secret to steal and the damage stealing it would cause.

Every credential you store is one you can leak, must rotate, and have to protect. Managed identities remove that risk for service-to-service and service-to-platform access. The platform issues short-lived tokens to the workload's own identity, so there is no connection string or API key sitting anywhere to be exposed. Where a managed identity is not possible, use a vault-held, rotated secret instead. Never use a static credential in config.

Least privilege is the other half. Each identity (human, service, or pipeline) should hold the narrowest role, on the narrowest scope, for the shortest time that lets it work. The Finperiti pattern of secrets in plain config is exactly what managed identity removes. And broad standing access is exactly what least privilege stops from becoming a disaster.

Authenticate without stored secrets

Grant the least that works

Stored key, broad role // connection string with an account key, in config
"Storage": "...;AccountKey=base64key=="
// identity granted: Contributor on the whole subscription

A long-lived key that can leak, plus a role that can change anything in the subscription. One exposure compromises everything, not just the one storage account.

Managed identity, scoped role // no secret anywhere; the app's managed identity authenticates
blobClient = new BlobServiceClient(uri, new DefaultAzureCredential());
// role assignment: 'Storage Blob Data Contributor' on THIS account only

Nothing to steal. Even if the workload is compromised, the identity can only touch the one storage account it was scoped to.

Self-review checklist

Why it matters: Stored credentials and over-broad access turn a small compromise into a total one. A single leaked key with Contributor rights can hand over the whole estate. Managed identity removes the credential entirely, and least privilege makes sure that whatever does get compromised can do the least possible harm.