简体   繁体   English

Azure kubernetes - 如何使用 Azure API 管理对 kubernetes API 进行身份验证?

[英]Azure kubernetes - How do I use Azure API management to authenticate kubernetes APIs?

I have deployed an application on Azure kubernetes without authentication and I have the Azure API management in front of the API.我在没有身份验证的情况下在 Azure kubernetes 上部署了一个应用程序,并且在 API 前面有 Azure API 管理。

How do I use the Azure API management to authenticate kubernetes APIs?如何使用 Azure API 管理对 kubernetes API 进行身份验证?

<validate-jwt header-name="Authorization" failed-validation-httpcode="401" failed-validation-error-message="Unauthorized. Access token is missing or invalid.">
    <openid-config url="https://login.microsoftonline.com/contoso.onmicrosoft.com/.well-known/openid-configuration" />
    <audiences>
        <audience>25eef6e4-c905-4a07-8eb4-0d08d5df8b3f</audience>
    </audiences>
    <required-claims>
        <claim name="id" match="all">
            <value>insert claim here</value>
        </claim>
    </required-claims>
</validate-jwt>

How are you authenticating your APIM url?您如何验证您的 APIM 网址?

Here is a raw way of achieving authentication这是实现身份验证的原始方法

  1. Generate a JwT from Azure AD (this could be your Web UI)从 Azure AD 生成 JwT(这可能是您的 Web UI)
  2. Enable OAuth2 for your APIM为您的 APIM 启用 OAuth2
  3. While calling APIM from your UI JwT token will be passed从您的 UI JwT 令牌调用 APIM 时将传递
  4. Upon receiving the token at the APIM, create an inbound policy to Validate the JwT https://docs.microsoft.com/en-us/azure/api-management/api-management-access-restriction-policies在 APIM 收到令牌后,创建入站策略以验证 JwT https://docs.microsoft.com/en-us/azure/api-management/api-management-access-restriction-policies
  5. Once the JwT is validated call the backend Kubernetes deployed endpoints.一旦 JwT 被验证,调用后端 Kubernetes 部署的端点。
  6. You may want to restrict your ingress controller to only accept traffic from the APIM您可能希望限制入口控制器仅接受来自 APIM 的流量
  7. Your http context will contain the user information from the JwT token at the api endpoint您的 http 上下文将包含来自 api 端点的 JwT 令牌的用户信息
  8. If you want you can further use this info from #7 at your middleware time write your custom auth logic.如果您愿意,可以在中间件时进一步使用 #7 中的此信息,请编写自定义身份验证逻辑。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 是否可以使用Azure API Management和Azure ACS(kubernetes)作为前端和后端? - Is it possible to use Azure API Management and Azure ACS (kubernetes) as frontend and backend? Azure kubernetes - 在 Azure API 管理中注册服务? - Azure kubernetes - register services in Azure API management? Azure kubernetes 和 Azure API 管理:Azure AD 身份验证? - Azure kubernetes and Azure API management : Azure AD authentication? 如何使用Azure B2C保护Azure API管理API - How do I secure Azure API Management APIs using Azure B2C 如何以编程方式对 Azure Kubernetes (AKS) 进行身份验证 - How to programmatically authenticate to Azure Kubernetes (AKS) 如何使用 azure msal 库访问 azure 服务管理 api? - How do I use the azure msal library to access azure service management apis? Azure kube.netes - Session 管理应用程序? - Azure kubernetes - Application with Session management? 如何使用部署在 Azure Z303136395F01189 中的微服务进行 Azure API 管理(基本层) - How to Azure API Management (BASIC TIER) with microservices deployed in Azure Kubernetes Service 如何使用 Azure API 管理链接 API - How to chain APIs using Azure API management 如何验证对Windows Azure的管理服务请求? - How do I authenticate a management service request to Windows Azure?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM