Custom API Policy

Upasana Ghosh 351 Reputation points
2022-10-21T13:33:29.44+00:00

............................................

Azure API Management
Azure API Management
An Azure service that provides a hybrid, multi-cloud management platform for APIs.
Azure Policy
Azure Policy
An Azure service that is used to implement corporate governance and standards at scale for Azure resources.
Microsoft Security | Microsoft Entra | Other
{count} votes

Answer accepted by question author
  1. MuthuKumaranMurugaachari-MSFT 22,446 Reputation points Moderator
    2022-10-21T18:54:34.383+00:00

    @Upasana Ghosh I assume that you have used Azure AD & App registration to obtain the token using OAuth 2.0 grant types. Use the following snippet to validate that app-client-id must present on the token for the validation to succeed (refer docs). This way you can validate the token was obtained from specific client(s) (or same client in your case).

        <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/{aad-tenant}/v2.0/.well-known/openid-configuration" />  
            <required-claims>  
                <claim name="aud">  
                    <value>{app-client-id}</value>  
                </claim>  
            </required-claims>  
        </validate-jwt>  
    

    Refer Claims docs which describe about different claims in the token such as aud, oid (user or service principal), roles or groups etc.

    253097-image.png

    Note: In short, application (or user) acquires a token from Azure AD and the token is sent in Authorization header to APIM and then gets validated with set of claims in APIM.

    TechCommunity article describes roles with audience as APIM (hence audience was set along with required-claims).
    253126-image.png

    I hope this answers your question or feel free to add a comment for any other questions. We would be happy to assist you.


0 additional answers

Sort by: Most helpful

Your answer

Answers can be marked as 'Accepted' by the question author and 'Recommended' by moderators, which helps users know the answer solved the author's problem.