Created
July 23, 2023 08:35
-
-
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.
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
# 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