Skip to content

Commit a00989b

Browse files
authored
Merge pull request #201478 from ninpan-ms/ninpan/gateway-openapi
Add openapi uri property to gateway
2 parents ca718df + ecc002b commit a00989b

File tree

3 files changed

+179
-70
lines changed

3 files changed

+179
-70
lines changed

articles/spring-cloud/how-to-set-up-sso-with-azure-ad.md

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
---
2-
title: How to set up Single Sign-on with Azure AD for Spring Cloud Gateway and API Portal for Tanzu
2+
title: How to set up single sign-on with Azure AD for Spring Cloud Gateway and API Portal for Tanzu
33
titleSuffix: Azure Spring Apps Enterprise Tier
4-
description: How to set up Single Sign-on with Azure Active Directory for Spring Cloud Gateway and API Portal for Tanzu with Azure Spring Apps Enterprise Tier.
4+
description: How to set up single sign-on with Azure Active Directory for Spring Cloud Gateway and API Portal for Tanzu with Azure Spring Apps Enterprise Tier.
55
author: karlerickson
66
ms.author: ninpan
77
ms.service: spring-cloud
@@ -10,18 +10,17 @@ ms.date: 05/20/2022
1010
ms.custom: devx-track-java, devx-track-azurecli
1111
---
1212

13-
# Set up Single Sign-on using Azure Active Directory for Spring Cloud Gateway and API Portal
13+
# Set up single sign-on using Azure Active Directory for Spring Cloud Gateway and API Portal
1414

1515
**This article applies to:** ❌ Basic/Standard tier ✔️ Enterprise tier
1616

17-
This article shows you how to configure Single Sign-on (SSO) for Spring Cloud Gateway or API Portal using the Azure Active Directory (Azure AD) as an OpenID identify provider.
17+
This article shows you how to configure single sign-on (SSO) for Spring Cloud Gateway or API Portal using the Azure Active Directory (Azure AD) as an OpenID identify provider.
1818

1919
## Prerequisites
2020

2121
- An Enterprise tier instance with Spring Cloud Gateway or API portal enabled. For more information, see [Quickstart: Provision an Azure Spring Apps service instance using the Enterprise tier](quickstart-provision-service-instance-enterprise.md).
2222
- Sufficient permissions to manage Azure AD applications.
2323

24-
2524
To enable SSO for Spring Cloud Gateway or API Portal, you need the following four properties configured:
2625

2726
| SSO Property | Azure AD Configuration |

articles/spring-cloud/how-to-use-enterprise-api-portal.md

Lines changed: 74 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ ms.custom: devx-track-java, devx-track-azurecli, event-tier1-build-2022
1919

2020
This article shows you how to use API portal for VMware Tanzu® with Azure Spring Apps Enterprise Tier.
2121

22-
[API portal](https://docs.vmware.com/en/API-portal-for-VMware-Tanzu/1.0/api-portal/GUID-index.html) is one of the commercial VMware Tanzu components. API portal supports viewing API definitions from [Spring Cloud Gateway for VMware Tanzu®](./how-to-use-enterprise-spring-cloud-gateway.md) and testing of specific API routes from the browser. It also supports enabling Single Sign-on authentication via configuration.
22+
[API portal](https://docs.vmware.com/en/API-portal-for-VMware-Tanzu/1.0/api-portal/GUID-index.html) is one of the commercial VMware Tanzu components. API portal supports viewing API definitions from [Spring Cloud Gateway for VMware Tanzu®](./how-to-use-enterprise-spring-cloud-gateway.md) and testing of specific API routes from the browser. It also supports enabling single sign-on (SSO) authentication via configuration.
2323

2424
## Prerequisites
2525

@@ -34,9 +34,9 @@ This article shows you how to use API portal for VMware Tanzu® with Azure Sprin
3434

3535
The following sections describe configuration in API portal.
3636

37-
### Configure single Sign-on (SSO)
37+
### Configure single sign-on (SSO)
3838

39-
API portal supports authentication and authorization using single Sign-on (SSO) with an OpenID identity provider (IdP) that supports the OpenID Connect Discovery protocol.
39+
API portal supports authentication and authorization using single sign-on (SSO) with an OpenID identity provider (IdP) that supports the OpenID Connect Discovery protocol.
4040

4141
> [!NOTE]
4242
> Only authorization servers supporting the OpenID Connect Discovery protocol are supported. Be sure to configure the external authorization server to allow redirects back to the gateway. Refer to your authorization server's documentation and add `https://<gateway-external-url>/login/oauth2/code/sso` to the list of allowed redirect URIs.
@@ -48,7 +48,7 @@ API portal supports authentication and authorization using single Sign-on (SSO)
4848
| clientSecret | Yes | The OpenID Connect client secret provided by your IdP |
4949
| scope | Yes | A list of scopes to include in JWT identity tokens. This list should be based on the scopes allowed by your identity provider |
5050

51-
To set up SSO with Azure AD, see [How to set up Single Sign-on with Azure AD for Spring Cloud Gateway and API Portal for Tanzu](./how-to-set-up-sso-with-azure-ad.md).
51+
To set up SSO with Azure AD, see [How to set up single sign-on with Azure AD for Spring Cloud Gateway and API Portal for Tanzu](./how-to-set-up-sso-with-azure-ad.md).
5252

5353
> [!NOTE]
5454
> If you configure the wrong SSO property, such as the wrong password, you should remove the entire SSO property and re-add the correct configuration.
@@ -75,7 +75,73 @@ You can also use the Azure CLI to assign a public endpoint with the following co
7575
az spring api-portal update --assign-endpoint
7676
```
7777

78-
## View the route information through API portal
78+
## Configure API routing with OpenAPI Spec on Spring Cloud Gateway for Tanzu
79+
80+
This section describes how to view and try out APIs with schema definitions in API portal. Use the following steps to configure API routing with an OpenAPI spec URL on Spring Cloud Gateway for Tanzu.
81+
82+
1. Create an app in Azure Spring Apps that the gateway will route traffic to.
83+
84+
1. Generate the OpenAPI definition and get the URI to access it. The following two URI options are accepted:
85+
86+
- The first option is to use a publicly accessible endpoint like the URI `https://petstore3.swagger.io/api/v3/openapi.json`, which includes the OpenAPI specification.
87+
- The second option is to put the OpenAPI definition in the relative path of the app in Azure Spring Apps, and construct the URI in the format `http://<app-name>/<relative-path-to-OpenAPI-spec>`. You can choose tools like `SpringDocs` to generate the OpenAPI specification automatically, so the URI can be like `http://<app-name>/v3/api-docs`.
88+
89+
1. Use the following command to assign a public endpoint to the gateway to access it.
90+
91+
```azurecli
92+
az spring gateway update --assign-endpoint
93+
```
94+
95+
1. Use the following command to configure Spring Cloud Gateway for Tanzu properties:
96+
97+
```azurecli
98+
az spring gateway update \
99+
--api-description "<api-description>" \
100+
--api-title "<api-title>" \
101+
--api-version "v0.1" \
102+
--server-url "<endpoint-in-the-previous-step>" \
103+
--allowed-origins "*"
104+
```
105+
106+
1. Configure routing rules to apps.
107+
108+
To create rules to access the app in Spring Cloud Gateway for Tanzu route configuration, save the following contents to the *sample.json* file.
109+
110+
```json
111+
{
112+
"open_api": {
113+
"uri": "https://petstore3.swagger.io/api/v3/openapi.json"
114+
},
115+
"routes": [
116+
{
117+
"title": "Petstore",
118+
"description": "Route to application",
119+
"predicates": [
120+
"Path=/pet",
121+
"Method=PUT"
122+
],
123+
"filters": [
124+
"StripPrefix=0",
125+
]
126+
}
127+
]
128+
}
129+
```
130+
131+
The `open_api.uri` value is the public endpoint or URI constructed in the second step above. You can add predicates and filters for paths defined in your OpenAPI specification.
132+
133+
Use the following command to apply the rule to the app created in the first step:
134+
135+
```azurecli
136+
az spring gateway route-config create \
137+
--name sample \
138+
--app-name <app-name> \
139+
--routes-file sample.json
140+
```
141+
142+
1. Check the response of the created routes. You can also view the routes in the portal.
143+
144+
## View exposed APIs in API portal
79145

80146
> [!NOTE]
81147
> It takes several minutes to sync between Spring Cloud Gateway for Tanzu and API portal.
@@ -84,13 +150,12 @@ Select the `endpoint URL` to go to API portal. You'll see all the routes configu
84150

85151
:::image type="content" source="media/enterprise/how-to-use-enterprise-api-portal/api-portal.png" alt-text="Screenshot of A P I portal showing configured routes.":::
86152

87-
## Try APIs using API portal
153+
## Try out APIs in API portal
88154

89-
> [!NOTE]
90-
> Only `GET` operations are supported in the public preview.
155+
Use the following steps to try out APIs:
91156

92157
1. Select the API you would like to try.
93-
1. Select **EXECUTE** and the response will be shown.
158+
1. Select **EXECUTE**, and the response will be shown.
94159

95160
:::image type="content" source="media/enterprise/how-to-use-enterprise-api-portal/api-portal-tryout.png" alt-text="Screenshot of A P I portal.":::
96161

0 commit comments

Comments
 (0)