Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add Auth Options: User-Managed Identity, System-Managed Identity, and AzDO Workload Identity Federation #545

Open
wants to merge 27 commits into
base: main
Choose a base branch
from

Conversation

ianjensenisme
Copy link
Contributor

This pull request introduces new authentication methods for the Power Platform provider in Terraform. The key changes include adding support for Managed Identity and Workload Identity Federation, along with the necessary configuration updates and new methods for handling these authentication mechanisms.

Documentation Updates:

  • Added sections for "Authenticating to Power Platform using a Managed Identity" and "Authenticating to Power Platform using Workload Identity Federation" in docs/index.md. [1] [2] [3]

Codebase Enhancements:

  • Introduced new methods in internal/api/auth.go to handle authentication using User-Managed Identity, System-Managed Identity, and Azure DevOps Workload Identity Federation. [1] [2]

Configuration Changes:

  • Added UseMsi and AzDOServiceConnectionID to the ProviderConfig struct in internal/config/config.go and updated related methods to check for these configurations. [1] [2] [3] [4] [5]

Environment Variables:

Provider Configuration:

  • Updated the provider schema and configuration logic in internal/provider/provider.go to include the new authentication options. [1] [2] [3]

docs/index.md Show resolved Hide resolved
#### System-Managed Identity

1. [Enable system-managed identity on an Azure resource](https://learn.microsoft.com/en-us/entra/identity/managed-identities-azure-resources/overview)
1. [Register the managed identity with the Power Platform](https://learn.microsoft.com/en-us/power-platform/admin/powershell-create-service-principal) using the Application ID from the enterprise application for the system-managed identity resource.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

shouldn't we point to our example how to do it with TF?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@mawasile which example are you thinking of? The only one I'm aware of is in https://microsoft.github.io/terraform-provider-power-platform/#authentication , but it points at the same link that I've included here.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.


We recomend using Environment Variables to pass the credentials to the provider.
1. [Create a User-Managed Identity resource](https://learn.microsoft.com/en-us/entra/identity/managed-identities-azure-resources/overview)
1. [Register the Managed Identity with the Power Platform](https://learn.microsoft.com/en-us/power-platform/admin/powershell-create-service-principal) using the Client ID from the user-managed identity resource.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

same here

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@mawasile which example are you thinking of? The only one I'm aware of is in https://microsoft.github.io/terraform-provider-power-platform/#authentication , but it points at the same link that I've included here.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@@ -281,10 +338,16 @@ func (client *Auth) GetTokenForScopes(ctx context.Context, scopes []string) (*st
token, tokenExpiry, err = client.AuthenticateClientSecret(ctx, scopes)
case client.config.IsCliProvided():
token, tokenExpiry, err = client.AuthenticateUsingCli(ctx, scopes)
case client.config.IsAzDOWorkloadIdentityFederationProvided():
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do I get that right? Now we have a dedicated AzDO setup but for GitHub one has to use generic Oidc auth? Maybe we should mention that somewhere because now it looks that github is not supported at all?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah I think the core limitation is that azidentity ONLY supports newAzurePipelinesCredential and doesn't have a similar analog for GitHub. I've added a note to the new section in the documentation to explain that we still support hands-off auth for GitHub, you just have to fall back to OIDC.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

cool

internal/provider/provider.go Show resolved Hide resolved
@ianjensenisme ianjensenisme requested a review from mawasile January 6, 2025 19:08
mattdot
mattdot previously approved these changes Jan 7, 2025
client.config.ClientId,
client.config.AzDOServiceConnectionID,
client.config.OidcRequestToken,
&azidentity.AzurePipelinesCredentialOptions{}, // Auxiliary tenants could be defined here
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Add aux tenants

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request security
Projects
None yet
Development

Successfully merging this pull request may close these issues.

OIDC Azure DevOps Workload Identity Managed Identity for the provider authentication
3 participants