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

OSOE-688: Azure authentication with Service Principal Federated Credentials #255

Merged
merged 24 commits into from
Sep 28, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
24 commits
Select commit Hold shift + click to select a range
cc41cd1
Updating the login-to-azure action's parameter list for calling azure…
BenedekFarkas Sep 15, 2023
2dfe05c
Modifying the reusable workflows' call to the login-to-azure action
BenedekFarkas Sep 15, 2023
b9ee52c
Updating permissions and secrets of the reusable workflows calling lo…
BenedekFarkas Sep 15, 2023
8e30a3e
Adding the environment property to the reusable workflows' jobs
BenedekFarkas Sep 15, 2023
9ded176
Using the slot-name and destination-slot-name inputs to define the jo…
BenedekFarkas Sep 15, 2023
3b7d344
Disabling most of the steps in the Azure actions to test the authenti…
BenedekFarkas Sep 18, 2023
1442305
Fixing the secret names passed from reset-azure-environment to login-…
BenedekFarkas Sep 18, 2023
e686459
Adding comment to explain Azure authentication secrets, updating Work…
BenedekFarkas Sep 21, 2023
4f67b05
Merge remote-tracking branch 'origin/dev' into issue/OSOE-688
BenedekFarkas Sep 21, 2023
522ce6f
Adding missing required property to the CHECKOUT_TOKEN secrets
BenedekFarkas Sep 21, 2023
c8ad9a9
Updating other secrets in some of the workflows to have a required pr…
BenedekFarkas Sep 21, 2023
eccd213
Updating some workflow branch references to match this issue as expec…
BenedekFarkas Sep 21, 2023
60c03ea
Update Docs/Workflows.md
BenedekFarkas Sep 27, 2023
d0f3e11
Updating Workflows.md
BenedekFarkas Sep 27, 2023
6ca80f2
Updating comments/docs on Azure authentication secrets
BenedekFarkas Sep 27, 2023
d3e3cab
Adding logout-from-azure
BenedekFarkas Sep 27, 2023
5895f57
Fixing copypasta
BenedekFarkas Sep 27, 2023
d4b06d6
Testing the effectiveness of logout-from-azure on reset-azure-environ…
BenedekFarkas Sep 27, 2023
dfd9528
Apparently the recommended course of action for logging out from Azur…
BenedekFarkas Sep 27, 2023
5992722
Removing logout-from-azure stuff for now
BenedekFarkas Sep 27, 2023
6b916c7
Removing testing step from reset-azure-environment
BenedekFarkas Sep 27, 2023
5c8aa5c
Formatting
Piedone Sep 27, 2023
5a469f2
Revert "Disabling most of the steps in the Azure actions to test the …
BenedekFarkas Sep 28, 2023
5fc31a5
Restoring workflow branch references to dev
BenedekFarkas Sep 28, 2023
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 7 additions & 5 deletions .github/actions/login-to-azure/action.yml
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
name: Login to Azure
description: >
Logs in to Azure using a service principal. After a successful login, the action will set up the necessary credentials
and environment variables for the service to be able to access Azure resources. The service can then use these
credentials to make API calls to Azure services. Intentionally not documented in Actions.md since it's only meant for
internal use.
Logs in to Azure using OpenID Connect by impersonating a Service Principal or Managed Credential. After a successful
login, the action will set up the necessary credentials and environment variables for the service to be able to access
Azure resources. The service can then use these credentials to make API calls to Azure services. Intentionally not
documented in Actions.md since it's only meant for internal use.

inputs:
enable-az-ps-session:
Expand All @@ -18,5 +18,7 @@ runs:
# v1.4.6
uses: azure/login@92a5484dfaf04ca78a94597f4f19fea633851fa2
with:
creds: ${{ env.SERVICE_PRINCIPAL }}
client-id: ${{ env.AZURE_CLIENT_ID }}
tenant-id: ${{ env.AZURE_TENANT_ID }}
subscription-id: ${{ env.AZURE_SUBSCRIPTION_ID }}
enable-AzPSSession: ${{ inputs.enable-az-ps-session }}
1 change: 1 addition & 0 deletions .github/workflows/build-and-test-dotnet.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ on:
workflow_call:
secrets:
CHECKOUT_TOKEN:
required: false
description: >
The GitHub token to authenticate checkout. Pass in a GitHub personal access token if authenticated submodules
are used.
Expand Down
1 change: 1 addition & 0 deletions .github/workflows/build-and-test-orchard-core.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ on:
workflow_call:
secrets:
CHECKOUT_TOKEN:
required: false
description: >
The GitHub token to authenticate checkout. Pass in a GitHub personal access token if authenticated submodules
are used.
Expand Down
1 change: 1 addition & 0 deletions .github/workflows/build-dotnet.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ on:
workflow_call:
secrets:
CHECKOUT_TOKEN:
required: false
description: >
The GitHub token to authenticate checkout. Pass in a GitHub personal access token if authenticated submodules
are used.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,14 +19,17 @@ on:
required: true
description: The project key in JIRA, i.e. the prefix of issue keys (the "KEY" part of KEY-123).
DISCUSSION_JIRA_ISSUE_DESCRIPTION:
required: false
description: >
Template for the Jira issues to be created for GitHub discussions, using the internal markup format of Jira
(not Markdown). See the documentation for details.
ISSUE_JIRA_ISSUE_DESCRIPTION:
required: false
description: >
Template for the Jira issues to be created for GitHub issues, using the internal markup format of Jira (not
Markdown). See the documentation for details.
PULL_REQUEST_JIRA_ISSUE_DESCRIPTION:
required: false
description: >
Template for the Jira issues to be created for GitHub pull requests, using the internal markup format of Jira
(not Markdown). See the documentation for details.
Expand Down
32 changes: 30 additions & 2 deletions .github/workflows/deploy-orchard1-to-azure-app-service.yml
Piedone marked this conversation as resolved.
Show resolved Hide resolved
Original file line number Diff line number Diff line change
Expand Up @@ -3,17 +3,42 @@ name: Deploy Orchard 1 to Azure App Service
concurrency:
group: AzureDeployApp

permissions:
id-token: write
contents: read

on:
workflow_call:
secrets:
CHECKOUT_TOKEN:
Piedone marked this conversation as resolved.
Show resolved Hide resolved
required: false
description: >
The GitHub token to authenticate checkout. Pass in a GitHub personal access token if authenticated submodules
are used.
AZURE_APP_SERVICE_DEPLOYMENT_SERVICE_PRINCIPAL:

# These secrets are for OpenID Connect-based authentication with Azure services through the azure/login action
# (proxied by our login-to-azure action below). Check out its documentation on how these secrets are used:
# https://github.com/azure/login.
AZURE_APP_SERVICE_DEPLOYMENT_SERVICE_PRINCIPAL_ID:
required: true
description: >
The Application (client) ID of the Azure Service Principal or Managed Credential, which will be mapped to the
client-id parameter when calling azure/login.
AZURE_APP_SERVICE_DEPLOYMENT_AZURE_TENANT_ID:
required: true
description: >
The Tenant (Directory) ID of the Microsoft Entra ID tenant, which will be mapped to the tenant-id parameter
when calling azure/login.
AZURE_APP_SERVICE_DEPLOYMENT_AZURE_SUBSCRIPTION_ID:
required: true
description: >
The ID of the Azure Subscription the resources are under, which will be mapped to the subscription-id
parameter when calling azure/login. You can look this up e.g. in the Azure Portal under any resource or the
subscription itself.

AZURE_APP_SERVICE_PUBLISH_PROFILE:
required: true

MAINTENANCE_USER_NAME:
MAINTENANCE_PASSWORD:

Expand Down Expand Up @@ -90,6 +115,7 @@ jobs:
deploy:
runs-on: ${{ inputs.machine-type }}
name: Deploy to Azure App Service
environment: ${{ inputs.slot-name }}
defaults:
run:
shell: pwsh
Expand Down Expand Up @@ -122,7 +148,9 @@ jobs:
- name: Login to Azure
uses: Lombiq/GitHub-Actions/.github/actions/login-to-azure@dev
env:
SERVICE_PRINCIPAL: ${{ secrets.AZURE_APP_SERVICE_DEPLOYMENT_SERVICE_PRINCIPAL }}
AZURE_CLIENT_ID: ${{ secrets.AZURE_APP_SERVICE_DEPLOYMENT_SERVICE_PRINCIPAL_ID }}
AZURE_TENANT_ID: ${{ secrets.AZURE_APP_SERVICE_DEPLOYMENT_AZURE_TENANT_ID }}
AZURE_SUBSCRIPTION_ID: ${{ secrets.AZURE_APP_SERVICE_DEPLOYMENT_AZURE_SUBSCRIPTION_ID }}

- name: Initialize PowerShell modules
uses: Lombiq/Infrastructure-Scripts/.github/actions/initialize@dev
Expand Down
31 changes: 29 additions & 2 deletions .github/workflows/deploy-to-azure-app-service.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,39 @@ name: Deploy to Azure App Service
concurrency:
group: AzureDeployApp

permissions:
id-token: write
contents: read

on:
workflow_call:
secrets:
CHECKOUT_TOKEN:
required: false
description: >
The GitHub token to authenticate checkout. Pass in a GitHub personal access token if authenticated submodules
are used.
AZURE_APP_SERVICE_DEPLOYMENT_SERVICE_PRINCIPAL:

# These secrets are for OpenID Connect-based authentication with Azure services through the azure/login action
# (proxied by our login-to-azure action below). Check out its documentation on how these secrets are used:
# https://github.com/azure/login.
AZURE_APP_SERVICE_DEPLOYMENT_SERVICE_PRINCIPAL_ID:
required: true
description: >
The Application (client) ID of the Azure Service Principal or Managed Credential, which will be mapped to the
client-id parameter when calling azure/login.
AZURE_APP_SERVICE_DEPLOYMENT_AZURE_TENANT_ID:
required: true
description: >
The Tenant (Directory) ID of the Microsoft Entra ID tenant, which will be mapped to the tenant-id parameter
when calling azure/login.
AZURE_APP_SERVICE_DEPLOYMENT_AZURE_SUBSCRIPTION_ID:
required: true
description: >
The ID of the Azure Subscription the resources are under, which will be mapped to the subscription-id
parameter when calling azure/login. You can look this up e.g. in the Azure Portal under any resource or the
subscription itself.

AZURE_APP_SERVICE_PUBLISH_PROFILE:
required: true

Expand Down Expand Up @@ -113,6 +137,7 @@ jobs:
deploy:
runs-on: ${{ inputs.machine-type }}
name: Deploy to Azure App Service
environment: ${{ inputs.slot-name }}
defaults:
run:
shell: pwsh
Expand Down Expand Up @@ -172,7 +197,9 @@ jobs:
- name: Login to Azure
uses: Lombiq/GitHub-Actions/.github/actions/login-to-azure@dev
env:
SERVICE_PRINCIPAL: ${{ secrets.AZURE_APP_SERVICE_DEPLOYMENT_SERVICE_PRINCIPAL }}
AZURE_CLIENT_ID: ${{ secrets.AZURE_APP_SERVICE_DEPLOYMENT_SERVICE_PRINCIPAL_ID }}
AZURE_TENANT_ID: ${{ secrets.AZURE_APP_SERVICE_DEPLOYMENT_AZURE_TENANT_ID }}
AZURE_SUBSCRIPTION_ID: ${{ secrets.AZURE_APP_SERVICE_DEPLOYMENT_AZURE_SUBSCRIPTION_ID }}

- name: Initialize PowerShell modules
uses: Lombiq/Infrastructure-Scripts/.github/actions/initialize@dev
Expand Down
1 change: 1 addition & 0 deletions .github/workflows/msbuild-and-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ on:
workflow_call:
secrets:
CHECKOUT_TOKEN:
required: false
description: >
The GitHub token to authenticate checkout. Pass in a GitHub personal access token if authenticated submodules
are used.
Expand Down
1 change: 1 addition & 0 deletions .github/workflows/post-pull-request-checks-automation.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ on:
secrets:
# We can't access org secrets here so they need to be passed in.
MERGE_TOKEN:
required: false
description: >
An authentication token, like a personal access token (PAT), that provides write access to the repository and
can be used to merge the pull request. This is necessary because when a pull request is merged while being
Expand Down
1 change: 1 addition & 0 deletions .github/workflows/publish-nuget.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ on:
workflow_call:
secrets:
CHECKOUT_TOKEN:
required: false
description: >
The GitHub token to authenticate checkout. Pass in a GitHub personal access token if authenticated submodules
are used.
Expand Down
30 changes: 28 additions & 2 deletions .github/workflows/reset-azure-environment.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,36 @@ name: Reset Azure Environment
concurrency:
group: AzureResetEnvironment

permissions:
id-token: write
contents: read

on:
workflow_call:
secrets:
AZURE_APP_SERVICE_RESET_SERVICE_PRINCIPAL:
# These secrets are for OpenID Connect-based authentication with Azure services through the azure/login action
# (proxied by our login-to-azure action below). Check out its documentation on how these secrets are used:
# https://github.com/azure/login.
AZURE_APP_SERVICE_RESET_SERVICE_PRINCIPAL_ID:
required: true
description: >
The Application (client) ID of the Azure Service Principal or Managed Credential, which will be mapped to the
client-id parameter when calling azure/login.
AZURE_APP_SERVICE_RESET_AZURE_TENANT_ID:
required: true
description: >
The Tenant (Directory) ID of the Microsoft Entra ID tenant, which will be mapped to the tenant-id parameter
when calling azure/login.
AZURE_APP_SERVICE_RESET_AZURE_SUBSCRIPTION_ID:
required: true
description: >
The ID of the Azure Subscription the resources are under, which will be mapped to the subscription-id
parameter when calling azure/login. You can look this up e.g. in the Azure Portal under any resource or the
subscription itself.

MAINTENANCE_USER_NAME:
MAINTENANCE_PASSWORD:

inputs:
cancel-workflow-on-failure:
description: When set to "true", will cancel the current workflow run with all jobs if this workflow fails.
Expand Down Expand Up @@ -120,6 +143,7 @@ jobs:
reset-azure-environment:
runs-on: ${{ inputs.machine-type }}
name: Reset Azure Environment
environment: ${{ inputs.destination-slot-name }}
defaults:
run:
shell: pwsh
Expand All @@ -128,7 +152,9 @@ jobs:
- name: Login to Azure
uses: Lombiq/GitHub-Actions/.github/actions/login-to-azure@dev
env:
SERVICE_PRINCIPAL: ${{ secrets.AZURE_APP_SERVICE_RESET_SERVICE_PRINCIPAL }}
AZURE_CLIENT_ID: ${{ secrets.AZURE_APP_SERVICE_RESET_SERVICE_PRINCIPAL_ID }}
AZURE_TENANT_ID: ${{ secrets.AZURE_APP_SERVICE_RESET_AZURE_TENANT_ID }}
AZURE_SUBSCRIPTION_ID: ${{ secrets.AZURE_APP_SERVICE_RESET_AZURE_SUBSCRIPTION_ID }}

- name: Initialize PowerShell modules
uses: Lombiq/Infrastructure-Scripts/.github/actions/initialize@dev
Expand Down
1 change: 1 addition & 0 deletions .github/workflows/spelling.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ on:
workflow_call:
secrets:
CHECKOUT_TOKEN:
required: false
description: >
The GitHub token to authenticate checkout. Pass in a GitHub personal access token if authenticated submodules
are used.
Expand Down
29 changes: 27 additions & 2 deletions .github/workflows/swap-azure-web-app-slots.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,33 @@ name: Swap Azure Web App Slots
concurrency:
group: AzureSwapAppSlots

permissions:
id-token: write
contents: read

on:
workflow_call:
secrets:
AZURE_APP_SERVICE_SWAP_SERVICE_PRINCIPAL:
# These secrets are for OpenID Connect-based authentication with Azure services through the azure/login action
# (proxied by our login-to-azure action below). Check out its documentation on how these secrets are used:
# https://github.com/azure/login.
AZURE_APP_SERVICE_SWAP_SERVICE_PRINCIPAL_ID:
required: true
description: >
The Application (client) ID of the Azure Service Principal or Managed Credential, which will be mapped to the
client-id parameter when calling azure/login.
AZURE_APP_SERVICE_SWAP_AZURE_TENANT_ID:
required: true
description: >
The Tenant (Directory) ID of the Microsoft Entra ID tenant, which will be mapped to the tenant-id parameter
when calling azure/login.
AZURE_APP_SERVICE_SWAP_AZURE_SUBSCRIPTION_ID:
required: true
description: >
The ID of the Azure Subscription the resources are under, which will be mapped to the subscription-id
parameter when calling azure/login. You can look this up e.g. in the Azure Portal under any resource or the
subscription itself.

inputs:
cancel-workflow-on-failure:
description: When set to "true", will cancel the current workflow run with all jobs if this workflow fails.
Expand Down Expand Up @@ -52,6 +74,7 @@ jobs:
swap-azure-web-app-slots:
runs-on: ${{ inputs.machine-type }}
name: Swap Azure Web App Slots
environment: ${{ inputs.destination-slot-name }}
defaults:
run:
shell: pwsh
Expand All @@ -60,7 +83,9 @@ jobs:
- name: Login to Azure
uses: Lombiq/GitHub-Actions/.github/actions/login-to-azure@dev
env:
SERVICE_PRINCIPAL: ${{ secrets.AZURE_APP_SERVICE_SWAP_SERVICE_PRINCIPAL }}
AZURE_CLIENT_ID: ${{ secrets.AZURE_APP_SERVICE_SWAP_SERVICE_PRINCIPAL_ID }}
AZURE_TENANT_ID: ${{ secrets.AZURE_APP_SERVICE_SWAP_AZURE_TENANT_ID }}
AZURE_SUBSCRIPTION_ID: ${{ secrets.AZURE_APP_SERVICE_SWAP_AZURE_SUBSCRIPTION_ID }}

- name: Initialize PowerShell modules
uses: Lombiq/Infrastructure-Scripts/.github/actions/initialize@dev
Expand Down
30 changes: 28 additions & 2 deletions .github/workflows/swap-orchard1-azure-web-app-slots.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,36 @@ name: Swap Azure Web App Slots
concurrency:
group: AzureSwapAppSlots

permissions:
id-token: write
contents: read

on:
workflow_call:
secrets:
AZURE_APP_SERVICE_SWAP_SERVICE_PRINCIPAL:
# These secrets are for OpenID Connect-based authentication with Azure services through the azure/login action
# (proxied by our login-to-azure action below). Check out its documentation on how these secrets are used:
# https://github.com/azure/login.
AZURE_APP_SERVICE_SWAP_SERVICE_PRINCIPAL_ID:
required: true
description: >
The Application (client) ID of the Azure Service Principal or Managed Credential, which will be mapped to the
client-id parameter when calling azure/login.
AZURE_APP_SERVICE_SWAP_AZURE_TENANT_ID:
required: true
description: >
The Tenant (Directory) ID of the Microsoft Entra ID tenant, which will be mapped to the tenant-id parameter
when calling azure/login.
AZURE_APP_SERVICE_SWAP_AZURE_SUBSCRIPTION_ID:
required: true
description: >
The ID of the Azure Subscription the resources are under, which will be mapped to the subscription-id
parameter when calling azure/login. You can look this up e.g. in the Azure Portal under any resource or the
subscription itself.

MAINTENANCE_USER_NAME:
MAINTENANCE_PASSWORD:

inputs:
cancel-workflow-on-failure:
description: When set to "true", will cancel the current workflow run with all jobs if this workflow fails.
Expand Down Expand Up @@ -62,6 +85,7 @@ jobs:
swap-azure-web-app-slots:
runs-on: ${{ inputs.machine-type }}
name: Swap Azure Web App Slots
environment: ${{ inputs.destination-slot-name }}
defaults:
run:
shell: pwsh
Expand All @@ -70,7 +94,9 @@ jobs:
- name: Login to Azure
uses: Lombiq/GitHub-Actions/.github/actions/login-to-azure@dev
env:
SERVICE_PRINCIPAL: ${{ secrets.AZURE_APP_SERVICE_SWAP_SERVICE_PRINCIPAL }}
AZURE_CLIENT_ID: ${{ secrets.AZURE_APP_SERVICE_SWAP_SERVICE_PRINCIPAL_ID }}
AZURE_TENANT_ID: ${{ secrets.AZURE_APP_SERVICE_SWAP_AZURE_TENANT_ID }}
AZURE_SUBSCRIPTION_ID: ${{ secrets.AZURE_APP_SERVICE_SWAP_AZURE_SUBSCRIPTION_ID }}

- name: Initialize PowerShell modules
uses: Lombiq/Infrastructure-Scripts/.github/actions/initialize@dev
Expand Down
1 change: 1 addition & 0 deletions .github/workflows/test-analysis-failure.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ on:
workflow_call:
secrets:
CHECKOUT_TOKEN:
required: false
description: >
The GitHub token to authenticate checkout. Pass in a GitHub personal access token if authenticated submodules
are used.
Expand Down
Loading