Skip to content

Instantly share code, notes, and snippets.

@adamstraube
Last active March 15, 2022 02:01
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 adamstraube/cd47b8e3e0ac090b7a81e46493f64117 to your computer and use it in GitHub Desktop.
Save adamstraube/cd47b8e3e0ac090b7a81e46493f64117 to your computer and use it in GitHub Desktop.
Geoblocking by country code for use in Auth0 Actions
/**
* 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