# Simple username:password protection for Heroku app

**URL:** <https://community.auth0.com/t/simple-username-password-protection-for-heroku-app/71809>\
**Category:** Get Help\
**Tags:** react, heroku\
**Created:** [October 21, 2021, 5:13pm UTC](https://community.auth0.com/t/simple-username-password-protection-for-heroku-app/71809 "2021-10-21T17:13:17Z")\
**Posts on this page:** 10\
**Page:** 1

<div class="post-metadata">

**Author:** ![dylannirvana](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/dylannirvana/32/32508_2.png) [@dylannirvana](https://community.auth0.com/u/dylannirvana)\
**Post date:** [October 21, 2021, 5:13pm UTC](https://community.auth0.com/t/simple-username-password-protection-for-heroku-app/71809/1 "2021-10-21T17:13:18Z")

</div>

I have a Heroku website where I have Auth0 as an _add-on_. I am only looking to secure the app for a few users while it is in development. Just simple username:password protection, with no registration. No new users.

For some reason, this simple implementation escapes me. The documentation and examples have kind of made this more complicated than it needs to be.

I am just unfamiliar with Auth0, and would love it if I could find some clear direction on how to do this, step by step.

Sorry for such a pedestrian question. But I suppose other people may benefit from the answer as well. Thanks!

---

<div class="post-metadata">

**Author:** ![rueben.tiow](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/rueben.tiow/32/11646_2.png) [@rueben.tiow](https://community.auth0.com/u/rueben.tiow)\
**Post date:** [October 21, 2021, 10:58pm UTC](https://community.auth0.com/t/simple-username-password-protection-for-heroku-app/71809/3 "2021-10-21T22:58:09Z")

</div>

Hi @dylannirvana,

Welcome to the Auth0 Community!

I understand that you need some guidance on configuring your Heroku App with the Auth0 add-on. I’d be happy to help.

First, could you please clarify what do you specifically need help with your configuration with Auth0?

I have found this related documentation from Heroku: [https://devcenter.heroku.com/articles/auth0](https://devcenter.heroku.com/articles/auth0)

And, could you please clarify which SDK you are using?

Thank you.

---

<div class="post-metadata">

**Author:** ![dylannirvana](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/dylannirvana/32/32508_2.png) [@dylannirvana](https://community.auth0.com/u/dylannirvana)\
**Post date:** [October 21, 2021, 11:36pm UTC](https://community.auth0.com/t/simple-username-password-protection-for-heroku-app/71809/4 "2021-10-21T23:36:06Z")

</div>

Hey Rueben,  
Thanks man, I do need a little help. I am completely unfamiliar with the Auth0 ecosystem. And as essentially a Front End Developer, I have to work a little harder understanding Back End systems (though often it turns out to be pretty straight forward).

The app is a single page website, static HTML in a React wrapper. A `npx create-react-app` application. I’m running on Heroku, and served Auth0 as an add-on mainly for security purposes: I just want to lock down the application to all but a handful of developers who are working on the project.

As a Heroku add-on, I am expecting a simple redirect to a sign in page. No registration. No new users. Basic and simple as it gets. Just don’t want to expose authentication client-side.

Auth0 documentation is so broad and robust, they don’t even deal with the possibility that a person just wants to clamp down access to a simple webpage.

Easy is so hard these days.  
Dylan

---

<div class="post-metadata">

**Author:** ![rueben.tiow](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/rueben.tiow/32/11646_2.png) [@rueben.tiow](https://community.auth0.com/u/rueben.tiow)\
**Post date:** [October 22, 2021, 12:19am UTC](https://community.auth0.com/t/simple-username-password-protection-for-heroku-app/71809/5 "2021-10-22T00:19:41Z")

</div>

Hi @dylannirvana,

Thank you for your response.

For starters, have you created a [Single Page Application](https://auth0.com/docs/get-started/create-apps/single-page-web-apps) on your Auth0 Dashboard?

You can do this by going to your Auth0 [Dashboard\>Applications](https://manage.auth0.com/#/applications) and clicking on _Create Application_ and choosing _Single Page Web Applications_ as your Application Type.

This will serve your Universal Login Page for your users.

Then, to make sure that sign-ups are disabled, navigate to your _Username-Password-Authentication_ Database Connection in your [Dashboard\>Authentication\>Database](https://manage.auth0.com/#/connections/database) and switch on the **Disable Sign Ups** toggle.

Then proceed to create these Whitelisted users within that Database connection, and this will grant them access to the application.

After this is complete, you should have everything set up on the Auth0 side, and you can continue with the configuration for the Auth0 add-on on Heroku.

Please let me know if you have any further questions.

Thank you.

---

<div class="post-metadata">

**Author:** ![dylannirvana](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/dylannirvana/32/32508_2.png) [@dylannirvana](https://community.auth0.com/u/dylannirvana)\
**Post date:** [October 22, 2021, 12:39am UTC](https://community.auth0.com/t/simple-username-password-protection-for-heroku-app/71809/6 "2021-10-22T00:39:28Z")

</div>

@rueben.tiow Thank you so much for your help.

There are two applications in there already: Auth0 Dashboard Backend Management Client and Default App. I think the first one is what is connected to Heroku. I went into this and designated it as a SPA.

Are you suggesting I create a third app?

Also, where would I create whitelisted users? I don’t see this in Database.

---

<div class="post-metadata">

**Author:** ![rueben.tiow](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/rueben.tiow/32/11646_2.png) [@rueben.tiow](https://community.auth0.com/u/rueben.tiow)\
**Post date:** [October 22, 2021, 3:47pm UTC](https://community.auth0.com/t/simple-username-password-protection-for-heroku-app/71809/8 "2021-10-22T15:47:20Z")

</div>

Hi @dylannirvana,

Thank you for your response.

That’s correct, there are already two applications there. However, to clarify, the _API Explorer Application_ must be a **Machine-to-Machine** application type and generally left the way it is. It is used for the [_Auth0 Management API_](https://auth0.com/docs/api/management/v2).

The _Default App_ could be used and configured for your application, but I leave it alone because the Default App name is not very meaningful.

Instead, I recommend that you create a third application using the _Create Application_ button, give your application a meaningful name, select **Single Page Application** as your application type and, press _Create_.

While you’re still in your new application, be sure to scroll down in the Settings to **Allowed Callback URLs** and **Allowed Logout URLs** and include the necessary callback URLs. See [here](https://auth0.com/docs/quickstart/spa/react#configure-callback-urls) for more details.

Once that is complete, you have completed the configuration for your Auth0 SPA Application.

Now, keep a note of the following properties:

- Client ID
- Client Secret
- Domain
- Allowed Callback URL

These values are needed to set up your configuration variables in your Heroku [environment setup](https://devcenter.heroku.com/articles/auth0#provisioning-the-add-on).

Now, to create your whitelisted users you can navigate to [Dashboard\>User Management\>Users](https://manage.auth0.com/#/users) and press on the _Create User_ button. From here, create those users individually, making sure the connection is set to the _Username-Password-Authentication_ connection.

Double-check that the _Username-Password-Authentication_ has **Disable Sign Ups** enabled. After doing so, you will have created an isolated Database for your users.

Lastly, you may not want to allow this DB connection to authenticate on other applications. To restrict access to only your new app, go to the _Username-Password-Authentication connection \> Applications_ and disable other applications.

I hope this helps! Please let me know how this works for you.

Thank you.

---

<div class="post-metadata">

**Author:** ![dylannirvana](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/dylannirvana/32/32508_2.png) [@dylannirvana](https://community.auth0.com/u/dylannirvana)\
**Post date:** [October 24, 2021, 1:17pm UTC](https://community.auth0.com/t/simple-username-password-protection-for-heroku-app/71809/9 "2021-10-24T13:17:33Z")

</div>

@rueben.tiow  
Hey I followed all the steps. I added [http://localhost:3000](http://localhost:3000) accordingly. All the credentials are correct. Added the wrapper code to src/index.js, (which says it will work by React _context_) with Auth0Provider. It doesn’t.

All I want to do is password protect a website hosted on Heroku. I don’t want login buttons, special routing. When someone navigates to the URL, I want them to be confronted with the Universal Login. If they are a whitelisted user, they get in.

I can’t believe how difficult this has been. This should be so simple. I don’t know where it is breaking down. The sample apps are so robust and overkill (and even after `npm i` do not compile anyway).

It would be brilliant if someone could shine the light on what I am missing here.  
Thank you!

---

<div class="post-metadata">

**Author:** ![rueben.tiow](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/rueben.tiow/32/11646_2.png) [@rueben.tiow](https://community.auth0.com/u/rueben.tiow)\
**Post date:** [October 25, 2021, 11:41pm UTC](https://community.auth0.com/t/simple-username-password-protection-for-heroku-app/71809/10 "2021-10-25T23:41:47Z")

</div>

Hi @dylannirvana,

Thank you for your response.

Could you please clarify whether you have been ​following the Heroku Docs to set up your Heroku App with the Auth0 Add-on? [https://devcenter.heroku.com/articles/auth0](https://devcenter.heroku.com/articles/auth0)

There is no need to go as far as adding the wrapper code. That documentation was only to explain the purpose of the Allowed Callback URLs and Allowed Logout URLs. Based on Heroku’s docs, you only need to set up the application on the Auth0 side.

Which you should have done so if you

1. Create an Auth0 app
2. Add the Allowed Callback URLs and
3. Added Allowed Logout URLs

You had to configure a few extra steps because you wanted **no sign-ups** and only **allow a selected number of users** access. This was accomplished by configuring the `Username-Authentication-Password` DB connection in Auth0.

After that, you will have to resume configuring on Heroku: [https://devcenter.heroku.com/articles/auth0#local-setup](https://devcenter.heroku.com/articles/auth0#local-setup).

That should be the extent of your configuration for Heroku with Auth0 as an Addon.

If you encounter any problems configuring on the Heroku with the Auth0 Addon, I recommend that you also contact Heroku Support [as mentioned in their docs](https://devcenter.heroku.com/articles/auth0#support).

Thank you.

---

<div class="post-metadata">

**Author:** ![konrad.sopala](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/konrad.sopala/32/13516_2.png) [@konrad.sopala](https://community.auth0.com/u/konrad.sopala)\
**Post date:** [November 18, 2021, 10:29am UTC](https://community.auth0.com/t/simple-username-password-protection-for-heroku-app/71809/12 "2021-11-18T10:29:49Z")

</div>

Previous message deleted due to SPAM reasons.

---

<div class="post-metadata">

**Author:** ![system](https://global.discourse-cdn.com/auth0/original/3X/b/5/b560f266932fcce5d57f09a6595bd50518cae3f3.jpeg) [@system](https://community.auth0.com/u/system)\
**Post date:** [December 3, 2021, 10:30am UTC](https://community.auth0.com/t/simple-username-password-protection-for-heroku-app/71809/13 "2021-12-03T10:30:22Z")

</div>

This topic was automatically closed 15 days after the last reply. New replies are no longer allowed.
