Authentication
Setting up authentication for your application
SaaSKits comes with pre-built authentication for your application.
It uses Remix Auth for authentication.
SaaSKits uses Remix's inbuilt session management to manage user sessions.
SaaSKits has two types of providers for authentication:
- Email and Password
Email and Password
To enable email and password authentication, you need to set the following environment variables:
SESSION_SECRET=
HOST_URL=
This is the secret used to sign the session cookie. It is recommended to use a random string of at least 32 characters.
Google Authentication
To enable Google authentication, you need to set the following environment variables:
GOOGLE_CLIENT_ID=
GOOGLE_CLIENT_SECRET=
You can get these values from the Google Developer Console.
Create/Select a new project
Go to the Google Developer Console and create/select a new project.
APIs & Services
Go to the APIs & Services section.
Credentials
Go to the Credentials section.
Create Credentials
Click on the Create Credentials
button and select OAuth client ID
.
Configure Consent Screen
Select External
and click on the Create
button.
Fill in the following details:
Application name: <Your Application Name>
User support email: <Your Support Email>
Developer contact information: <Your Support Email>
Click on the Save and Continue
button.
Configure Scopes
No need to change anything here. Click on the Save and Continue
button.
Test Users
No need to change anything here. Click on the Save and Continue
button.
Click on the Back to Dashboard
button.
Publish App
Click on the Publish App
button and push to production.
Go to Credentials
Click on the Go to Credentials
button.
Create Credentials
Click on the Create Credentials
button and select OAuth client ID
.
Configure OAuth Client
Select Web application
and enter the following details:
Authorized JavaScript origins: <Your Application URL> (e.g http://localhost:3000)
Authorized redirect URIs: <Your Application URL>/google/callback (e.g http://localhost:3000/google/callback)
Click on the Create
button.
Copy Client ID and Client Secret
Copy the Client ID
and Client Secret
and add them to your .env
file.
GOOGLE_CLIENT_ID=
GOOGLE_CLIENT_SECRET=
Don't forget to add the following to your .env
file:
SESSION_SECRET=
HOST_URL=
This is the secret used to sign the session cookie. It is recommended to use a random string of at least 32 characters.
We are all set with authentication now. Let's move on to next step.