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.

  • Terraform
  • Entra ID
  • Microsoft Graph
  • GitHub OIDC
  • Vault
  • GitHub Environments

// 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

The App Registration Factory That Cannot Hold a Secret flow1. Bootstrap → 2. Federated trust → 3. Graph consent → 4. Declare app → 5. Plan → 6. Reviewer approval → 7. Apply → 8. Publish credentials → 9. Detect01Bootstrap02Federated trust03Graph consent04Declare app05Plan06 · GATEReviewer approval07Apply08Publish credentials09Detect
  1. Bootstrapseparate stack creates the automation identity, avoiding a circular dependency
  2. Federated trustcredential bound to repo and environment subject claim
  3. Graph consentapplication permissions granted once by an admin
  4. Declare appmodule call adds app, roles, groups and redirect URIs; owner is the automation identity
  5. Planruns with a custom read-only role
  6. Reviewer approval gaterequired reviewer on the environment
  7. Applyapp, service principal, groups and role assignments created
  8. Publish credentialsclient details written to Vault per environment
  9. 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.

// Related