1. 10
    Configure Fauna to Authenticate with Auth0 in a Next.js Application
    2m 15s

Configure Fauna to Authenticate with Auth0 in a Next.js Application

Shadid Haque
InstructorShadid Haque
Share this video with your friends

Social Share Links

Send Tweet

Now that we have login working, we'll need to configure Fauna with Auth0 to give logged in vendors more permissions than logged out users.

We'll start by creating a role that includes creating, updating, and deleting data in our database. In the provider tab, we'll create an access provider and set issuer and JWKS urls that we got from Auth0. This will create an Audience URL that we will set in Auth0 and Next.js.

Shadid Haque: [0:00] Let's configure Fauna for Auth0. We want authenticated users to be able to create, delete, and update records in our database. Let's go ahead and create a new role for that. We're going to call this role AuthRole. Let's give create, update, and delete permission to both Shop and Product collection.

[0:19] Next, we'll go to Security and go to the provider tab. We'll create a new access provider for Auth0. Let's name this Auth0. We'll go back to our code, and from our environment variable, we're going to get the issuer URL. Make sure you add a trailing backslash here.

[0:56] For the JWKS endpoint, we are going to paste the issuer URL and then backslash and then .well-known and then backslash and we're going to write jwks.json. That's going to be our JWKS endpoint.

[1:17] Next, we're going to select a role. Let's go ahead and select our Auth0 role. We're going to copy this audience URL, and we're going to go back to our code.

[1:31] In our environment variable, we're going to create a new environment variable. We're going to call it AUTH0_AUDIENCE and paste in that audience URL. Let's go back to Fauna dashboard and save everything.

[1:45] Next, we will go back to Auth0 dashboard. From here, we're going to select APIs, and we're going to select Create API. We're going to give our API a name. For Identifier, we will paste in the audience URL from Fauna. Finally, we'll select Create. Now, we have successfully configured Fauna to work with Auth0.