Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save deangrant/d322637c4117e4a0f573111c4f33655b to your computer and use it in GitHub Desktop.
Save deangrant/d322637c4117e4a0f573111c4f33655b to your computer and use it in GitHub Desktop.
Azure Web Application Firewall rule to set exposed path recommendations for Keycloak and restrict by host requester header and permitted remote IP addresses.
# Change the {{ host }} value in []matchConditions > {} 0 > [] matchValues to a array of host header
# values allowed and {{ remoteAddr }} value and []matchConditions > {} 2 > [] matchValues to an array
# of remote IP addresses allowed.
# For more information on exposed path recommendations in Keycloak, see
# https://www.keycloak.org/server/reverseproxy#_exposed_path_recommendations
{
"action": "Block",
"matchConditions": [
{
"matchValues": [
"{{ host }}"
],
"matchVariables": [
{
"selector": "host",
"variableName": "RequestHeaders"
}
],
"negationConditon": false,
"operator": "Equal",
"transforms": []
},
{
"matchValues": [
"\\/welcome",
"\\/metrics",
"\\/health",
"\\/$",
"\\/admin.*"
],
"matchVariables": [
{
"variableName": "RequestUri"
}
],
"negationConditon": false,
"operator": "Regex",
"transforms": []
},
{
"matchValues": [
"{{ remoteAddr }}"
],
"matchVariables": [
{
"variableName": "RemoteAddr"
}
],
"negationConditon": true,
"operator": "IPMatch",
"transforms": []
}
],
"name": "KeycloakExposedPathRecommendations",
"priority": 99,
"ruleType": "MatchRule",
"state": "Enabled"
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment