如何通过API管理来处理内部和外部的API访问?

问题描述 投票:0回答:1

我有一个场景,当 API 位于 Azure API 管理后面时需要帮助。在任何组织中,他们都有内部和外部 API。

在我们的组织中,我们有 Azure API 管理,并且它对客户向互联网公开。但我们希望限制所有内部 API 不暴露于互联网。有什么办法可以限制吗?

例如: www.myorganization/apimanagement/internal/* --- 不应访问互联网。(只能在具有有效 JWT 令牌的公司网络中访问)

www.myorganization/apimanagement/external/* -- 应该可以使用有效的 JWT 令牌访问互联网

我们使用 OKTA 作为 Azure API 管理中的 Oauth 提供程序,并验证每个 API 策略中的 JWT 令牌。

azure azure-api-management
1个回答
0
投票

您可以使用 API-M 功能(例如产品、组、用户和 订阅。

内部产品应仅授予内部用户访问权限 - 您也可以喜欢 AD 安全组。

外部访问应由 IT 人员根据具体情况进行控制。

例如,可以编写以下 Bicep 中的 Infra As 代码来生成 Azure API-M 中的产品、组、订阅访问权限。

首先创建一个产品:

module product'products/template.bicep' = {
  name: 'testProduct'
  params: {
    apimServiceName: apimServiceName
    productDescription: 'Product Project APIs'
    productDisplayName: 'Product Project'
    productName: 'ProductName'
    productSubscription: true
    productApproval: true
  }
}

将产品添加到订阅:

module addSubsciptionToProduct 'subscriptions/template.bicep' = {
  name: 'subscriptionToProduct'
  params: {
    apimServiceName: apimServiceName
    scopeId: testProduct.outputs.productId
    subscriptionDisplayName: 'ProductSubscriptionKey'
    name: 'product-subscription-key'
    primaryKey: keyVault.getSecret('product-subscription-key')
  }
}

创建群组:

module group 'groups/template.bicep' = {
  name: 'groupDeployment'
  params: {
    apimServiceName: apimServiceName
    groupName: 'product-group'
    displayName: 'Product User Group'
  }
}

然后将产品链接到组:

module productGroup 'product-group-links/template.bicep' = {
  name: 'prodcuctGroupDeployment'
  params: {
    apimServiceName: apimServiceName
    productGroupName: group.outputs.id
    productName: testProduct.outputs.productName
  }
}

您还可以使用 Azure 门户中的单击操作手动完成所有这些操作。

© www.soinside.com 2019 - 2024. All rights reserved.