|
1 | 1 | ---
|
2 | 2 | title: Manage network access control to an endpoint
|
3 | 3 | description: Learn how to control network access to your Azure Web PubSub resource.
|
4 |
| -author: yjin81 |
5 |
| -ms.author: yajin1 |
| 4 | +author: ArchangelSDY |
| 5 | +ms.author: dayshen |
6 | 6 | ms.service: azure-web-pubsub
|
7 | 7 | ms.topic: how-to
|
8 | 8 | ms.date: 08/16/2024
|
9 | 9 | ---
|
10 | 10 |
|
11 | 11 | # Manage network access control
|
12 | 12 |
|
| 13 | +Azure Web PubSub allows you to secure and manage access to your service endpoint based on request types and network subsets. When you configure network access control rules, only applications making requests from the specified networks can access your Azure Web PubSub instance. |
| 14 | + |
13 | 15 | You can configure Azure Web PubSub to secure and control the level of access to your service endpoint based on the request type and subset of networks used. When network rules are configured, only applications that request data over the specified set of networks can access your Web PubSub resource.
|
14 | 16 |
|
15 |
| -Azure Web PubSub has a public endpoint that is accessible through the internet. You can also create a [private endpoint for your Web PubSub resource](howto-secure-private-endpoints.md). A private endpoint assigns a private IP address from your virtual network to the Web PubSub resource. It also secures all traffic between your virtual network and the Web PubSub resource over a private link. The Web PubSub network access control provides access control for both a public endpoint and for private endpoints. |
| 17 | + :::image type="content" alt-text="Screenshot showing network access control decision flow chart." source="media\howto-secure-network-access-control\network-access-control-decision-flow-chart.png" ::: |
| 18 | + |
| 19 | + |
| 20 | +## Public network access |
| 21 | + |
| 22 | +We offer a single, unified switch to simplify the configuration of public network access. The switch has following options: |
| 23 | + |
| 24 | +* Disabled: Completely blocks public network access. All other network access control rules are ignored for public networks. |
| 25 | +* Enabled: Allows public network access, which is further regulated by additional network access control rules. |
| 26 | + |
| 27 | +### [Configure public network access via portal](#tab/azure-portal) |
| 28 | + |
| 29 | +1. Go to the Azure Web PubSub instance you want to secure. |
| 30 | +1. Select **Networking** from the left side menu. Select **Public access** tab: |
| 31 | + |
| 32 | + :::image type="content" alt-text="Screenshot showing how to configure public network access." source="media\howto-secure-network-access-control\portal-public-network-access.png" ::: |
| 33 | + |
| 34 | +1. Select **Disabled** or **Enabled**. |
| 35 | + |
| 36 | +1. Select **Save** to apply your changes. |
| 37 | + |
| 38 | +### [Configure public network access via bicep](#tab/bicep) |
| 39 | + |
| 40 | +The following template disables public network access: |
| 41 | + |
| 42 | +```bicep |
| 43 | +resource webpubsub 'Microsoft.SignalRService/WebPubSub@2024-08-01-preview' = { |
| 44 | + name: 'foobar' |
| 45 | + location: 'eastus' |
| 46 | + properties: { |
| 47 | + publicNetworkAccess: 'Disabled' |
| 48 | + } |
| 49 | +} |
| 50 | +``` |
| 51 | + |
| 52 | +----- |
| 53 | + |
| 54 | + |
| 55 | +## Default action |
| 56 | + |
| 57 | +The default action is applied when no other rule matches. |
| 58 | + |
| 59 | +### [Configure default action via portal](#tab/azure-portal) |
16 | 60 |
|
17 |
| -Optionally, you can choose to allow or deny certain types of requests for a public endpoint and for each private endpoint. |
| 61 | +1. Go to the Azure Web PubSub instance you want to secure. |
| 62 | +1. Select **Network access control** from the left side menu. |
18 | 63 |
|
19 |
| -An application that accesses a Web PubSub resource when network access control rules are in effect still requires proper authorization for the request. |
| 64 | + :::image type="content" alt-text="Screenshot showing default action on portal." source="media/howto-secure-network-access-control/portal-default-action.png" ::: |
20 | 65 |
|
21 |
| -The next sections describe your two options to control access to your Web PubSub resources: |
| 66 | +1. To edit the default action, toggle the **Allow/Deny** button. |
| 67 | +1. Select **Save** to apply your changes. |
| 68 | + |
| 69 | +### [Configure default action via bicep](#tab/bicep) |
22 | 70 |
|
23 |
| -- Deny all requests that originate in a public endpoint. |
24 |
| -- Allow only client connections from a public network. |
| 71 | +The following template sets the default action to `Deny`. |
25 | 72 |
|
26 |
| -## Deny all public traffic |
| 73 | +```bicep |
| 74 | +resource webpubsub 'Microsoft.SignalRService/WebPubSub@2024-08-01-preview' = { |
| 75 | + name: 'foobar' |
| 76 | + location: 'eastus' |
| 77 | + properties: { |
| 78 | + networkACLs: { |
| 79 | + defaultAction: 'Deny' |
| 80 | + } |
| 81 | +} |
| 82 | +``` |
27 | 83 |
|
28 |
| -To completely deny all public traffic, first configure the public network rule to allow no request type. Then, configure rules that grant access to traffic from specific virtual networks. This configuration enables you to build a secure network boundary for your applications. |
| 84 | +----- |
29 | 85 |
|
30 |
| -## Allow only client connections from a public network |
31 | 86 |
|
32 |
| -In this scenario, you configure the public network rule to allow only client connections from a public network. You can then configure private network rules to allow other types of requests that originate from a specific virtual network. This configuration hides your app servers on a public network and establishes secure connections between your app servers and Azure Web PubSub. |
| 87 | +## Request type rules |
33 | 88 |
|
34 |
| -## Manage network access control in the Azure portal |
| 89 | +You can configure rules to allow or deny specified request types for both the public network and each [private endpoint](howto-secure-private-endpoints.md). |
35 | 90 |
|
36 |
| -You can manage network access control for Azure Web PubSub by using the Azure portal. |
| 91 | +For example, [REST API calls](reference-rest-api-data-plane.md) are typically high-privileged. To enhance security, you may want to restrict their origin. You can configure rules to block all REST API calls from public network, and only allow they originate from a specific virtual network. |
37 | 92 |
|
38 |
| -1. In the Azure portal, go to the Web PubSub service you want to secure. |
| 93 | +If no rule matches, the default action is applied. |
39 | 94 |
|
40 |
| -1. On the left menu under **Settings**, select **Network access control**. |
| 95 | +### [Configure request type rules via portal](#tab/azure-portal) |
41 | 96 |
|
42 |
| -1. To edit the default action, select **Default action**. |
| 97 | +1. Go to the Azure Web PubSub instance you want to secure. |
| 98 | +1. Select **Network access control** from the left side menu. |
43 | 99 |
|
44 |
| - > [!TIP] |
45 |
| - > The default action is the action that you take when no access control list (ACL) rules match. For example, if the default action is **Deny**, request types that are not explicitly approved are denied. |
| 100 | + :::image type="content" alt-text="Screenshot showing request type rules on portal." source="media/howto-secure-network-access-control/portal-request-type-rules.png" ::: |
46 | 101 |
|
47 |
| - :::image type="content" source="./media/howto-secure-network-access-control/portal-network-access-control.png" alt-text="Screenshot that shows the Network access control pane in the Azure portal."::: |
| 102 | +1. To edit public network rule, select allowed types of requests under **Public network**. |
48 | 103 |
|
49 |
| -1. To edit a public network rule, under **Public network**, select the types of requests that you want to allow. |
| 104 | + :::image type="content" alt-text="Screenshot of selecting allowed request types for public network on portal." source="media/howto-secure-network-access-control/portal-public-network.png" ::: |
50 | 105 |
|
51 |
| - :::image type="content" source="./media/howto-secure-network-access-control/portal-public-network.png" alt-text="Screenshot that shows editing a public network access control list in the Azure portal."::: |
| 106 | +1. To edit private endpoint network rules, select allowed types of requests in each row under **Private endpoint connections**. |
52 | 107 |
|
53 |
| -1. To edit private endpoint network rules, under **Private endpoint connections**, select the allowed types of requests in each row. |
| 108 | + :::image type="content" alt-text="Screenshot of selecting allowed request types for private endpoints on portal." source="media/howto-secure-network-access-control/portal-private-endpoint.png" ::: |
54 | 109 |
|
55 | 110 | 1. Select **Save** to apply your changes.
|
| 111 | + |
| 112 | +### [Configure request type rules via bicep](#tab/bicep) |
| 113 | + |
| 114 | +The following template denies all requests from the public network except Client Connections. Additionally, it allows only REST API calls, and Trace calls from a specific private endpoint. |
| 115 | + |
| 116 | +The name of the private endpoint connection can be inspected in the `privateEndpointConnections` sub-resource. It's automatically generated by the system. |
| 117 | + |
| 118 | +```bicep |
| 119 | +resource webpubsub 'Microsoft.SignalRService/WebPubSub@2024-08-01-preview' = { |
| 120 | + name: 'foobar' |
| 121 | + location: 'eastus' |
| 122 | + properties: { |
| 123 | + networkACLs: { |
| 124 | + defaultAction: 'Deny' |
| 125 | + publicNetwork: { |
| 126 | + allow: ['ClientConnection'] |
| 127 | + } |
| 128 | + privateEndpoints: [ |
| 129 | + { |
| 130 | + name: 'foo.0000aaaa-11bb-cccc-dd22-eeeeee333333' |
| 131 | + allow: ['RESTAPI', 'Trace'] |
| 132 | + } |
| 133 | + ] |
| 134 | + } |
| 135 | +} |
| 136 | +``` |
| 137 | + |
| 138 | +----- |
| 139 | + |
| 140 | + |
| 141 | +## IP rules |
| 142 | + |
| 143 | +IP rules allow you to grant or deny access to specific public internet IP address ranges. These rules can be used to permit access for certain internet-based services and on-premises networks or to block general internet traffic. |
| 144 | + |
| 145 | +The following restrictions apply: |
| 146 | + |
| 147 | +* You can configure up to 30 rules. |
| 148 | +* Address ranges must be specified using [CIDR notation](https://tools.ietf.org/html/rfc4632), such as `16.17.18.0/24`. Both IPv4 and IPv6 addresses are supported. |
| 149 | +* IP rules are evaluated in the order they are defined. If no rule matches, the default action is applied. |
| 150 | +* IP rules apply only to public traffic and cannot block traffic from private endpoints. |
| 151 | + |
| 152 | +### [Configure IP rules via portal](#tab/azure-portal) |
| 153 | + |
| 154 | +1. Go to the Azure Web PubSub instance you want to secure. |
| 155 | +1. Select **Networking** from the left side menu. Select **Access control rules** tab: |
| 156 | + |
| 157 | + :::image type="content" alt-text="Screenshot showing how to configure IP rules." source="media\howto-secure-network-access-control\portal-ip-rules.png" ::: |
| 158 | + |
| 159 | +1. Edit the list under **IP rules** section. |
| 160 | + |
| 161 | +1. Select **Save** to apply your changes. |
| 162 | + |
| 163 | +### [Configure IP rules via bicep](#tab/bicep) |
| 164 | + |
| 165 | +The following template has these effects: |
| 166 | + |
| 167 | +* Requests from `123.0.0.0/8` and `2603::/8` are allowed. |
| 168 | +* Requests from all other IP ranges are denied. |
| 169 | + |
| 170 | +```bicep |
| 171 | +resource webpubsub 'Microsoft.SignalRService/WebPubSub@2024-08-01-preview' = { |
| 172 | + name: 'foobar' |
| 173 | + location: 'eastus' |
| 174 | + properties: { |
| 175 | + networkACLs: { |
| 176 | + defaultAction: 'Deny' |
| 177 | + ipRules: [ |
| 178 | + { |
| 179 | + value: '123.0.0.0/8' |
| 180 | + action: 'Allow' |
| 181 | + } |
| 182 | + { |
| 183 | + value: '2603::/8' |
| 184 | + action: 'Allow' |
| 185 | + } |
| 186 | + { |
| 187 | + value: '0.0.0.0/0' |
| 188 | + action: 'Deny' |
| 189 | + } |
| 190 | + { |
| 191 | + value: '::/0' |
| 192 | + action: 'Deny' |
| 193 | + } |
| 194 | + ] |
| 195 | + } |
| 196 | + } |
| 197 | +} |
| 198 | +``` |
| 199 | + |
| 200 | +----- |
| 201 | + |
| 202 | + |
| 203 | +## Next steps |
| 204 | + |
| 205 | +Learn more about [Azure Private Link](../private-link/private-link-overview.md). |
0 commit comments