Security & FinOps · Least privilege
The App Registration Factory That Cannot Hold a Secret
A federated automation identity creates and owns SSO, SAML and CI/CD app registrations with the narrowest Graph permission available, and no client secret of its own.
// Overview
A tiny bootstrap stack creates one automation identity whose only credential is a federated trust bound to one repo and one protected environment. A second stack, driven by that identity, declares dozens of app registrations with roles and group mappings, and publishes client details to the secrets manager for in-cluster use.
// The problem
Registrations were hand-built in the portal, credentials sprawled, and the automation that created them needed tenant-wide write power.
// Flow
- Bootstrapseparate stack creates the automation identity, avoiding a circular dependency
- Federated trustcredential bound to repo and environment subject claim
- Graph consentapplication permissions granted once by an admin
- Declare appmodule call adds app, roles, groups and redirect URIs; owner is the automation identity
- Planruns with a custom read-only role
- Reviewer approval gaterequired reviewer on the environment
- Applyapp, service principal, groups and role assignments created
- Publish credentialsclient details written to Vault per environment
- Detectdetection rules watch the automation identity itself
// Design decisions & guardrails
- Application.ReadWrite.OwnedBy instead of ReadWrite.All limits the blast radius to apps it owns; the trade-off (every app lists the identity as owner) is documented.
- Role management, PIM and user-write permissions are explicitly forbidden.
- A custom tenant-root role carries only the read actions Terraform refresh needs, instead of Reader.
- No wildcard federated credentials and no client secret on the automation identity.
- A one-time ownership backfill script supports --dry-run; a risk assessment and break-glass procedure are documented.
// Outcome
About 34 module invocations owned by an identity that holds no secret.