Skip to content

Commit c953a2e

Browse files
Merge pull request #234346 from ninpan-ms/ninpan/cert-verify
Add cert upload and verification for gateway
2 parents 9cbb630 + bbf12c1 commit c953a2e

File tree

3 files changed

+146
-23
lines changed

3 files changed

+146
-23
lines changed

articles/spring-apps/how-to-configure-enterprise-spring-cloud-gateway.md

Lines changed: 119 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -56,14 +56,17 @@ To assign an endpoint in the Azure portal, use the following steps:
5656

5757
After a few minutes, **URL** shows the configured endpoint URL. Save the URL to use later.
5858

59-
:::image type="content" source="media/how-to-configure-enterprise-spring-cloud-gateway/gateway-overview.png" alt-text="Screenshot of Azure portal showing the Spring Cloud Gateway overview page for an Azure Spring Apps instance with the Assign endpoint buttons highlighted and the configured endpoint URL displayed." lightbox="media/how-to-configure-enterprise-spring-cloud-gateway/gateway-overview.png":::
59+
:::image type="content" source="media/how-to-configure-enterprise-spring-cloud-gateway/gateway-overview.png" alt-text="Screenshot of the Azure portal showing the Spring Cloud Gateway overview page with Assign endpoint highlighted." lightbox="media/how-to-configure-enterprise-spring-cloud-gateway/gateway-overview.png":::
6060

6161
#### [Azure CLI](#tab/Azure-CLI)
6262

6363
Use the following command to assign the endpoint.
6464

6565
```azurecli
66-
az spring gateway update --assign-endpoint
66+
az spring gateway update \
67+
--resource-group <resource-group-name> \
68+
--service <Azure-Spring-Apps-instance-name> \
69+
--assign-endpoint true
6770
```
6871

6972
---
@@ -89,21 +92,23 @@ You can use the Azure portal and the Azure CLI to edit metadata properties.
8992

9093
#### [Azure portal](#tab/Azure-portal)
9194

92-
To edit metadata in the Azure portal, do these steps:
95+
To edit metadata in the Azure portal, use the following steps:
9396

9497
1. Open your Azure Spring Apps instance.
9598
1. Select **Spring Cloud Gateway** in the navigation pane, and then select **Configuration**.
9699
1. Specify values for the properties listed for **API**.
97100
1. Select **Save**.
98101

99-
:::image type="content" source="media/how-to-configure-enterprise-spring-cloud-gateway/gateway-configuration.png" alt-text="Screenshot of Azure portal showing the Spring Cloud Gateway configuration page for an Azure Spring Apps instance with the API section highlighted." lightbox="media/how-to-configure-enterprise-spring-cloud-gateway/gateway-configuration.png":::
102+
:::image type="content" source="media/how-to-configure-enterprise-spring-cloud-gateway/gateway-configuration.png" alt-text="Screenshot of Azure portal showing the Spring Cloud Gateway configuration page for an Azure Spring Apps instance, with the API section highlighted." lightbox="media/how-to-configure-enterprise-spring-cloud-gateway/gateway-configuration.png":::
100103

101104
#### [Azure CLI](#tab/Azure-CLI)
102105

103106
Use the following command to configure VMware Spring Cloud Gateway metadata properties. You need the endpoint URL obtained from the [Configure Spring Cloud Gateway](#configure-spring-cloud-gateway) section.
104107

105108
```azurecli
106109
az spring gateway update \
110+
--resource-group <resource-group-name> \
111+
--service <Azure-Spring-Apps-instance-name> \
107112
--api-description "<api-description>" \
108113
--api-title "<api-title>" \
109114
--api-version "v0.1" \
@@ -137,14 +142,16 @@ To edit SSO properties in the Azure portal, use the following steps:
137142
1. Specify values for the properties listed for **SSO**.
138143
1. Select **Save**.
139144

140-
:::image type="content" source="media/how-to-configure-enterprise-spring-cloud-gateway/gateway-sso-configuration.png" alt-text="Screenshot of Azure portal showing the Spring Cloud Gateway configuration page for an Azure Spring Apps instance with the Single Sign On section highlighted." lightbox="media/how-to-configure-enterprise-spring-cloud-gateway/gateway-sso-configuration.png":::
145+
:::image type="content" source="media/how-to-configure-enterprise-spring-cloud-gateway/gateway-sso-configuration.png" alt-text="Screenshot of Azure portal showing the Spring Cloud Gateway configuration page for an Azure Spring Apps instance, with the Single Sign On section highlighted." lightbox="media/how-to-configure-enterprise-spring-cloud-gateway/gateway-sso-configuration.png":::
141146

142147
#### [Azure CLI](#tab/Azure-CLI)
143148

144149
Use the following command to configure SSO properties for VMware Spring Cloud Gateway.
145150

146151
```azurecli
147152
az spring gateway update \
153+
--resource-group <resource-group-name> \
154+
--service <Azure-Spring-Apps-instance-name> \
148155
--client-id <client-id> \
149156
--client-secret <client-secret> \
150157
--issuer-uri <issuer-uri> \
@@ -182,7 +189,7 @@ The following steps describe an example of how to implement the function in your
182189
183190
### Log out just the SSO session
184191

185-
If you send the `GET` request to the `/scg-logout` endpoint using a `XMLHttpRequest` (XHR), then the `302` redirect could be swallowed and not handled in the response handler. In this case, the user would only be logged out of the SSO session on the gateway service instance and would still have a valid IdP session. The behavior typically seen in this case is that if the user attempts to log in again, they're automatically sent back to the gateway as authenticated from IdP.
192+
If you send the `GET` request to the `/scg-logout` endpoint using a `XMLHttpRequest` (XHR), then the `302` redirect could be swallowed and not handled in the response handler. In this case, the user would only be logged out of the SSO session on the gateway service instance and would still have a valid IdP session. The behavior typically seen is that if the user attempts to log in again, they're automatically sent back to the gateway as authenticated from IdP.
186193

187194
You need to have a route configuration to route the logout request to your application, as shown in the following example. This code makes a gateway-only logout SSO session.
188195

@@ -266,6 +273,8 @@ Use the following command to set up APM using Azure CLI:
266273
267274
```azurecli
268275
az spring gateway update \
276+
--resource-group <resource-group-name> \
277+
--service <Azure-Spring-Apps-instance-name> \
269278
--apm-types <APM-type> \
270279
--properties <key=value> \
271280
--secrets <key=value>
@@ -275,6 +284,8 @@ The allowed values for `--apm-types` are `ApplicationInsights`, `AppDynamics`, `
275284
276285
```azurecli
277286
az spring gateway update \
287+
--resource-group <resource-group-name> \
288+
--service <Azure-Spring-Apps-instance-name> \
278289
--apm-types ApplicationInsights \
279290
--properties APPLICATIONINSIGHTS_CONNECTION_STRING=<THE CONNECTION STRING OF YOUR APPINSIGHTS> APPLICATIONINSIGHTS_SAMPLE_RATE=10
280291
```
@@ -289,6 +300,108 @@ You can also put environment variables in the `--secrets` parameter instead of `
289300
> By default, Azure Spring Apps prints the logs of the APM Java agent to `STDOUT`. These logs are included with the Spring Cloud Gateway logs. You can check the version of the APM agent used in the logs. You can query these logs in Log Analytics to troubleshoot.
290301
> To make the APM agents work correctly, increase the CPU and memory of Spring Cloud Gateway.
291302
303+
## Configure TLS between gateway and applications
304+
305+
To enhance security and protect sensitive information from interception by unauthorized parties, you can enable Transport Layer Security (TLS) between Spring Cloud Gateway and your applications. This section explains how to configure TLS between a gateway and applications.
306+
307+
Before configuring TLS, you need to have a TLS-enabled application and a TLS certificate. To prepare a TLS certificate, generate a certificate from a trusted certificate authority (CA). The certificate verifies the identity of the server and establishes a secure connection.
308+
309+
After you have a TLS-enabled application running in Azure Spring Apps, upload the certificate to Azure Spring Apps. For more information, see the [Import a certificate](how-to-use-tls-certificate.md#import-a-certificate) section of [Use TLS/SSL certificates in your application in Azure Spring Apps](how-to-use-tls-certificate.md).
310+
311+
With the certificate updated to Azure Spring Apps, you can now configure the TLS certificate for the gateway and enable certificate verification. You can configure the certification in the Azure portal or by using the Azure CLI.
312+
313+
#### [Azure portal](#tab/Azure-portal)
314+
315+
Use the following steps to configure the certificate in the Azure portal:
316+
317+
1. In your Azure Spring Apps instance, select **Spring Cloud Gateway** in the navigation pane.
318+
1. On the **Spring Cloud Gateway** page, select **Certificate management**.
319+
1. Select **Enable cert verification**.
320+
1. Select the TLS certificate in **Certificates**.
321+
1. Select **Save**.
322+
323+
Updating the configuration can take a few minutes. You should get a notification when the configuration is complete.
324+
325+
#### [Azure CLI](#tab/Azure-CLI)
326+
327+
Use the following command to enable or disable certificate verification using the Azure CLI. Be sure to replace the *`<value>`* placeholder with *true* to enable or *false* to disable verification.
328+
329+
```azurecli
330+
az spring gateway update \
331+
--resource-group <resource-group-name> \
332+
--service <Azure-Spring-Apps-instance-name> \
333+
--enable-cert-verify <value> \
334+
--certificate-names <certificate-name-in-Azure-Spring-Apps>
335+
```
336+
337+
---
338+
339+
### Prepare the route configuration
340+
341+
You must specify the protocol as HTTPS in the route configuration. The following JSON object instructs the gateway to use the HTTPS protocol for all traffic between the gateway and the app.
342+
343+
1. Create a file named *test-tls-route.json* with the following content.
344+
345+
```json
346+
{
347+
"routes": [
348+
{
349+
"title": "Test TLS app",
350+
"predicates": [
351+
"Path=/path/to/your/app",
352+
"Method=GET"
353+
]
354+
}
355+
],
356+
"uri": "https://<app-custom-domain-name>"
357+
}
358+
```
359+
360+
1. Use the following command to apply the rule to the application:
361+
362+
```azurecli
363+
az spring gateway route-config create \
364+
--resource-group <resource-group-name> \
365+
--service <Azure-Spring-Apps-instance-name> \
366+
--name test-tls-app \
367+
--routes-file test-tls-route.json
368+
```
369+
370+
You can now test whether the application is TLS enabled with the endpoint of the gateway. For more information, see the [Configure routes](how-to-use-enterprise-spring-cloud-gateway.md#configure-routes) section of [Use Spring Cloud Gateway](how-to-use-enterprise-spring-cloud-gateway.md).
371+
372+
### Rotate certificates
373+
374+
As certificates expire, you need to rotate certificates in Spring Cloud Gateway by using the following steps:
375+
376+
1. Generate new certificates from a trusted CA.
377+
1. Import the certificates into Azure Spring Apps. For more information, see the [Import a certificate](how-to-use-tls-certificate.md#import-a-certificate) section of [Use TLS/SSL certificates in your application in Azure Spring Apps](how-to-use-tls-certificate.md).
378+
1. Synchronize the certificates, using the Azure portal or the Azure CLI.
379+
380+
The gateway restarts accordingly to ensure that the gateway uses the new certificate for all connections.
381+
382+
#### [Azure portal](#tab/Azure-portal)
383+
384+
Use the following steps to synchronize certificates.
385+
386+
1. In your Azure Spring Apps instance, select **Spring Cloud Gateway** in the navigation pane.
387+
1. On the **Spring Cloud Gateway** page, select **Certificate management**.
388+
1. Select the certificate you imported in **Certificates**.
389+
1. Select **sync certificate**, and confirm the operation.
390+
391+
:::image type="content" source="media/how-to-configure-enterprise-spring-cloud-gateway/gateway-sync-certificate.png" alt-text="Screenshot of the Azure portal showing the Spring Cloud Gateway page for Certificate Management with the sync certificate prompt highlighted." lightbox="media/how-to-configure-enterprise-spring-cloud-gateway/gateway-sync-certificate.png":::
392+
393+
#### [Azure CLI](#tab/Azure-CLI)
394+
395+
Use the following command to synchronize a certificate for Spring Cloud Gateway.
396+
397+
```azurecli
398+
az spring gateway sync-cert \
399+
--resource-group <resource-group-name> \
400+
--service <Azure-Spring-Apps-instance-name>
401+
```
402+
403+
---
404+
292405
## Next steps
293406

294407
- [How to Use Spring Cloud Gateway](how-to-use-enterprise-spring-cloud-gateway.md)

0 commit comments

Comments
 (0)