Skip to content

Commit 525871b

Browse files
committed
wip
1 parent 13ad7cb commit 525871b

9 files changed

Lines changed: 4 additions & 55 deletions

File tree

docs/adr/ADR-005_Managed_Identity_For_Azure_Relay.md

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -16,17 +16,14 @@ The initial implementation used Shared Access Signature (SAS) tokens. These are
1616

1717
As the gateway runs inside the hospital network but is provisioned via Azure Arc, it can be assigned a managed identity through Arc-enabled infrastructure. Storing a long-lived shared secret in the environment is therefore unnecessary operational overhead and a potential security risk.
1818

19-
That said, setting up a working Relay connection locally is already complex. Mandating managed identity for all environments would add further friction for developers, who would need Azure CLI credentials with a Relay Listener role assignment before they could run the service.
2019

2120
## Decision
2221

23-
In **production** (`ENVIRONMENT=prod`), the gateway uses `ManagedIdentityCredential` exclusively. The SAS token path is unavailable regardless of what environment variables are set. The gateway's managed identity must be assigned the **Azure Relay Listener** role on the hybrid connection resource in Azure.
22+
All the deployed environments use `ManagedIdentityCredential` exclusively, from both the web application side and the gateway. The gateway's managed identity must be assigned the **Azure Relay Listener** role on the hybrid connection resource in Azure.
2423

25-
In **non-production** environments, SAS-based authentication is only enabled in the review environment
24+
Developers need to connect to Azure relay but cannot use a managed identity. It is required to keep relay with SAS keys enabled for their local testing. A SAS key may be provisioned and injected into `.env`.
2625

27-
- In the review environment, a SAS key may be provisioned and injected into `.env` so local testing against the gateway test VM continues to work.
28-
- In dev, preprod, and prod the relay listener uses managed identity / Azure AD authentication and no SAS key is provisioned or injected into `.env`.
29-
- If no SAS key is present, `DefaultAzureCredential` is used for developer scenarios that rely on `az login` and the appropriate Relay Listener role assignment.
26+
If no SAS key is present, `DefaultAzureCredential` is used for developer scenarios that rely on `az login` and the appropriate Relay Listener role assignment.
3027

3128
The token is passed as an `Authorization: Bearer` HTTP header on the WebSocket upgrade request for managed identity paths. Azure Relay validates it against Azure AD.
3229

docs/relay-listener/README.md

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,6 @@
33
Relay listener uses websocket communication to Manage Breast Screening service via Azure Relay.
44
The listener processes worklist actions sent from Manage/Django and creates worklist items in the Modality Worklist server.
55

6-
Note: SAS-based relay authentication is review-only. For dev, preprod, and prod, the listener should use managed identity and no `AZURE_RELAY_SHARED_ACCESS_KEY` should be injected into `.env`.
7-
86
## Architecture
97

108
```
Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,2 @@
11
enable_gateway_test_vm = true
22
screening_entra_group_id = "14f915c3-ef0a-471b-b9bf-31187d18f8b6"
3-
enable_relay_sas_keys = false

infrastructure/modules/arc-infra/outputs.tf

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -33,12 +33,3 @@ output "app_insights_connection_string" {
3333
sensitive = true
3434
value = var.enable_arc_servers ? module.app_insights[0].connection_string : null
3535
}
36-
37-
output "relay_listen_sas_keys" {
38-
description = "Per-machine relay listen SAS primary keys, keyed by Arc resource name. Populated only for the review environment."
39-
sensitive = true
40-
value = {
41-
for k, rule in azurerm_relay_hybrid_connection_authorization_rule.per_machine_listen :
42-
k => rule.primary_key
43-
}
44-
}

infrastructure/modules/arc-infra/relay.tf

Lines changed: 0 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -45,25 +45,6 @@ resource "azurerm_relay_hybrid_connection" "per_machine" {
4545
requires_client_authorization = true
4646
}
4747

48-
# Listen-only SAS rule per HC — retained for local development / break-glass access.
49-
# Production relay authentication uses Managed Identity (see relay_listener_role below).
50-
resource "azurerm_relay_hybrid_connection_authorization_rule" "per_machine_listen" {
51-
for_each = {
52-
for machine_name, machine_config in local.arc_machines :
53-
machine_name => machine_config
54-
if var.enable_relay_sas_keys
55-
}
56-
57-
name = "listen"
58-
hybrid_connection_name = azurerm_relay_hybrid_connection.per_machine[each.key].name
59-
namespace_name = local.relay_namespace_name
60-
resource_group_name = local.relay_namespace_rg
61-
62-
listen = true
63-
send = false
64-
manage = false
65-
}
66-
6748
# Look up each discovered Arc machine to obtain its system-assigned managed identity.
6849
# Static machines (registered in the same apply) are excluded — they are not yet
6950
# visible to the data source and will be picked up on the next apply after onboarding.

infrastructure/modules/arc-infra/variables.tf

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -28,8 +28,3 @@ variable "static_arc_machine_names" {
2828
type = list(string)
2929
default = []
3030
}
31-
32-
variable "enable_relay_sas_keys" {
33-
description = "Whether to create relay SAS keys for the Arc machines. Only used in the review environment."
34-
type = bool
35-
}

infrastructure/terraform/main.tf

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@ module "arc_infra" {
1111
env_config = var.env_config
1212
resource_group_name = local.resource_group_name
1313
enable_arc_servers = var.enable_arc_servers
14-
enable_relay_sas_keys = var.enable_relay_sas_keys
1514

1615
# Create the HC for the test VM in the same run as VM creation.
1716
# The Arc data source won't see a machine registered in the same apply.

infrastructure/terraform/outputs.tf

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,3 @@ output "relay_namespace_hostname" {
88
description = "Relay namespace FQDN for AZURE_RELAY_NAMESPACE in the gateway .env"
99
value = module.arc_infra.relay_namespace_hostname
1010
}
11-
12-
output "relay_listen_sas_keys" {
13-
description = "Per-machine relay listen SAS primary keys, keyed by Arc resource name"
14-
sensitive = true
15-
value = module.arc_infra.relay_listen_sas_keys
16-
}

infrastructure/terraform/variables.tf

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -50,13 +50,8 @@ variable "gateway_test_vm_size" {
5050
default = "Standard_B2s"
5151
}
5252

53-
variable "enable_relay_sas_keys" {
54-
description = "Whether to create relay SAS keys for the Arc machines"
55-
default = false
56-
type = bool
57-
}
5853

5954
locals {
6055
region = "uksouth"
6156
resource_group_name = "rg-${var.app_short_name}-${var.environment}-uks"
62-
}
57+
}

0 commit comments

Comments
 (0)