ryanntannn / sgid-next-auth

NextAuth provider for sgid

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

The example repository is maintained from a monorepo. Pull Requests should be opened against nextauthjs/next-auth.


NextAuth.js - Example App

Open Source. Full Stack. Own Your Data.

npm Bundle Size Downloads TypeScript

Overview

NextAuth.js is a complete open-source authentication solution.

Go to next-auth.js.org for more information and documentation.

The base project this was shamelessly stolen from https://github.com/nextauthjs/next-auth-example

Getting Started

1. Clone the repository and install dependencies

git clone git@github.com:tiongg/sgid-next-auth.git
cd next-auth-sgid
pnpm i

2. Configure your local environment

Copy the .env.local.example file in this directory to .env.local (which will be ignored by Git):

cp .env.local.example .env.local

Add details for one or more providers (e.g. Google, Twitter, GitHub, Email, etc).

Database

A database is needed to persist user accounts and to support email sign in. However, you can still use NextAuth.js for authentication without a database by using OAuth for authentication. If you do not specify a database, JSON Web Tokens will be enabled by default.

You can skip configuring a database and come back to it later if you want.

For more information about setting up a database, please check out the following links:

3. Configure SGID

  1. Review and update SgidProvider options in pages/api/auth/[...nextauth].js as needed.

  2. When setting up sgid, configure the callback URL to {server}/api/auth/callback/sgid in the sgid dev portal

e.g. http://localhost:3000/api/auth/callback/sgid

4. Start the application

To run your site locally, use:

pnpm run dev

Using it outside of this project

  1. Copy pages/api/providers/sgid.provider.ts and paste it into your app

  2. Configure profile as needed

Acknowledgements

https://github.com/nextauthjs/next-auth-example: The base template
https://github.com/opengovsg/sgid-client: Sgid Client

About

NextAuth provider for sgid

License:MIT License


Languages

Language:TypeScript 92.1%Language:CSS 7.6%Language:JavaScript 0.3%