Add Action from Auth0 Marketplace To Restrict Access By Country

Will Johnson
InstructorWill Johnson
Share this video with your friends

Social Share Links

Send Tweet
Published a year ago
Updated a year ago

With Actions you have the option to use pre-configured Actions from the Auth0 Marketplace.

Add the Country-based Access Action to your Action library to restrict users access based on their country.

Once the Action is added to your library, choose the Login flow trigger. Use the drag and drop flow editor to add the Country-based Access Action to the Auth0 login flow.

Instructor: [0:01] Let's get started with actions from the Auth0 dashboard by going to actions and then library. On the actions library page, you have two options. You have build custom and you have add action. [0:18] To start, we're going to use an action from the actions marketplace. Click add action. Here on the browse action page, here's a list of all the actions that are already pre-made so you don't have to write any code for them. For this example, we're going to do the Country-based Access action.

[0:39] What this action does is that it restricts access to your application based on the user's country. You might want to do this to be able to stop attacks coming from a certain country if there are a lot of attacks coming from that country or if you're not able to do business in that particular country for whatever reason they may be.

[0:59] Click add integration. The next screen will tell you what Country-based Access actions need access to, say that three times fast. Then you click continue. Then you'll be on the configuration screen.

[1:12] The first option it asks you is what countries to block. I'm going to put US for me since I'm located in the United States, and you can even have a custom error description. This says access denied from your location and then we will click create.

[1:32] Now, the Country-based Access action has been added to our library, but it still isn't actually live in the application. For that, let's go to actions flows. On the flows page, you'll be presented with six different trigger point and the Auth0 pipeline that you can use to add your actions.

[1:56] For today, we'll select login. Now, you're on the flow editor. For the login flow, it starts when the user logs in and then the flow is completed when the token is issued. On the right-hand side of the flow editor, we have our Country-based Access action that we added to our library. Click on that, and then drag it in between the start and the completion of the action.

[2:24] Then click apply. Now, our login flow for application is updated. Now, you can have more than one action within a flow. You can actually have a maximum of 20, but we recommend 1 to 3 in order to keep the application fast. Now, let's test out this action by going to the terminal and typing in npm run start.

[2:49] All right. We have our React sample project running again. Let's open up the login menu and it says, "Oops. Access denied from your location." We see that our action has worked. If whatever restrictions that kept you from doing business in that country happened to be removed, you can easily remove that action.

[3:17] Go back to the flow editor that's in the Auth0 dashboard, then click on the Country-based Access action and then just click remove. This will remove that action from the flow.

[3:31] Once it's removed, make sure you click apply and that will update your login flow. Then go back to the sample application, try to login. Then, as you see, I have been logged in. Now, I'm able to access the application from the US again.

egghead
egghead
~ 43 minutes ago

Member comments are a way for members to communicate, interact, and ask questions about a lesson.

The instructor or someone from the community might respond to your question Here are a few basic guidelines to commenting on egghead.io

Be on-Topic

Comments are for discussing a lesson. If you're having a general issue with the website functionality, please contact us at support@egghead.io.

Avoid meta-discussion

  • This was great!
  • This was horrible!
  • I didn't like this because it didn't match my skill level.
  • +1 It will likely be deleted as spam.

Code Problems?

Should be accompanied by code! Codesandbox or Stackblitz provide a way to share code and discuss it in context

Details and Context

Vague question? Vague answer. Any details and context you can provide will lure more interesting answers!

Markdown supported.
Become a member to join the discussionEnroll Today