
* Squashed commit of the following:
commit 26ab03fb36fcc7fcee63fdf3ae8c2dfb29027eff
Author: bsu3338 <bsu3338@users.noreply.github.com>
Date: Tue Jun 13 00:23:23 2023 -0500
Update Registration.spec.tsx
commit e908dd82fe9ef1b43c75ee64c183d2f654bdac1c
Author: bsu3338 <bsu3338@users.noreply.github.com>
Date: Tue Jun 13 00:23:01 2023 -0500
Update Login.spec.tsx
commit 223734820fb77d7fb5af4802af642d1c1fd7c1f5
Author: bsu3338 <bsu3338@users.noreply.github.com>
Date: Tue Jun 13 00:22:39 2023 -0500
Update Registration.tsx
commit 7036d3dd0538979ee397d958ebc113bb0ea32411
Author: bsu3338 <bsu3338@users.noreply.github.com>
Date: Tue Jun 13 00:21:55 2023 -0500
Update Login.tsx
commit 76bb78221db3195fd930fe9cfd6a5da7194fa759
Author: bsu3338 <bsu3338@users.noreply.github.com>
Date: Tue Jun 13 00:21:03 2023 -0500
Update envConstants.js
commit ee2f69f33d75fbb57022afbcd9564bca38a46bee
Author: bsu3338 <bsu3338@users.noreply.github.com>
Date: Tue Jun 13 00:20:08 2023 -0500
Update docker-compose.yml
commit 5ac72d789b3446884c6e2f4f595cbf67d731d43c
Author: bsu3338 <bsu3338@users.noreply.github.com>
Date: Tue Jun 13 00:18:41 2023 -0500
Update Dockerfile
commit d24341db2bd5b17eb89ab01e171a5f51f3beab0a
Author: bsu3338 <bsu3338@users.noreply.github.com>
Date: Tue Jun 13 00:16:38 2023 -0500
Update .env.example
commit 22154f4a09c5fcdfee95d43609fb01a5a883b7a9
Author: bsu3338 <bsu3338@users.noreply.github.com>
Date: Tue Jun 13 00:07:48 2023 -0500
Update Registration.spec.tsx
commit 5163f7d372a6a03c94f4357b358211a03369456e
Author: bsu3338 <bsu3338@users.noreply.github.com>
Date: Tue Jun 13 00:07:30 2023 -0500
Update Login.spec.tsx
commit 61da49e330a9376e130b24dc944854f97ab58d80
Author: bsu3338 <bsu3338@users.noreply.github.com>
Date: Tue Jun 13 00:07:00 2023 -0500
Update Registration.tsx
commit 0e45d3f0dbde34388ff2f0b2dc51b983b472eb05
Author: bsu3338 <bsu3338@users.noreply.github.com>
Date: Tue Jun 13 00:06:18 2023 -0500
Update Login.tsx
commit dca1e5367e5f3b468c7964218cc5914ca53095af
Author: bsu3338 <bsu3338@users.noreply.github.com>
Date: Tue Jun 13 00:05:07 2023 -0500
Update envConstants.js
commit f48c058465d82b03716ba85224e9f97007e014d2
Author: bsu3338 <bsu3338@users.noreply.github.com>
Date: Tue Jun 13 00:04:05 2023 -0500
Update .env.example
commit 818226c9cb079acae4fcbfe5997e4aa9e3c6d2cc
Author: bsu3338 <bsu3338@users.noreply.github.com>
Date: Mon Jun 12 23:59:08 2023 -0500
Update .env.example
commit 9a805439189b352a38ac7654d7a31bb28f0f58dd
Author: bsu3338 <bsu3338@users.noreply.github.com>
Date: Mon Jun 12 23:58:31 2023 -0500
Update env.d.ts
commit 3f37ce54758b017c9281b7fad9b040a47630ec66
Author: bsu3338 <bsu3338@users.noreply.github.com>
Date: Mon Jun 12 23:57:04 2023 -0500
Update .env.example
commit 1026036f4dd529e9531c53084450ce768cfca4c1
Author: bsu3338 <bsu3338@users.noreply.github.com>
Date: Mon Jun 12 23:50:36 2023 -0500
Update docker-compose.yml
commit a61cf7b8c51d4a9bd73a20bd67abc29891c11463
Author: bsu3338 <bsu3338@users.noreply.github.com>
Date: Mon Jun 12 23:50:00 2023 -0500
Update Dockerfile
commit 79610d6648755cd5ec45215b9fdbe04ba8242fcf
Author: bsu3338 <bsu3338@users.noreply.github.com>
Date: Mon Jun 12 23:35:34 2023 -0500
Update package-lock.json
commit e40853fd2b77f2db5be1c3dfd8b170d650e23271
Author: bsu3338 <bsu3338@users.noreply.github.com>
Date: Mon Jun 12 23:30:17 2023 -0500
Update envConstants.js
commit 5529bc61b43f279fb4418c3851be2f9011b6454d
Author: bsu3338 <bsu3338@users.noreply.github.com>
Date: Mon Jun 12 23:25:58 2023 -0500
Update docker-compose.yml
commit 07848cc464a64f7cad484e24a1310dc61aa03b18
Merge: ec628a3 72e9828
Author: bsu3338 <bsu3338@users.noreply.github.com>
Date: Mon Jun 12 23:24:03 2023 -0500
Merge branch 'danny-avila:main' into openid-client
commit ec628a3044ba963b4e733c72229400074e7c2bc4
Author: bsu3338 <bsu3338@users.noreply.github.com>
Date: Mon Jun 12 23:23:16 2023 -0500
Update envConstants.js
commit 21272221db0f58c244f08335482d45b177d338ab
Author: bsu3338 <bsu3338@users.noreply.github.com>
Date: Mon Jun 12 23:21:59 2023 -0500
Update Registration.spec.tsx
commit d3f2949c0484d5760e7b689501852f86209992a3
Author: bsu3338 <bsu3338@users.noreply.github.com>
Date: Mon Jun 12 23:21:12 2023 -0500
Update Login.spec.tsx
commit f2cf23ddd6708a3bb8d032dde5f1ce300dbe8cad
Author: bsu3338 <bsu3338@users.noreply.github.com>
Date: Mon Jun 12 23:20:15 2023 -0500
Update Registration.tsx
commit 482c346b2a7baf958665c9474223d2557504dee5
Author: bsu3338 <bsu3338@users.noreply.github.com>
Date: Mon Jun 12 23:17:53 2023 -0500
Update Login.tsx
commit 2f017aa5bf4ef91b73fe027fb346132e1a5d8b87
Author: bsu3338 <bsu3338@users.noreply.github.com>
Date: Mon Jun 12 23:14:17 2023 -0500
Update env.d.ts
commit addfd95cf93ef19cae05bab652d634af64313e6a
Author: bsu3338 <bsu3338@users.noreply.github.com>
Date: Mon Jun 12 23:13:16 2023 -0500
Create openidStrategy.js
commit 84c3b5c2f078494d8380f3a02e3ba2d935d8d79f
Author: bsu3338 <bsu3338@users.noreply.github.com>
Date: Mon Jun 12 23:09:02 2023 -0500
Update oauth.js
commit 63225cdf33b7f42005b4a446797acbd91b7ee4a7
Author: bsu3338 <bsu3338@users.noreply.github.com>
Date: Mon Jun 12 23:07:35 2023 -0500
Update index.js
commit 6efe4dafd4359ed1c3139468bf9d43f70bbaf6aa
Author: bsu3338 <bsu3338@users.noreply.github.com>
Date: Mon Jun 12 23:04:55 2023 -0500
Update package.json
commit 201badbbb5a5c8d48f5c4cba3a1349d4cfc7a070
Author: bsu3338 <bsu3338@users.noreply.github.com>
Date: Mon Jun 12 23:03:37 2023 -0500
Update User.js
commit 7d13d5c303465be9b1268e5f6d9bdf7bb8dfb2e4
Author: bsu3338 <bsu3338@users.noreply.github.com>
Date: Mon Jun 12 23:02:29 2023 -0500
Update Dockerfile
commit 2ef7f84ea77f281c3dce61211d9fd841a6424e65
Author: bsu3338 <bsu3338@users.noreply.github.com>
Date: Mon Jun 12 23:00:42 2023 -0500
Update .env.example
* Update openidStrategy.js
* Update .env.example
* Update .env.example
* Update docker-compose.yml
* Update env.d.ts
* Update .env.example
* Update .env.example
* Update config.js
* Update Login.tsx
* Update config.js
* Update Login.tsx
* Update Registration.tsx
* Update docker-compose.yml
* Update openidStrategy.js
* Update docker-compose.yml
* Update config.spec.js
* Update Login.spec.tsx
* Update Registration.spec.tsx
* Update types.ts
* Update .env.example
* Update package-lock.json
* Update openidStrategy.js
* Update openidStrategy.js
* Update config.js
* Update config.js
* Update Login.tsx
* Update Registration.tsx
* Update oauth.js
* Update openidStrategy.js
* Update openidStrategy.js
* Update Registration.tsx
* Update Login.tsx
* Update Login.tsx
* Update Registration.tsx
* Update Registration.tsx
* Update index.js
* Update index.js
* Update .env.example
* Update user_auth_system.md
updated instruction that includes OpenID set up
* Update package.json
* Update package-lock.json
* Update package-lock.json
* Update package-lock.json
* Update package-lock.json
* Update package-lock.json
* Update package-lock.json
* Update package-lock.json
* Update package-lock.json
* Update openidStrategy.js
* Update openidStrategy.js
Lookup user based on openID instead of email. This is because not all AzureAD users may have an email tied to their account
* Update openidStrategy.js
First try to match an email, then try openIdID
* Update openidStrategy.js
* Update openidStrategy.js
Consider a family name or given name is not provided
---------
Co-authored-by: Fuegovic <32828263+fuegovic@users.noreply.github.com>
5.3 KiB
User/Auth System
First Time Setup
In order for the auth system to function properly, there are some environment variables that are needed. Note that this information is also included in the /.env.example file.
In /.env, you will need to set the following variables:
# Change this to a secure string
JWT_SECRET=secret
# Set the expiration delay for the secure cookie with the JWT token
# Delay is in millisecond e.g. 7 days is 1000*60*60*24*7
SESSION_EXPIRY=1000 * 60 * 60 * 24 * 7
DOMAIN_SERVER=http://localhost:3080
DOMAIN_CLIENT=http://localhost:3080
Please Note: If you are wanting this to work in development mode, you will need to create a file called .env.development
in the root directory and set DOMAIN_CLIENT
to http://localhost:3090
or whatever port is provided by vite when runnning npm run frontend-dev
Important: When you run the app for the first time, you need to create a new account by clicking on "Sign up" on the login page. The first account you make will be the admin account. The admin account doesn't have any special features right now, but it might be useful if you want to make an admin dashboard to manage other users later.
⚠️ For the first time, you should use a local account (email and password) to sign up and log in.
OAuth2/Social Login
How to Set Up Google Authentication
To enable Google login, you must create an application in the Google Cloud Console and provide the client ID and client secret in the /.env
file.
- Go to "APIs and Services" in your Google Cloud account and click on "Credentials".
- Click on "Configure consent screen" and select "External" as the user type.
- Add "profile", "email" and "openid" as the scopes for your app. These are the first three checkboxes when you click on "Add or remove scopes".
- Click on "Save and continue" and then "Back to dashboard".
- Click on "Create Credentials" and then "OAuth client ID".
- Select "Web application" as the application type and give it a name.
- Add "http://localhost" "http://localhost:3080" and "http://localhost:3090" to the authorized JavaScript origins.
- Add "http://localhost:3080/oauth/google/callback" to the authorized redirect URIs.
- Click on "Create" and copy your client ID and client secret.
- Paste them into your /.env file.
- Enable the feature in the /.env file
How to Set Up OpenID Authentication with Azure AD
- Go to the Azure Portal and sign in with your account.
- In the search box, type Azure Active Directory and click on it.
- On the left menu, click on App registrations and then on New registration.
- Give your app a name and select Web as the platform type.
- In the Redirect URI field, enter https://fqdn/oauth/openid/callback and click on Register.
- You will see an Overview page with some information about your app. Copy the Application (client) ID and the Directory (tenant) ID and save them somewhere.
- On the left menu, click on Authentication and check the boxes for Access tokens and ID tokens under Implicit grant and hybrid flows.
- On the left menu, click on Certificates & Secrets and then on New client secret. Give your secret a name and an expiration date and click on Add.
- You will see a Value column with your secret. Copy it and save it somewhere. Don't share it with anyone!
- Open the .env file in your project folder and add the following variables with the values you copied:
OPENID_CLIENT_ID=Your Application (client) ID
OPENID_CLIENT_SECRET=Your client secret
OPENID_ISSUER=https://login.microsoftonline.com/Your Directory (tenant ID)/v2.0/
OPENID_SESSION_SECRET=Any random string
OPENID_SCOPE=openid profile email
OPENID_CALLBACK_URL=/oauth/openid/callback
- Save the .env file and you're done! You have successfully set up OpenID authentication with Azure AD for your app.
Email and Password Reset
Most of the code is in place for sending password reset emails, but is not yet feature-complete as I have not setup an email server to test it. Currently, submitting a password reset request will then display a link with the one-time reset token that can then be used to reset the password. Understanding that this is a considerable security hazard, email integration will be included in the next release.
Disable User Registration
To disable or re-enable registration, open up the root .env
file and set ALLOW_REGISTRATION=true
or ALLOW_REGISTRATION=false
depending on if you want registration open or closed.
⚠️Warning
If you previously implemented your own user system using the original scaffolding that was provided, you will no longer see conversations and presets by switching to the new user system. This is because of a design flaw in the scaffolding implementation that was problematic for the inclusion of social login.
For user updating from an older version of the app:
When the first account is registered, the application will automatically migrate any conversations and presets that you created before the user system was implemented to that account. if you use login for the first time with a social login account (eg. Google, facebook, etc.), the conversations and presets that you created before the user system was implemented will NOT be migrated to that account.