Giter VIP home page Giter VIP logo

terraform-azuread-github_oidc's People

Contributors

animal77 avatar ned1313 avatar robinmordasiewicz avatar sebelino avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

terraform-azuread-github_oidc's Issues

Add GraphAPI application Application.ReadWrite.OwnedBy role access to OIDC service principal

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:

  1. Creating a new App Registration
  2. Save the Application (client) ID for the Microsoft Entra app registration.
  3. Save the client secret for the Microsoft Entra app registration.
  4. Configure two parameters in SWA's Application Settings AZURE_CLIENT_ID, AZURE_CLIENT_SECRET
  5. Reference these settings in staticwebapp.config.json of the SWA
  6. Enjoy authentication via AD for users of the SWA

A 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.

Add support for multiple brances, tags, or environments

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.

"pull-request" vs. "pull_request"

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

deprecated attributes in use

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)

Change PR behavior

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.

Add tests for the module

Use the new testing framework in Terraform 1.6 to test the following options:

  • PR only
  • Single branch
  • Multiple branch
  • Multiple branch and PR
  • Single env
  • Multiple env
  • Multiple env and PR
  • Single tag
  • Multiple tags
  • Multiple tags and PR

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.