I created this repository, to introduce Hive's students and 42 students overall to create NextJS application with 42 OAuth authentication with NextAuth.js.
First of all, you will need to create a 42OAuth application. You can create your app from the intra on this page
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!
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:
- the 42 Getting started and Guides pages.
- the 42 API endpoints.
- the JWT Introduction page.
TODO - will come soon
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!