Skip to content

Commit d48f273

Browse files
authored
Merge pull request #17 from sebassem/main
Updating webapp authentication
2 parents b4b061d + 861022f commit d48f273

File tree

5 files changed

+40
-9
lines changed

5 files changed

+40
-9
lines changed

.github/workflows/deployAzGovVizAccelerator.yml

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,10 @@ name: DeployAzGovVizAccelerator
22

33
on:
44
workflow_dispatch:
5-
5+
inputs:
6+
authorizedGroupId:
7+
description: 'Authorized Group object Id to access the AzGovViz webapp'
8+
required: true
69
jobs:
710
AzureGovernanceVisualizer:
811
runs-on: ubuntu-latest
@@ -32,6 +35,6 @@ jobs:
3235
subscriptionId: ${{ secrets.SUBSCRIPTION_ID }}
3336
resourceGroupName: ${{vars.RESOURCE_GROUP_NAME}}
3437
template: ./bicep/webApp.bicep
35-
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 }}
38+
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}}
3639
failOnStdErr: false
3740

README.md

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -258,20 +258,24 @@ New-AzRoleAssignment `
258258
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.
259259

260260
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"
261-
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.
261+
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.
262262

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

265-
1. From the left navigation, select Expose an API > Add > Save.
265+
3. From the left navigation, select Expose an API > Add > Save.
266266

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

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

271-
1. Click on _Add a scope_ and provide the values as the screenshot.
271+
4. Click on _Add a scope_ and provide the values as the screenshot.
272272

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

275+
5. From the left navigation, select Manifest and set "groupMembershipClaims" to "SecurityGroup".
276+
277+
![Screenshot showing adding a scope to the API](./media/app_registration_groupsClaim.png)
278+
275279
**:keyboard: Use PowerShell:**
276280

277281
```powershell
@@ -312,6 +316,7 @@ $body = @"
312316
"identifierUris" : [
313317
"api://$webAppSPAppId"
314318
],
319+
"groupMembershipClaims" : "SecurityGroup",
315320
"api": {
316321
"oauth2PermissionScopes": [
317322
{
@@ -423,9 +428,9 @@ gh api -X PUT /repos/$GitHubOrg/$GitHubRepository/actions/permissions/workflow -
423428

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

426-
1. Run the _DeployAzGovVizAccelerator_ workflow to initialize the accelerator, deploy the Azure Web App and configure Microsoft Entra authentication for it.
431+
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.
427432

428-
![Screenshot showing deploying the DeployAzGovVizAccelerator workflow](./media/run_deploy_accelerator_action.png)
433+
![Screenshot showing deploying the DeployAzGovVizAccelerator workflow](./media/run_deploy_accelerator_action_input.png)
429434

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

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

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

448-
1. Then, run the _DeployAzGovViz_ workflow to deploy AzGovViz and publish it to the Azure Web App
453+
3. Then, run the _DeployAzGovViz_ workflow to deploy AzGovViz and publish it to the Azure Web App
449454

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

bicep/webApp.bicep

Lines changed: 24 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,9 @@ param clientSecret string
3333
@description('The AzGovViz management group ID')
3434
param managementGroupId string
3535

36+
@description('The authorized groups IDs to access the web app')
37+
param authorizedGroupId string
38+
3639
resource appServicePlan 'Microsoft.Web/serverfarms@2022-03-01' = {
3740
name: appServicePlanName
3841
location: location
@@ -42,7 +45,7 @@ resource appServicePlan 'Microsoft.Web/serverfarms@2022-03-01' = {
4245
kind: kind
4346
}
4447

45-
resource webApp 'Microsoft.Web/sites@2022-03-01' = {
48+
resource webApp 'Microsoft.Web/sites@2023-01-01' = {
4649
name: webAppName
4750
location: location
4851
properties: {
@@ -70,6 +73,11 @@ resource webApp 'Microsoft.Web/sites@2022-03-01' = {
7073
redirectToProvider: 'azureActiveDirectory'
7174
unauthenticatedClientAction: 'RedirectToLoginPage'
7275
}
76+
login: {
77+
tokenStore: {
78+
enabled: true
79+
}
80+
}
7381
identityProviders: {
7482
azureActiveDirectory: {
7583
enabled: true
@@ -78,6 +86,20 @@ resource webApp 'Microsoft.Web/sites@2022-03-01' = {
7886
clientId: clientId
7987
clientSecretSettingName: 'AzureAdClientSecret'
8088
}
89+
validation: {
90+
jwtClaimChecks: {
91+
allowedGroups: [
92+
authorizedGroupId
93+
]
94+
}
95+
defaultAuthorizationPolicy: {
96+
allowedPrincipals: {
97+
groups: [
98+
authorizedGroupId
99+
]
100+
}
101+
}
102+
}
81103
}
82104
}
83105
}
@@ -87,6 +109,7 @@ resource webApp 'Microsoft.Web/sites@2022-03-01' = {
87109
name: 'appsettings'
88110
properties: {
89111
AzureAdClientSecret: clientSecret
112+
WEBSITE_AUTH_AAD_ALLOWED_TENANTS: tenantId
90113
}
91114
}
92115

386 KB
Loading
271 KB
Loading

0 commit comments

Comments
 (0)