Skip to content

Commit be5e01a

Browse files
committed
Split back-office into its own ACA container app with platform Easy Auth
1 parent e735c31 commit be5e01a

5 files changed

Lines changed: 59 additions & 22 deletions

File tree

.github/workflows/_deploy-infrastructure.yml

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -116,16 +116,16 @@ jobs:
116116
fi
117117
118118
if [[ "${{ inputs.back_office_domain_name }}" != "" ]] && [[ "${{ inputs.back_office_domain_name }}" != "-" ]]; then
119-
# Check if account-api already has the back-office custom domain configured
120-
account_api_details=$(az containerapp show --name account-api --resource-group $CLUSTER_RESOURCE_GROUP_NAME 2>&1 || echo "")
121-
account_api_custom_domains=$(echo "$account_api_details" | jq -r '.properties.configuration.ingress.customDomains // []')
119+
# Check if back-office already has the back-office custom domain configured
120+
back_office_details=$(az containerapp show --name back-office --resource-group $CLUSTER_RESOURCE_GROUP_NAME 2>&1 || echo "")
121+
back_office_custom_domains=$(echo "$back_office_details" | jq -r '.properties.configuration.ingress.customDomains // []')
122122
123-
if [[ "$account_api_custom_domains" != "[]" ]] && [[ "$account_api_custom_domains" != "null" ]]; then
124-
echo "$(date +"%Y-%m-%dT%H:%M:%S") Custom domain '${{ inputs.back_office_domain_name }}' is already configured correctly on account-api."
123+
if [[ "$back_office_custom_domains" != "[]" ]] && [[ "$back_office_custom_domains" != "null" ]]; then
124+
echo "$(date +"%Y-%m-%dT%H:%M:%S") Custom domain '${{ inputs.back_office_domain_name }}' is already configured correctly on back-office."
125125
else
126126
echo "$(date +"%Y-%m-%dT%H:%M:%S") Please add the following DNS entries for the back-office hostname and then retry:"
127127
echo "- A TXT record with the name 'asuid.${{ inputs.back_office_domain_name }}' and the value '$custom_domain_verification_id'."
128-
echo "- A CNAME record with the Host name '${{ inputs.back_office_domain_name }}' that points to address 'account-api.$default_domain'."
128+
echo "- A CNAME record with the Host name '${{ inputs.back_office_domain_name }}' that points to address 'back-office.$default_domain'."
129129
fi
130130
fi
131131
else

.gitignore

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,9 @@
33
##
44
## Get latest from https://github.com/github/gitignore/blob/master/VisualStudio.gitignore
55

6-
# Bicep generated parameter files
6+
# Bicep generated artifacts
77
cloud-infrastructure/cluster/main-cluster.parameters.json
8+
cloud-infrastructure/cluster/main-cluster.json
89

910
# User-specific files
1011
*.rsuser

cloud-infrastructure/cluster/deploy-cluster.sh

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -93,18 +93,18 @@ then
9393
custom_domain_verification_id=$(echo "$env_details" | jq -r '.properties.customDomainConfiguration.customDomainVerificationId')
9494
default_domain=$(echo "$env_details" | jq -r '.properties.defaultDomain')
9595

96-
# Display instructions for setting up DNS entries. Both the user-facing domain (served by app-gateway)
97-
# and the back-office domain (served by account-api directly, since EasyAuth runs at the platform layer)
98-
# require their own asuid TXT + CNAME records. Print both when configured so the user can see every
99-
# missing record at once instead of one per redeploy.
96+
# Display instructions for setting up DNS entries. The user-facing domain is served by the app-gateway
97+
# container, while the back-office domain is served by its own dedicated back-office container with
98+
# platform-level Easy Auth. Print both when configured so the user can see every missing record at
99+
# once instead of one per redeploy.
100100
echo -e "${RED}$(date +"%Y-%m-%dT%H:%M:%S") Please add the following DNS entries and then retry:${RESET}"
101101
if [[ -n "$DOMAIN_NAME" ]]; then
102102
echo -e "${RED}- A TXT record with the name 'asuid.$DOMAIN_NAME' and the value '$custom_domain_verification_id'.${RESET}"
103103
echo -e "${RED}- A CNAME record with the Host name '$DOMAIN_NAME' that points to address 'app-gateway.$default_domain'.${RESET}"
104104
fi
105105
if [[ -n "$BACK_OFFICE_DOMAIN_NAME" ]]; then
106106
echo -e "${RED}- A TXT record with the name 'asuid.$BACK_OFFICE_DOMAIN_NAME' and the value '$custom_domain_verification_id'.${RESET}"
107-
echo -e "${RED}- A CNAME record with the Host name '$BACK_OFFICE_DOMAIN_NAME' that points to address 'account-api.$default_domain'.${RESET}"
107+
echo -e "${RED}- A CNAME record with the Host name '$BACK_OFFICE_DOMAIN_NAME' that points to address 'back-office.$default_domain'.${RESET}"
108108
fi
109109
exit 1
110110
elif [[ $output == *"ERROR:"* ]]; then

cloud-infrastructure/cluster/main-cluster.bicep

Lines changed: 45 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -169,6 +169,13 @@ var publicUrl = isCustomDomainSet
169169
: 'https://${appGatewayContainerAppName}.${containerAppsEnvironment.outputs.defaultDomainName}'
170170
var cdnUrl = publicUrl
171171

172+
// Back-office is reachable on its custom domain when set, else on the auto-generated ACA FQDN. Both code
173+
// paths must agree on the same hostname for Easy Auth redirect URLs and for the application's host-aware
174+
// routing (HostScopedSinglePageApp, BackOffice__Host, Hostnames__BackOffice).
175+
var backOfficeHost = backOfficeDomainName != ''
176+
? backOfficeDomainName
177+
: 'back-office.${containerAppsEnvironment.outputs.defaultDomainName}'
178+
172179
// Account
173180

174181
var accountIdentityName = '${clusterResourceGroupName}-account'
@@ -268,7 +275,7 @@ var accountApiEnvironmentVariables = concat(accountEnvironmentVariables, [
268275
}
269276
{
270277
name: 'BackOffice__Host'
271-
value: backOfficeDomainName
278+
value: backOfficeHost
272279
}
273280
{
274281
name: 'BackOffice__GroupId'
@@ -321,26 +328,55 @@ module accountApi '../modules/container-app.bicep' = {
321328
userAssignedIdentityName: accountIdentityName
322329
ingress: true
323330
hasProbesEndpoint: true
324-
additionalDomainName: backOfficeDomainName
325-
external: backOfficeDomainName != ''
331+
external: false
326332
revisionSuffix: revisionSuffix
327333
environmentVariables: accountApiEnvironmentVariables
328334
}
329335
dependsOn: [accountWorkers]
330336
}
331337

332-
module accountApiAuthConfig '../modules/container-app-auth-config.bicep' = if (backOfficeDomainName != '' && backOfficeEntraClientId != '') {
333-
name: '${clusterResourceGroupName}-account-api-auth-config'
338+
// Back-office runs the same image as account-api on a separate external container app. Easy Auth is bound here
339+
// only (RedirectToLoginPage), so account-api can stay internal-only and reachable solely through AppGateway.
340+
module backOffice '../modules/container-app.bicep' = {
341+
name: '${clusterResourceGroupName}-back-office-container-app'
342+
scope: clusterResourceGroup
343+
params: {
344+
name: 'back-office'
345+
location: location
346+
tags: tags
347+
clusterResourceGroupName: clusterResourceGroupName
348+
containerAppsEnvironmentId: containerAppsEnvironment.outputs.environmentId
349+
containerAppsEnvironmentName: containerAppsEnvironment.outputs.name
350+
containerRegistryName: containerRegistryName
351+
containerImageName: 'account-api'
352+
containerImageTag: accountVersion
353+
cpu: '0.1'
354+
memory: '0.2Gi'
355+
minReplicas: 0
356+
maxReplicas: 1
357+
userAssignedIdentityName: accountIdentityName
358+
ingress: true
359+
hasProbesEndpoint: true
360+
additionalDomainName: backOfficeDomainName
361+
external: true
362+
revisionSuffix: revisionSuffix
363+
environmentVariables: accountApiEnvironmentVariables
364+
}
365+
dependsOn: [accountApi]
366+
}
367+
368+
module backOfficeAuthConfig '../modules/container-app-auth-config.bicep' = if (backOfficeEntraClientId != '') {
369+
name: '${clusterResourceGroupName}-back-office-auth-config'
334370
scope: clusterResourceGroup
335371
params: {
336-
containerAppName: 'account-api'
372+
containerAppName: 'back-office'
337373
tenantId: subscription().tenantId
338374
clientId: backOfficeEntraClientId
339375
allowedExternalRedirectUrls: [
340-
'https://${backOfficeDomainName}/.auth/login/aad/callback'
376+
'https://${backOfficeHost}/.auth/login/aad/callback'
341377
]
342378
}
343-
dependsOn: [accountApi]
379+
dependsOn: [backOffice]
344380
}
345381

346382
// Main
@@ -546,7 +582,7 @@ module appGateway '../modules/container-app.bicep' = {
546582
}
547583
{
548584
name: 'Hostnames__BackOffice'
549-
value: backOfficeDomainName
585+
value: backOfficeHost
550586
}
551587
]
552588
}

cloud-infrastructure/modules/container-app-auth-config.bicep

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ resource authConfig 'Microsoft.App/containerApps/authConfigs@2025-10-02-preview'
1515
enabled: true
1616
}
1717
globalValidation: {
18-
unauthenticatedClientAction: 'AllowAnonymous'
18+
unauthenticatedClientAction: 'RedirectToLoginPage'
1919
}
2020
identityProviders: {
2121
azureActiveDirectory: {

0 commit comments

Comments
 (0)