Skip to content

Commit fe8fac5

Browse files
authored
Merge pull request #221078 from dlepow/subs
[APIM] Subscription key scenarios
2 parents 47c9530 + 5e9a9c1 commit fe8fac5

File tree

1 file changed

+52
-8
lines changed

1 file changed

+52
-8
lines changed

articles/api-management/api-management-subscriptions.md

Lines changed: 52 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,9 @@ author: dlepow
77

88
ms.service: api-management
99
ms.topic: conceptual
10-
ms.date: 09/27/2022
10+
ms.date: 12/16/2022
1111
ms.author: danlep
12+
ms.custom: engagement-fy23
1213
---
1314
# Subscriptions in Azure API Management
1415

@@ -81,29 +82,72 @@ Creating a subscription without assigning an owner makes it a standalone subscri
8182
* Manually share the subscription key.
8283
* Use a custom system to make the subscription key available to your team.
8384

84-
## Create subscriptions in Azure portal
85+
## Create and manage subscriptions in Azure portal
8586

8687
API publishers can [create subscriptions](api-management-howto-create-subscriptions.md) directly in the Azure portal.
8788

88-
## How API Management handles requests with or without subscription keys
89+
When created in the portal, a subscription is in the **Active** state, meaning a subscriber can call an associated API using a valid subscription key. You can change the state of the subscription as needed - for example, you can suspend, cancel, or delete the subscription to prevent API access.
90+
91+
## Enable or disable subscription requirement for API or product access
8992

90-
By default, a developer can only access a product or API by using a subscription key. Under certain scenarios, API publishers might want to publish a product or a particular API to the public without the requirement of subscriptions. While a publisher could choose to enable unsecured access to certain APIs, configuring another mechanism to secure client access is recommended.
93+
By default when you create an API, a subscription key is required for API access. Similarly, when you create a product, by default a subscription key is required to access any API that's added to the product. Under certain scenarios, an API publisher might want to publish a product or a particular API to the public without the requirement of subscriptions. While a publisher could choose to enable unsecured (anonymous) access to certain APIs, configuring another mechanism to secure client access is recommended.
9194

9295
> [!CAUTION]
9396
> Use care when configuring a product or an API that doesn't require a subscription. This configuration may be overly permissive and may make an API more vulnerable to certain [API security threats](mitigate-owasp-api-threats.md#security-misconfiguration).
9497
98+
You can disable the subscription requirement at the time you create an API or product, or at a later date.
99+
95100
To disable the subscription requirement using the portal:
96101

97-
* **Disable requirement for product** - Disable **Requires subscription** on the **Settings** page of the product.
98-
* **Disable requirement for API** - Disable **Subscription required** on the **Settings** page of the API.
102+
* **Disable requirement for product** - On the **Settings** page of the product, disable **Requires subscription**
103+
* **Disable requirement for API** - In the **Settings** page of the API, disable **Subscription required**.
104+
105+
After the subscription requirement is disabled, the selected API or APIs can be accessed without a subscription key.
106+
107+
## How API Management handles requests with or without subscription keys
108+
109+
### API request with a subscription key
110+
111+
When API Management receives an API request from a client with a subscription key, it handles the request according to these rules:
112+
113+
1. Check if it's a valid key associated with an active subscription, either:
114+
115+
* A subscription scoped to the API
116+
* A subscription scoped to a product that's assigned to the API
117+
* A subscription scoped to all APIs
118+
* The service-scoped subscription (built-in all access subscription)
99119

100-
After the subscription requirement is disabled, the selected API or APIs can be accessed without a subscription key.
120+
If a valid key for an active subscription at an appropriate scope is provided, access is allowed. Policies are applied depending on the configuration of the policy definition at that scope.
121+
122+
1. Otherwise, access is denied (401 Access denied error).
123+
124+
### API request without a subscription key
101125

102126
When API Management receives an API request from a client without a subscription key, it handles the request according to these rules:
103127

104128
1. Check first for the existence of a product that includes the API but doesn't require a subscription (an *open* product). If the open product exists, handle the request in the context of the APIs, policies, and access rules configured for the product.
105129
1. If an open product including the API isn't found, check whether the API requires a subscription. If a subscription isn't required, handle the request in the context of that API and operation.
106-
1. If no configured product or API is found, then access is denied.
130+
1. If no configured product or API is found, then access is denied (401 Access denied error).
131+
132+
### Summary table
133+
134+
The following table summarizes how the gateway handles API requests with or without subscription keys in different scenarios. Configurations that could potentially enable unintended, anonymous API access are noted.
135+
136+
137+
|All products assigned to API require subscription |API requires subscription |API call with subscription key |API call without subscription key | Typical scenarios |
138+
|---------|---------|---------|---------|----|
139+
|✔️ | ✔️ | Access allowed:<br/><br/>• Product-scoped key<br/>• API-scoped key<br/>• All APIs-scoped key<br/>• Service-scoped key<br/><br/>Access denied:<br/><br/>• Other key not scoped to applicable product or API | Access denied | Protected API access using product-scoped or API-scoped subscription |
140+
|✔️ || Access allowed:<br/><br/>• Product-scoped key<br/>• API-scoped key<br/>• All APIs-scoped key<br/>• Service-scoped key<br/><br/>Access denied:<br/><br/>• Other key not scoped to applicable product or API | Access allowed (API context) | • Protected API access with product-scoped subscription<br/><br/>• Anonymous access to API. If anonymous access isn’t intended, configure API-level policies to enforce authentication and authorization. |
141+
|❌<sup>1</sup> | ✔️ | Access allowed:<br/><br/>• Product-scoped key<br/>• API-scoped key<br/>• All APIs-scoped key<br/>• Service-scoped key<br/><br/>Access denied:<br/><br/>• Other key not scoped to applicable product or API | Access allowed (open product context) | • Protected API access with API-scoped subscription<br/><br/>• Anonymous access to API. If anonymous access isn’t intended, configure with product policies to enforce authentication and authorization |
142+
|❌<sup>1</sup> || Access allowed:<br/><br/>• Product-scoped key<br/>• API-scoped key<br/>• All APIs-scoped key<br/>• Service-scoped key<br/><br/>Access denied:<br/><br/>• Other key not scoped to applicable product or API | Access allowed (open product context) | Anonymous access to API. If anonymous access isn’t intended, configure with product policies to enforce authentication and authorization |
143+
144+
<sup>1</sup> An open product exists.
145+
146+
### Considerations
147+
148+
- API access in a product context is the same, whether the product is published or not. Unpublishing the product hides it from the developer portal, but it doesn’t invalidate new or existing subscription keys.
149+
- Even if a product or API doesn't require a subscription, a valid key from an active subscription that enables access to the product or API can still be used.
150+
- API access "context" means the policies and access controls that are applied at a particular scope (for example, API or product).
107151

108152
## Next steps
109153
Get more information on API Management:

0 commit comments

Comments
 (0)