Last active
March 15, 2022 02:01
-
-
Save adamstraube/cd47b8e3e0ac090b7a81e46493f64117 to your computer and use it in GitHub Desktop.
Geoblocking by country code for use in Auth0 Actions
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
/** | |
* Geoblock users by Country code | |
* | |
* The action below blocks the following countries: | |
* - Russia | |
* - Belarus | |
* - Iran | |
* - Cuba | |
* - Syria | |
* - North Korea | |
* | |
* You can lookup more country codes here: http://www.ip2country.net/ip2country/country_code.html | |
*/ | |
const countryCodeList = [ | |
"RU", "BY", "IR", "CU", "SY", "KP" | |
]; | |
exports.onExecutePostLogin = async (event, api) => { | |
if ( countryCodeList.includes(event.request.geoip.countryCode) ) { | |
const countryName = event.request.geoip.countryName; | |
api.access.deny(`Users from ${countryName} are not allowed!`); | |
}; | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment