I've set up Workload identity federation. Basically like this:
var applicationRegistrationDisplayName = 'GitHub Actions Application Deployer.'
var githubOIDCProvider = 'https://token.actions.githubusercontent.com'
var microsoftEntraAudience = 'api://AzureADTokenExchange'
var applicationRegistrationName = 'app-deployer'
resource GithubActionsApplication 'Microsoft.Graph/applications@v1.0' = {
uniqueName: applicationRegistrationName
displayName: applicationRegistrationDisplayName
resource githubFederatedIdentityCredential 'federatedIdentityCredentials@v1.0' = {
name: '${GithubActionsApplication.uniqueName}/githubFederatedIdentityCredential'
audiences: [microsoftEntraAudience]
description: 'Identity for application to deploy the root infrastructure.'
issuer: githubOIDCProvider
subject: GitHubActionsFederatedIdentitySubject
}
}
resource githubActionsServicePrincipal 'Microsoft.Graph/servicePrincipals@v1.0' = {
displayName: applicationRegistrationDisplayName
appId: GithubActionsApplication.appId
}
Then I added Managed Identity Federated Credentials from GitHub should be from trusted repository owners Azure BuiltIn Policy definition, since I was I thinking I should restrict allowed repositories across any possible federated identity trying to connect.
I'm however unsure now that what should be put into the allowedRepoOwners
array. So, here are the questions in my mind:
https://github.com/<organizationX>
, should I add there https://github.com/<organizationX>
or maybe organizationX
?https://github.com/<organizationX>/<RepoA>
, https://github.com/<organizationX>/<RepoB>
?It has occurred to me to just try out, but I'm also thinking how to read definitions like this to pull out information like this. Then also that maybe there is chance to improve documentation a bit, but I don't know where to do that.
What should be put to 'repoOwners' in Managed Identity Federated Credentials policy?
The allowedRepoOwners
array in the Managed Identity Federated Credentials policy
which contains the GitHub usernames or organizations that are trusted to federate credentials.
In order to limit federation to repositories owned by the organization, you can add organizationX to the allowedRepoOwners array
Here is the example: github.com/organizationX
To limit all repositories underneath that owner you can add an organization to the allowedRepoOwners array
, its enough to limit all repositories.
This will apply to all repositories owned by organizationX
and access control.