Skip to content
⚠️ Open SaaS is now running on Wasp v0.13! If you're running an older version of Open SaaS, please follow the migration instructions here ⚠️

Authentication

Setting up your app’s authentication is easy with Wasp. In fact, it’s aready set up for your in the main.wasp file:

main.wasp
auth: {
userEntity: User,
methods: {
email: {},
google: {},
gitHub: {}
},
onAuthFailedRedirectTo: "/",
},

The great part is, by defining your auth config in the main.wasp file, Wasp manages most of the Auth process for you, including the auth-related databse entities for user credentials and sessions, as well as auto-generated client components for your app on the fly (aka AuthUI — you can see them in the src/client/auth folder).

Email Verified Auth

The email method, with it’s use of an Email Sending provider to send verification and password reset emails to the user’s email address, is the default auth method in Open SaaS.

We’ve pre-configured the email auth method for you in a number of different files so you can get started quickly. In order to use the email auth method, you’ll need to switch from the Dummy email provider to a production-ready provider like SendGrid:

  1. First, set up the your app’s emailSender in the main.wasp file by following this guide.
  2. Add your SENDGRID_API_KEY to the .env.server file.
  3. Make sure the email address you use in the fromField object is the same email address that you configured your SendGrid account to send out emails with. In the end, your main.wasp file should look something like this:
main.wasp
auth: {
methods: {
email: {
fromField: {
name: "Open SaaS App",
// When using SendGrid, you must use the same email address that you configured your account to send out emails with!
email: "me@example.com"
},
//...
},
}
},
//...
emailSender: {
provider: Dummy,
provider: SendGrid,
defaultFrom: {
name: "Open SaaS App",
// When using SendGrid, you must use the same email address that you configured your account to send out emails with!
email: "me@example.com"
},
},

And that’s it. Wasp will take care of the rest and update your AuthUI components accordingly.

Check out the Wasp Auth docs for more info.

Google & GitHub Auth

We’ve also customized and pre-built the Google and GitHub auth flow for you. To start using them, you just need to uncomment out the methods you want in your main.wasp file and obtain the proper API keys to add to your .env.server file.

To create a Google OAuth app and get your Google API keys, follow the instructions in Wasp’s Google Auth docs.

To create a GitHub OAuth App add get your GitHub API keys, you can follow the instructions in Wasp’s GitHub Auth docs.

Again, Wasp will take care of the rest and update your AuthUI components accordingly.