Azure Auth Helper

Authenticate to Azure Resource Manager using the VM's system-assigned managed identity instead of a stored client secret.

gl0di Updated

File contents

Azure Auth Helper

Fetches an OAuth2 token from Azure's Instance Metadata Service (IMDS) managed-identity endpoint -- the vendor-recommended alternative to a static Azure AD app secret -- and uses it to call Azure Resource Manager.

Usage

TOKEN=$(curl -s -H "Metadata: true" \
  "http://169.254.169.254/metadata/identity/oauth2/token?api-version=2018-02-01&resource=https://management.azure.com/" \
  | jq -r '.access_token')

curl -s -H "Authorization: Bearer $TOKEN" \
  "https://management.azure.com/subscriptions?api-version=2020-01-01"

gl0di/clawseccheck/tree/main/fixtures/warn_b339_azure_managed_identity/skills/azure-auth-helper commit a42eb6479e

Frequently asked questions

npx skillmds@latest add gl0di/azure-auth-helper