From 0866b105bd812dcbb81ebeb2cbc6daf2b7e2ee00 Mon Sep 17 00:00:00 2001 From: Leo Wilkin Date: Sun, 30 Jun 2024 15:05:40 +0100 Subject: [PATCH] Add NextAuth & fix some fluency errors & more! (#22) * Update hosting-guide.mdx * Update config to include new info about NextAuth * Fix some grammatical things & add callout for Windows testers * Update configuration.mdx * remove stupid curly bracket * Update hosting-guide.mdx * Update pages/self-hosting/configuration.mdx Co-authored-by: Badr B. * Update configuration.mdx * Update pages/self-hosting/hosting-guide.mdx * Update hosting-guide.mdx * Remove Linode --------- Co-authored-by: Badr B. --- pages/self-hosting/configuration.mdx | 17 +++++++++++++++++ pages/self-hosting/hosting-guide.mdx | 26 ++++++++++++++++++++++++-- 2 files changed, 41 insertions(+), 2 deletions(-) diff --git a/pages/self-hosting/configuration.mdx b/pages/self-hosting/configuration.mdx index 0b7383e..f637ffe 100644 --- a/pages/self-hosting/configuration.mdx +++ b/pages/self-hosting/configuration.mdx @@ -142,13 +142,30 @@ Your System Email Address You can also configure your frontend by creating a `.env` file in the `apps/web` folder. +### Authentication (Oauth) configuration +Following the integration of OAuth using NextAuth to manage sign-ups/ins. For this to work, you now need to add two lines to your `.env` config file. + + +To safely encrypt tokens and email hashes, you need a NextAuth secret. + +To create one, either run `npx auth secret`, or on UNIX based systems (MacOS/Linux) you can use `openssl rand -base64 33`. + +Copy this string into your .env file as NEXTAUTH_SECRET. + + Here is an example of the `.env` file : ```env filename="apps/web/.env" {1-2} +# Learnhouse configuration NEXT_PUBLIC_LEARNHOUSE_MULTI_ORG=false NEXT_PUBLIC_LEARNHOUSE_DEFAULT_ORG=defaultorg +# NextAuth Configuration +NEXTAUTH_SECRET={generated_secret} +NEXTAUTH_URL=http://localhost:3000/ ``` +To learn more about Custom Authentication, visit the NextAuth docs [here](https://authjs.dev/getting-started/authentication). + ### Multi Organizations Please check the [Multi Organization](./organization-hosting-modes) section for more information. diff --git a/pages/self-hosting/hosting-guide.mdx b/pages/self-hosting/hosting-guide.mdx index 04212b9..4ddf81f 100644 --- a/pages/self-hosting/hosting-guide.mdx +++ b/pages/self-hosting/hosting-guide.mdx @@ -3,13 +3,17 @@ import { Steps } from 'nextra-theme-docs' # Self hosting guide -We use Docker & Docker compose to run LearnHouse, this makes it easy to run the application on any machine that has Docker installed. +We use Docker & Docker Compose to run LearnHouse, this makes it easy to run the application on any machine that has Docker installed. -Tested on : +Tested on: - macOS Sonoma - Ubuntu 23.04 Lunar lobster - (Need testers on Windows) + +Interested in helping test on Windows? Join our [Discord](https://discord.com/invite/CMyZjjYZ6x) community. + + ## Prerequisites - [Docker](https://docs.docker.com/get-docker/) @@ -34,6 +38,24 @@ git clone https://github.com/learnhouse/learnhouse cd learnhouse ``` +### Configure NextAuth + +Add these lines to your `.env` file. A template is available under `/extra/example-learnhouse-conf.env`. + + +To safely encrypt tokens and email hashes, you need a NextAuth secret. + +To create one, either run `npx auth secret`, or on UNIX based systems (MacOS/Linux) you can use `openssl rand -base64 33`. + +Copy this string into your .env file as NEXTAUTH_SECRET= + + +```env filename=".env" +# NextAuth Configuration +NEXTAUTH_SECRET={generated_secret} +NEXTAUTH_URL=http://localhost:3000/ +``` + ### Build and run LearnHouse ```shell copy