Created
August 20, 2019 06:49
-
-
Save svenmalvik/ba028ce3e4f1a81ff18417f531b5eb84 to your computer and use it in GitHub Desktop.
This policy snippet prevents one from using the master key by accident.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<choose> | |
<when condition="@(context.Subscription != null && context.Subscription.Id == "master")"> | |
<return-response> | |
<set-status code="400" reason="Bad Request" /> | |
<set-header name="Content-Type" exists-action="override"> | |
<value>application/json; charset=UTF-8</value> | |
</set-header> | |
<set-body>{"message": "Access denied due to invalid subscription key."}</set-body> | |
</return-response> | |
</when> | |
</choose> |
Hi there,
Does this Gist still work? I've deployed a new APIM instance today and copy/pasted this Gist to the global "App APIs" inbound policy but can still call API's with the service master subscription key.
I've confirmed by setting an outbound header that context.Subscription.Id is definitely "master", but I can't work out why the inbound policy isn't evaluated.
I would appreciate your thoughts.
You know what - ignore that - found that my API's don't have <base />
included! Added that and success! Thanks for the Gist!
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Hi there,
Does this Gist still work? I've deployed a new APIM instance today and copy/pasted this Gist to the global "App APIs" inbound policy but can still call API's with the service master subscription key.
I've confirmed by setting an outbound header that context.Subscription.Id is definitely "master", but I can't work out why the inbound policy isn't evaluated.
I would appreciate your thoughts.