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

Federated credentials #1094

Merged
merged 155 commits into from
Jun 25, 2024
Merged

Federated credentials #1094

merged 155 commits into from
Jun 25, 2024

Conversation

freddydk
Copy link
Contributor

@freddydk freddydk commented May 31, 2024

If the AppSourceContext doesn't contain a clientSecret, then we assume that federated credentials have been assigned and are available, so we will try to get an ID_TOKEN and use clientAssertion instead
Same with other Auth Context's - if they contain a clientId and no clientSecret, we will use clientAssertion instead.

Azure_Credentials also supports app registrations or managed identities with federated credentials if it contains a clientId without a clientSecret

Here are the supported formats for the various auth contexts:

STORAGECONTEXT (for deliver to storage)

Managed Identity/Federated credential
{"storageAccountName":"storageaccountname","clientId":"08b6d80c-68cf-48f9-a5ff-b054326e2ec3","tenantId":"72f988bf-86f1-41af-91ab-2d7cd011db47","containerName":"{project}","blobName":"{version}/{project}-{type}.zip"}

App Registration/Federated credential
{"storageAccountName":"storageaccountname","clientId":"a26651f5-0e90-473c-b4f9-e96119aac8b8","tenantId":"72f988bf-86f1-41af-91ab-2d7cd011db47","containerName":"{project}","blobName":"{version}/{project}-{type}.zip"}

App Registration/Client Secret
{"storageAccountName":"storageaccountname","clientId":"a26651f5-0e90-473c-b4f9-e96119aac8b8","clientSecret":"OPXxxxxxxxxxxxxxxxxxxxxxxabge","tenantId":"72f988bf-86f1-41af-91ab-2d7cd011db47","containerName":"{project}","blobName":"{version}/{project}-{type}.zip"}

storageAccountName/sastoken
{"storageAccountName":"storageaccountname","sastoken":"sv=2022-11-02&ss=b&srt=sco&sp=rwdlaciytf&se=2024-08-06T20:22:08Z&st=2024-04-06T12:22:08Z&spr=https&sig=IZyIf5xxxxxxxxxxxxxxb5I%3D","containerName":"{project}","blobName":"{version}/{project}-{type}.zip"}

storageAccountName/storageAccountKey
{"storageAccountName":"storageaccountname","storageAccountKey":"JHFZErCyxxxxxxxxxxxxxxxxXQ==","containerName":"{project}","blobName":"{version}/{project}-{type}.zip"}

AZURE_CREDENTIALS (connection to Azure for secrets and signing)

Access Configuration = Azure role-based access control

Access Control:
Action          Role
Read secrets    Key Vault Secrets User
Sign Apps       Key Vault Crypto User + Key Vault Certificate User

Access Configuration = Vault Access Policy

Action          Permissions:
Read secrets    Secret permissions: Get, List
Sign apps       Cryptographic Operations: Sign + Certificate permissions: Get

Managed Identity/Federated credential
{"keyVaultName":"BuildVariables","clientId":"55ce849b-c99d-484c-8999-df9f8df958bd","tenantId":"72f988bf-86f1-41af-91ab-2d7cd011db47"}

App Registration/Federated credential
{"keyVaultName":"BuildVariables","clientId":"a26651f5-0e90-473c-b4f9-e96119aac8b8","tenantId":"72f988bf-86f1-41af-91ab-2d7cd011db47"}

App Registration/Client Secret
{"keyVaultName":"BuildVariables","clientId":"a26651f5-0e90-473c-b4f9-e96119aac8b8","clientSecret":"OPXxxxxxxxxxxxxxxxxxxxxxxabge","tenantId":"72f988bf-86f1-41af-91ab-2d7cd011db47"}

APPSOURCECONTEXT (for deliver to AppSource)

Managed identity not possible - as this is not an Azure resource

App Registration/Federated credential
{"clientId":"a26651f5-0e90-473c-b4f9-e96119aac8b8","tenantId":"72f988bf-86f1-41af-91ab-2d7cd011db47","Scopes":"https://api.partner.microsoft.com/.default"}

App Registration/Client Secret
{"clientId":"a26651f5-0e90-473c-b4f9-e96119aac8b8","clientSecret":"OPXxxxxxxxxxxxxxxxxxxxxxxabge","tenantId":"72f988bf-86f1-41af-91ab-2d7cd011db47","Scopes":"https://api.partner.microsoft.com/.default"}

AUTHCONTEXT (for deploy to Business Central)

Managed identity not possible - as this is not an Azure resource

Impersonation/RefreshToken
{"TenantID":"69cb4a05-4ea8-482d-9f33-10fb5cf7db05","Scopes":"https://api.businesscentral.dynamics.com/","RefreshToken":"0.AUUAxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx_s6Eo4YOI","ClientID":"1950a258-227b-4e31-a9cf-717495945fc2"}

App Registration/Federated credential
{"TenantID":"69cb4a05-4ea8-482d-9f33-10fb5cf7db05","Scopes":"https://api.businesscentral.dynamics.com/","ClientID":"a26651f5-0e90-473c-b4f9-e96119aac8b8"}

App Registration/Client Secret
{"TenantID":"69cb4a05-4ea8-482d-9f33-10fb5cf7db05","Scopes":"https://api.businesscentral.dynamics.com/","ClientID":"a26651f5-0e90-473c-b4f9-e96119aac8b8","ClientSecret":"OPXxxxxxxxxxxxxxxxxxxxxxxabge"}

TODOs

  • Add documentation in codesigning.md (rbac)
  • Add documentation for appSourceContext federated credentials
  • Add documentation for other auth contexts
  • Add aka.ms/algosecrets#secretname
  • Add End 2 End test testing all these auth methods

This PR also switches to always use the Az PowerShell module (instead of the deprecated AzureRM PowerShell module installed on GitHub Hosted Windows runners)

Fixes #947

@freddydk freddydk requested a review from a team as a code owner May 31, 2024 12:24
@freddydk freddydk marked this pull request as draft May 31, 2024 12:25
@freddydk freddydk changed the title Federated creds Federated credentials May 31, 2024
@freddydk freddydk requested review from aholstrup1 and mazhelez June 25, 2024 12:03
mazhelez
mazhelez previously approved these changes Jun 25, 2024
aholstrup1
aholstrup1 previously approved these changes Jun 25, 2024
@freddydk freddydk dismissed stale reviews from aholstrup1 and mazhelez via 0dc2016 June 25, 2024 13:11
@freddydk freddydk requested review from mazhelez and aholstrup1 June 25, 2024 13:12
aholstrup1
aholstrup1 previously approved these changes Jun 25, 2024
RELEASENOTES.md Outdated Show resolved Hide resolved
mazhelez
mazhelez previously approved these changes Jun 25, 2024
Co-authored-by: Maria Zhelezova <[email protected]>
@freddydk freddydk dismissed stale reviews from mazhelez and aholstrup1 via 8da8b79 June 25, 2024 13:41
@freddydk freddydk enabled auto-merge (squash) June 25, 2024 13:41
@freddydk freddydk requested review from aholstrup1 and mazhelez June 25, 2024 13:41
@freddydk freddydk merged commit 9aa6e6f into microsoft:main Jun 25, 2024
5 checks passed
@freddydk freddydk deleted the issue1093 branch September 5, 2024 12:44
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

AL-Go-PTE: Publish to Enviroment PROD fails
3 participants