ned1313 / terraform-azuread-github_oidc Goto Github PK
View Code? Open in Web Editor NEWTerraform module to create an Azure AD application, service principal, and federated identity for GitHub-based OIDC authentication.
License: MIT License
Terraform module to create an Azure AD application, service principal, and federated identity for GitHub-based OIDC authentication.
License: MIT License
Motivation:
Suppose the SP created here is running Terraform to create a static web app (SWA). Further suppose that SWA requires custom authentication to be configured as described here. The TL;DR of how this is done is:
AZURE_CLIENT_ID
, AZURE_CLIENT_SECRET
staticwebapp.config.json
of the SWAA sample terraform script to accomplish 1-4 above is as follows:
# Create SP
resource "azuread_application_registration" "my_static_frontend" {
display_name = "My Static Frontend"
description = "My cool application"
}
# Create password
resource "azuread_application_password" "my_static_frontend" {
application_id = azuread_application_registration.my_static_frontend.id
}
# create the SWA
resource "azurerm_static_site" "my_static_frontend" {
name = "stapp-my-frontend-${local.name_suffix}"
resource_group_name = azurerm_resource_group.rg.name
location = azurerm_resource_group.rg.location
app_settings = {
"AZURE_CLIENT_ID" = azuread_application_registration.my_static_frontend.client_id
"AZURE_CLIENT_SECRET" = azuread_application_password.my_static_frontend.value
}
tags = local.common_tags
}
This script fails because the OIDC SP has insufficient permissions to create the application. It needs Microsoft Graph's Application.ReadWrite.OwnedBy. Note that Application.ReadWrite.All
would do but we prefer this in keeping with the principle of using the least required privilege.
Update the following variable names and types to list(string)
:
environment_name
-> environment_names
ref_branch
-> ref_branches
ref_tag
-> ref_tags
This is to support using the same service principal for multiple branches, environments, or tags.
Output Without Description, Severity: INFO, Results: 4
Description: All outputs should contain a valid description.
Platform: Terraform
Learn more about this vulnerability: https://docs.kics.io/latest/queries/terraform-queries/common/59312e8a-a64e-41e7-a252-618533dd1ea8
Hi, I tried setting entity_type
to "pull-request"
but I encountered an error:
Error: : AADSTS70021: No matching federated identity record found for presented assertion. Assertion Issuer: 'https://token.actions.githubusercontent.com/'. Assertion Subject: 'repo:algodx-ab/infrastructure:pull_request'. Assertion Audience: 'api://AzureADTokenExchange'. https://docs.microsoft.com/en-us/azure/active-directory/develop/workload-identity-federation
However, setting the entity_type
to "pull_request"
fixed the problem to me. It appears that Azure AD expects the string to be snake cased, as shown at 11:30 in your tutorial: https://youtu.be/10ljwwJ3V30?t=690
To support multiple federated identity credentials, the name and description needs to be updated. It should also be a little shorter and more accurate.
Seeing this issue
Warning: Argument is deprecated
│
│ with module.oidc_sp["nonprd"].azuread_application_federated_identity_credential.oidc,
│ on .terraform/modules/oidc_sp/main.tf line 13, in resource "azuread_application_federated_identity_credential" "oidc":
│ 13: application_object_id = azuread_application.oidc.object_id
│
│ The `application_object_id` property has been replaced with the `application_id` property and will be removed in version 3.0 of the AzureAD
│ provider
│
│ (and 3 more similar warnings elsewhere)
Add an optional argument to create a PR federated identity credential along with the branch, tag, or environment based-credential. If the credential type is PR, then ignore the create_pr_identity
field.
Use the new testing framework in Terraform 1.6 to test the following options:
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.