Skip to content

A plugin for RedwoodJS that adds OAuth capabilities to projects using dbAuth. It's designed to provide an easy and effective way to integrate OAuth into your RedwoodJS applications, offering a seamless experience for both developers and end users.

License

Notifications You must be signed in to change notification settings

spoonjoy/redwoodjs-dbauth-oauth

Repository files navigation

RedwoodJS dbAuth OAuth Plugin

A RedwoodJS plugin that adds OAuth capabilities to projects using dbAuth.

API side NPM version Web side NPM version

This is currently in production at spoonjoy.app, check it out!

Overview

This library provides an easy and effective way to integrate OAuth into your RedwoodJS applications, offering a seamless experience for both developers and end users. Currently, it supports OAuth providers including Apple, GitHub, and Google, with a flexible architecture that allows for the expansion to more providers.

This library additionally provides buttons to make setup even more effortless:

button screenshots

Project Structure

The project follows the dbAuth integration pattern as of Redwood version 4 and aligns with the Decoupled Auth strategy. It is structured as a Yarn monorepo with two main packages: web and api.

  • The web package handles the OAuth flow from the user's perspective.
  • The api package manages the communication with the OAuth provider and your database.

This repo also includes a fully set up example project.

For more detailed information on each package, please refer to their respective README files:

Setup Instructions

Setup involves preparing both the web and api sides of your project. First, follow the instructions for setting up the Web side, and then for setting up the API side.

Environment Variables

Most of the environment variables that you'll be adding will be specific to the providers that you choose to use, and are covered in those sections. There are, however, two that you'll need to set regardless:

  • FE_URL - this is the URL of your front end. If you're using Redwood locally out of the box, this will be http://localhost:8910.
    • This is primarily used as a fallback for redirection back from the API to your application.
  • RWJS_API_URL - this is the URL that your API lives at. If you're using Redwood locally out of the box, it'll probably be http://localhost:8910/.redwood/functions
    • This is used primarily in two places:
      • When constructing redirect URIs to give to a provider as part of the OAuth request
      • When making requests from the web side to the api side

Additionally, because RWJS_API_URL is used by the web-side code, you'll need to add it to your redwood.toml. Go ahead and add the following (note that you might have others): includeEnvironmentVariables = ["RWJS_API_URL"]

Enabling OAuth Provider(s)

After setting up both sides, you'll need to enable your chosen OAuth provider(s). Currently supported providers include:

About

A plugin for RedwoodJS that adds OAuth capabilities to projects using dbAuth. It's designed to provide an easy and effective way to integrate OAuth into your RedwoodJS applications, offering a seamless experience for both developers and end users.

Topics

Resources

License

Stars

Watchers

Forks