/next-42auth-demo

A demo repository to showcase Next.js, NextAuth with 42 School provider.

Primary LanguageJavaScript

next-42auth-demo

Created by Jordane Gengo (Titus)
From Hive Helsinki

I created this repository, to introduce Hive's students and 42 students overall to create NextJS application with 42 OAuth authentication with NextAuth.js.

Table of contents


Requirements

Create a 42 OAuth application

First of all, you will need to create a 42OAuth application. You can create your app from the intra on this page

create app

Redirect URI: Add potential (and allowed) redirect URI per line.

You can use the same app for your dev and prod environment. However, the best practice is to create one for each environment (dev, staging and prod).

So for example your could add:

http://localhost:3000/api/auth/callback/42-school
http://localhost:3001/api/auth/callback/42-school
http://domain.nl/api/auth/callback/42-school

Scopes: You can check scopes you are might need (on behalf of the user). For instance if you want to create an application allowing one to schedule evaluations slots, you will need to check "Manage teams, slots and all projects related stuff".

Submit!

example app

After creating your app, you will be provided a uid and secret that will need to be informed into .env

To acknowledge:

42central decided to create a secret rotation for security reasons, imposing you to rotate your secret every 30 days.

I highly encourage reading:

Steps by steps

TODO - will come soon

TL;DR

Create the Next.JS app

Add auth API endpoints

Encapsulate the session information

Access the session information

Sign in / Sign out

Contributing

Please note that I'm not an expert in Next.js or the JavaScript ecosystem overall.

However, I welcome contributions to make this repository a better reference for my peers.

Your suggestions and input are always appreciated!