Skip to content

Commit

Permalink
Merge pull request #17 from sebassem/main
Browse files Browse the repository at this point in the history
Updating webapp authentication
  • Loading branch information
jtracey93 authored Jun 14, 2024
2 parents b4b061d + 861022f commit d48f273
Show file tree
Hide file tree
Showing 5 changed files with 40 additions and 9 deletions.
7 changes: 5 additions & 2 deletions .github/workflows/deployAzGovVizAccelerator.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,10 @@ name: DeployAzGovVizAccelerator

on:
workflow_dispatch:

inputs:
authorizedGroupId:
description: 'Authorized Group object Id to access the AzGovViz webapp'
required: true
jobs:
AzureGovernanceVisualizer:
runs-on: ubuntu-latest
Expand Down Expand Up @@ -32,6 +35,6 @@ jobs:
subscriptionId: ${{ secrets.SUBSCRIPTION_ID }}
resourceGroupName: ${{vars.RESOURCE_GROUP_NAME}}
template: ./bicep/webApp.bicep
parameters: ./bicep/webApp.parameters.json webAppName=${{vars.WEB_APP_NAME}} managementGroupId=${{secrets.MANAGEMENT_GROUP_ID}} clientId=${{ secrets.ENTRA_CLIENT_ID }} clientSecret=${{ secrets.ENTRA_CLIENT_SECRET }}
parameters: ./bicep/webApp.parameters.json webAppName=${{vars.WEB_APP_NAME}} managementGroupId=${{secrets.MANAGEMENT_GROUP_ID}} clientId=${{ secrets.ENTRA_CLIENT_ID }} clientSecret=${{ secrets.ENTRA_CLIENT_SECRET }} authorizedGroupId=${{github.event.inputs.AuthorizedGroupId}}
failOnStdErr: false

17 changes: 11 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -258,20 +258,24 @@ New-AzRoleAssignment `
1. Create an [app registration](https://learn.microsoft.com/entra/identity-platform/quickstart-register-app#register-an-application) in Microsoft Entra ID for your Azure App Web App.

In the Redirect URIs section, select Web for platform and type the URI in the following format: "https://<webapp_name>.azurewebsites.net/.auth/login/aad/callback"
1. Click on _Authentication_ and under _Implicit grant and hybrid flows_, enable ID tokens to allow OpenID Connect user sign-ins from App Service. Select Save.
2. Click on _Authentication_ and under _Implicit grant and hybrid flows_, enable ID tokens to allow OpenID Connect user sign-ins from App Service. Select Save.

![Screenshot showing enabling Open ID in app registration](./media/app_registration_openID.png)

1. From the left navigation, select Expose an API > Add > Save.
3. From the left navigation, select Expose an API > Add > Save.

![Screenshot showing exposing an API](./media/app_registration_expose_api.png)

![Screenshot showing exposing an API](./media/app_registration_expose_api_add.png)

1. Click on _Add a scope_ and provide the values as the screenshot.
4. Click on _Add a scope_ and provide the values as the screenshot.

![Screenshot showing adding a scope to the API](./media/app_registration_expose_api_addScope.png)

5. From the left navigation, select Manifest and set "groupMembershipClaims" to "SecurityGroup".

![Screenshot showing adding a scope to the API](./media/app_registration_groupsClaim.png)

**:keyboard: Use PowerShell:**

```powershell
Expand Down Expand Up @@ -312,6 +316,7 @@ $body = @"
"identifierUris" : [
"api://$webAppSPAppId"
],
"groupMembershipClaims" : "SecurityGroup",
"api": {
"oauth2PermissionScopes": [
{
Expand Down Expand Up @@ -423,9 +428,9 @@ gh api -X PUT /repos/$GitHubOrg/$GitHubRepository/actions/permissions/workflow -

![Screenshot showing the GitHub actions pane](./media/actions_pane.png)

1. Run the _DeployAzGovVizAccelerator_ workflow to initialize the accelerator, deploy the Azure Web App and configure Microsoft Entra authentication for it.
2. Run the _DeployAzGovVizAccelerator_ workflow to initialize the accelerator, deploy the Azure Web App and configure Microsoft Entra authentication for it. By default, the web app is accessible to any authenticated user in the current tenant. To limit access to certain users, provide the ObjectId of an Entra ID group.

![Screenshot showing deploying the DeployAzGovVizAccelerator workflow](./media/run_deploy_accelerator_action.png)
![Screenshot showing deploying the DeployAzGovVizAccelerator workflow](./media/run_deploy_accelerator_action_input.png)

![Screenshot showing the DeployAzGovVizAccelerator workflow executing](./media/deploy_accelerator_action_running.png)

Expand All @@ -445,7 +450,7 @@ gh api -X PUT /repos/$GitHubOrg/$GitHubRepository/actions/permissions/workflow -

![Screenshot showing editing the AzGovViz parameters](./media/adding_noPIM_parameter.png)

1. Then, run the _DeployAzGovViz_ workflow to deploy AzGovViz and publish it to the Azure Web App
3. Then, run the _DeployAzGovViz_ workflow to deploy AzGovViz and publish it to the Azure Web App

![Screenshot showing deploying AzGovViz](./media/deploy_AzGovViz_workflow.png)

Expand Down
25 changes: 24 additions & 1 deletion bicep/webApp.bicep
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,9 @@ param clientSecret string
@description('The AzGovViz management group ID')
param managementGroupId string

@description('The authorized groups IDs to access the web app')
param authorizedGroupId string

resource appServicePlan 'Microsoft.Web/serverfarms@2022-03-01' = {
name: appServicePlanName
location: location
Expand All @@ -42,7 +45,7 @@ resource appServicePlan 'Microsoft.Web/serverfarms@2022-03-01' = {
kind: kind
}

resource webApp 'Microsoft.Web/sites@2022-03-01' = {
resource webApp 'Microsoft.Web/sites@2023-01-01' = {
name: webAppName
location: location
properties: {
Expand Down Expand Up @@ -70,6 +73,11 @@ resource webApp 'Microsoft.Web/sites@2022-03-01' = {
redirectToProvider: 'azureActiveDirectory'
unauthenticatedClientAction: 'RedirectToLoginPage'
}
login: {
tokenStore: {
enabled: true
}
}
identityProviders: {
azureActiveDirectory: {
enabled: true
Expand All @@ -78,6 +86,20 @@ resource webApp 'Microsoft.Web/sites@2022-03-01' = {
clientId: clientId
clientSecretSettingName: 'AzureAdClientSecret'
}
validation: {
jwtClaimChecks: {
allowedGroups: [
authorizedGroupId
]
}
defaultAuthorizationPolicy: {
allowedPrincipals: {
groups: [
authorizedGroupId
]
}
}
}
}
}
}
Expand All @@ -87,6 +109,7 @@ resource webApp 'Microsoft.Web/sites@2022-03-01' = {
name: 'appsettings'
properties: {
AzureAdClientSecret: clientSecret
WEBSITE_AUTH_AAD_ALLOWED_TENANTS: tenantId
}
}

Expand Down
Binary file added media/app_registration_groupsClaim.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added media/run_deploy_accelerator_action_input.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit d48f273

Please sign in to comment.