Soru

Zorluk: Çok zorSecure API Management Endpoints

An organization is deploying an API to Azure API Management (APIM) that communicates with a backend service hosted on Azure App Service. The API must meet the following security requirements:
1. Inbound requests to APIM must be authenticated using OAuth 2.0. APIM must validate that the JWT contains a claim named "roles" containing the value "Writer", and that the token is issued specifically by the company's Azure AD tenant (contoso.onmicrosoft.com). If validation fails, a 401 Unauthorized status must be returned.
2. APIM must authenticate to the backend App Service using a User-Assigned Managed Identity named "apim-identity" (Client ID: 11111111-1111-1111-1111-111111111111).

Which of the following policy configurations should you implement in the APIM policy definition to meet these requirements?

  1. <inbound>
    <base />
    <validate-jwt header-name="Authorization" failed-validation-httpcode="401" failed-validation-error-message="Unauthorized">
    <openid-config url="https://login.microsoftonline.com/contoso.onmicrosoft.com/v2.0/.well-known/openid-configuration" />
    <required-claims>
    <claim name="roles" match="any">
    <value>Writer</value>
    </claim>
    </required-claims>
    </validate-jwt>
    <authentication-managed-identity resource="https://backend.contoso.com" client-id="11111111-1111-1111-1111-111111111111" />
    </inbound>
    Cevap
  2. B
    <inbound>
    <base />
    <validate-jwt header-name="Authorization" failed-validation-httpcode="401" failed-validation-error-message="Unauthorized">
    <openid-config url="https://login.microsoftonline.com/contoso.onmicrosoft.com/v2.0/.well-known/openid-configuration" />
    <required-claims>
    <claim name="roles" match="any">
    <value>Writer</value>
    </claim>
    </required-claims>
    </validate-jwt>
    <authentication-managed-identity resource="https://backend.contoso.com" identity-id="/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/rg/providers/Microsoft.ManagedIdentity/userAssignedIdentities/apim-identity" />
    </inbound>
  3. C
    <inbound>
    <base />
    <validate-jwt header-name="Authorization" failed-validation-httpcode="401" failed-validation-error-message="Unauthorized">
    <openid-config url="https://login.microsoftonline.com/contoso.onmicrosoft.com/v2.0/.well-known/openid-configuration" />
    <required-claims>
    <claim name="roles" match="any">
    <value>Writer</value>
    </claim>
    </required-claims>
    </validate-jwt>
    </inbound>
    <outbound>
    <base />
    <authentication-managed-identity resource="https://backend.contoso.com" client-id="11111111-1111-1111-1111-111111111111" />
    </outbound>
  4. D
    <inbound>
    <base />
    <validate-jwt header-name="Authorization" failed-validation-httpcode="401" failed-validation-error-message="Unauthorized">
    <openid-config url="https://login.microsoftonline.com/contoso.onmicrosoft.com/v2.0/.well-known/openid-configuration" />
    <required-claims>
    <claim name="roles" match="any">
    <value>Writer</value> </claim> </required-claims>
    </validate-jwt>
    <authentication-managed-identity resource="https://backend.contoso.com" />
    </inbound>

Cevap

The policy configuration that places both validate-jwt and authentication-managed-identity with the client-id attribute set to the GUID of the user-assigned managed identity in the inbound section.
The correct configuration places both policies in the inbound section. The validate-jwt policy uses a tenant-specific OpenID Configuration URL to enforce single-tenant token validation and asserts that the roles claim contains the value Writer. The authentication-managed-identity policy correctly specifies the client-id parameter to utilize the user-assigned managed identity.

Adım Adım Çözüm

1
Examine the policy section placement for backend authentication.
The authentication-managed-identity policy must reside in the inbound section so that it executes before the request is forwarded to the backend service.
Placing it in the outbound section would apply authentication to the response returned to the client, which is incorrect.
2
Determine how to configure the user-assigned managed identity in the policy.
The policy requires the client-id attribute set to the GUID of the user-assigned identity.
If client-id is omitted, APIM defaults to the system-assigned managed identity. Using the resource ID path with an incorrect attribute name like identity-id is not supported.
3
Ensure the validate-jwt config targets the correct tenant endpoint.
The openid-config URL must reference the specific tenant (contoso.onmicrosoft.com) to restrict token issuance to that directory.
Using a generic endpoint like common would allow tokens from other directories, violating the security requirements.

Anahtar Kavram

Securing API Management backend connections using User-Assigned Managed Identity authentication policies and validating inbound JWT scopes and claims.
Tahmini Süre:3m 0s
Bu soruyu puanla