Skip to content

Commit 02c6753

Browse files
committed
Replace back-office group requirement with platform Easy Auth and auto-bootstrap Entra app registration
1 parent 6296a0c commit 02c6753

13 files changed

Lines changed: 137 additions & 131 deletions

File tree

.github/workflows/_deploy-infrastructure.yml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,9 @@ on:
3434
required: false
3535
type: string
3636
default: "-"
37+
back_office_entra_client_id:
38+
required: true
39+
type: string
3740
postgres_admin_object_id:
3841
required: true
3942
type: string
@@ -84,6 +87,7 @@ jobs:
8487
id: deploy_cluster
8588
env:
8689
POSTGRES_ADMIN_OBJECT_ID: ${{ inputs.postgres_admin_object_id }}
90+
BACK_OFFICE_ENTRA_CLIENT_ID: ${{ inputs.back_office_entra_client_id }}
8791
GOOGLE_OAUTH_CLIENT_ID: ${{ vars.GOOGLE_OAUTH_CLIENT_ID }}
8892
GOOGLE_OAUTH_CLIENT_SECRET: ${{ secrets.GOOGLE_OAUTH_CLIENT_SECRET }}
8993
STRIPE_PUBLISHABLE_KEY: ${{ vars.STRIPE_PUBLISHABLE_KEY }}
@@ -169,6 +173,7 @@ jobs:
169173
id: deploy_cluster
170174
env:
171175
POSTGRES_ADMIN_OBJECT_ID: ${{ inputs.postgres_admin_object_id }}
176+
BACK_OFFICE_ENTRA_CLIENT_ID: ${{ inputs.back_office_entra_client_id }}
172177
GOOGLE_OAUTH_CLIENT_ID: ${{ vars.GOOGLE_OAUTH_CLIENT_ID }}
173178
GOOGLE_OAUTH_CLIENT_SECRET: ${{ secrets.GOOGLE_OAUTH_CLIENT_SECRET }}
174179
STRIPE_PUBLISHABLE_KEY: ${{ vars.STRIPE_PUBLISHABLE_KEY }}

.github/workflows/cloud-infrastructure.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@ jobs:
3838
cluster_location: ${{ vars.STAGING_CLUSTER_LOCATION }}
3939
domain_name: ${{ vars.STAGING_DOMAIN_NAME }}
4040
back_office_domain_name: ${{ vars.STAGING_BACK_OFFICE_DOMAIN_NAME || '-' }}
41+
back_office_entra_client_id: ${{ vars.STAGING_BACK_OFFICE_ENTRA_CLIENT_ID }}
4142
postgres_admin_object_id: ${{ vars.STAGING_POSTGRES_ADMIN_OBJECT_ID }}
4243
production_service_principal_object_id: ${{ vars.PRODUCTION_SERVICE_PRINCIPAL_OBJECT_ID }}
4344

@@ -57,5 +58,6 @@ jobs:
5758
cluster_location: ${{ vars.PRODUCTION_CLUSTER1_LOCATION }}
5859
domain_name: ${{ vars.PRODUCTION_DOMAIN_NAME }}
5960
back_office_domain_name: ${{ vars.PRODUCTION_BACK_OFFICE_DOMAIN_NAME || '-' }}
61+
back_office_entra_client_id: ${{ vars.PRODUCTION_BACK_OFFICE_ENTRA_CLIENT_ID }}
6062
postgres_admin_object_id: ${{ vars.PRODUCTION_POSTGRES_ADMIN_OBJECT_ID }}
6163
tenant_id: ${{ vars.TENANT_ID }}

application/AppHost/Program.cs

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -81,8 +81,6 @@
8181
.WithReference(azureStorage)
8282
.WaitFor(accountDatabase);
8383

84-
var backOfficeGroupId = builder.Configuration["BackOffice:GroupId"];
85-
8684
var accountApi = builder
8785
.AddProject<Account_Api>("account-api")
8886
.WithEnvironment("KESTREL_PORT", ports.AccountApi.ToString())
@@ -93,7 +91,6 @@
9391
.WithEnvironment("OAUTH_PUBLIC_URL", "https://localhost:" + ports.AppGateway)
9492
.WithEnvironment("Hostnames__App", appHostname)
9593
.WithEnvironment("BackOffice__Host", backOfficeHostname)
96-
.WithEnvironment("BackOffice__GroupId", backOfficeGroupId ?? string.Empty)
9794
.WithReference(accountDatabase)
9895
.WithReference(azureStorage)
9996
.WithEnvironment("OAuth__Google__ClientId", googleOAuthClientId)

application/account/Tests/BackOffice/BackOfficeEndpointBaseTest.cs

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ public abstract class BackOfficeEndpointBaseTest : IDisposable
3333
protected readonly Faker Faker = new();
3434
private readonly WebApplicationFactory<Program> _webApplicationFactory;
3535

36-
protected BackOfficeEndpointBaseTest(string? configuredGroupId = null)
36+
protected BackOfficeEndpointBaseTest()
3737
{
3838
Environment.SetEnvironmentVariable(SinglePageAppConfiguration.PublicUrlKey, TestPublicUrl);
3939
Environment.SetEnvironmentVariable(SinglePageAppConfiguration.CdnUrlKey, $"{TestPublicUrl}/account");
@@ -62,10 +62,6 @@ protected BackOfficeEndpointBaseTest(string? configuredGroupId = null)
6262
// user-facing host use app.test.localhost.
6363
["Hostnames:App"] = "app.test.localhost"
6464
};
65-
if (configuredGroupId is not null)
66-
{
67-
backOfficeSettings["BackOffice:GroupId"] = configuredGroupId;
68-
}
6965

7066
configuration.AddInMemoryCollection(backOfficeSettings);
7167
}

application/account/Tests/BackOffice/GroupRequirementTests.cs

Lines changed: 0 additions & 59 deletions
This file was deleted.

application/shared-kernel/SharedKernel/Authentication/BackOfficeIdentity/BackOfficeGroupRequirement.cs

Lines changed: 0 additions & 33 deletions
This file was deleted.

application/shared-kernel/SharedKernel/Authentication/BackOfficeIdentity/BackOfficeHostOptions.cs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,4 @@ public sealed class BackOfficeHostOptions
88

99
[Required(AllowEmptyStrings = false)]
1010
public string Host { get; init; } = string.Empty;
11-
12-
public string? GroupId { get; init; }
1311
}

application/shared-kernel/SharedKernel/Authentication/BackOfficeIdentity/BackOfficeIdentityDefaults.cs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,4 @@ public static class BackOfficeIdentityDefaults
2424
public const string LogoutPath = "/.auth/logout";
2525

2626
public const string AccessDeniedPath = "/access-denied";
27-
28-
public const string BackOfficeGroupIdEnvironmentVariable = "BACK_OFFICE_GROUP_ID";
2927
}

application/shared-kernel/SharedKernel/Configuration/ApiDependencyConfiguration.cs

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
using Microsoft.AspNetCore.Authentication.JwtBearer;
2-
using Microsoft.AspNetCore.Authorization;
32
using Microsoft.AspNetCore.Builder;
43
using Microsoft.AspNetCore.Hosting;
54
using Microsoft.AspNetCore.HttpOverrides;
@@ -247,15 +246,12 @@ private IServiceCollection AddAuthConfiguration()
247246
)
248247
.AddScheme<BackOfficeIdentityOptions, BackOfficeIdentityHandler>(BackOfficeIdentityDefaults.AuthenticationScheme, _ => { });
249248

250-
services.AddSingleton<IAuthorizationHandler, BackOfficeGroupAuthorizationHandler>();
251-
252249
return services.AddAuthorization(authOptions =>
253250
{
254251
authOptions.AddPolicy(BackOfficeIdentityDefaults.PolicyName, policy =>
255252
{
256253
policy.AuthenticationSchemes = [BackOfficeIdentityDefaults.AuthenticationScheme];
257254
policy.RequireAuthenticatedUser();
258-
policy.AddRequirements(new BackOfficeGroupRequirement());
259255
}
260256
);
261257
}

cloud-infrastructure/cluster/deploy-cluster.sh

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,11 +31,17 @@ if [[ "$BACK_OFFICE_DOMAIN_NAME" == "-" ]]; then
3131
BACK_OFFICE_DOMAIN_NAME=""
3232
fi
3333

34+
if [[ -z "$BACK_OFFICE_ENTRA_CLIENT_ID" ]]; then
35+
echo "ERROR: BACK_OFFICE_ENTRA_CLIENT_ID is required. Run 'dotnet run --project developer-cli -- deploy' to bootstrap." >&2
36+
exit 1
37+
fi
38+
3439
export UNIQUE_PREFIX
3540
export ENVIRONMENT
3641
export LOCATION=$CLUSTER_LOCATION
3742
export DOMAIN_NAME
3843
export BACK_OFFICE_DOMAIN_NAME
44+
export BACK_OFFICE_ENTRA_CLIENT_ID
3945
export POSTGRES_ADMIN_OBJECT_ID
4046
export GOOGLE_OAUTH_CLIENT_ID
4147
export GOOGLE_OAUTH_CLIENT_SECRET

0 commit comments

Comments
 (0)