- Homepage
- Login with Google
- Login with Azure (Office365)
- Logout
- Node.js
- Docker
- Docker-compose
- Make
All configurations will be done in the backend directory
- Create a
.envfile in the backend directory - Copy content from
.env.distto.env - Fill the
GOOGLE_CLIENT_IDandGOOGLE_CLIENT_SECRETwith your Google OAuth credentials - Fill the
AZURE_CLIENT_IDandAZURE_CLIENT_SECRETandAZURE_TENANT_IDwith your Azure OAuth credentials - Fill the
SESSION_SECRETwith a random string
This is the easiest way to run the application
- Clone the repository
- cd to project directory
- make configuration changes as mentioned above
- Run
docker-compose up --build - Open
http://localhost:3000in your browser
- Clone the repository
- cd to project directory
- Make configuration changes as mentioned above
- Run
docker build -t demo-oauth-app . - Run
docker run -p 3000:3000 demo-oauth-app - Open
http://localhost:3000in your browser
- Clone the repository
- Make configuration changes as mentioned above
- Run
make build - Run
make run - Open
http://localhost:3000in your browser
- Clone the repository
cd /homegit clone https://[email protected]/py/passprt.gitcd passprtgit checkout master - Make configuration changes as mentioned above
- Go to the frontend directory
cd frontend - Run
npm install - Run
npm run build - Go to the root directory
cd .. - Go to the backend directory
cd backend - Run
npm install - Run
npm start - Open
http://localhost:3000in your browser - Add the following to nginx.conf:
location / {
proxy_pass http://localhost:3000;
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection 'upgrade';
proxy_set_header Host $host;
proxy_cache_bypass $http_upgrade;
}
You need to use /users/register endpoint with a POST request and a JSON body like this:
{
"username": "[email protected]",
"password": "password"
}Do not add user to database directly, password is hashed before saving to database.
Use sqlite3 cli to connect to the database and add a new user with the following SQL query:
INSERT INTO user (username, hashed_password, salt, email, providerId, provider) VALUES (?, ?, ?, ?,?,?)'usernameis the email of the userhashed_passwordis the hashed password of the user, can be null for Google and Azure userssaltis the salt of the user, can be null for Google and Azure usersemailis the email of the userproviderIdis the id of the user in the provider (Google or Azure)provideris the provider name (google or azure)
There is two database in backend folder. database.db for as user database, sessions.db is for session storage. You can delete these files to reset the database.
- Go to Google Developer Console
- Create a new project
- Go to
Credentialstab - Create a new OAuth 2.0 Client ID
- Fill the form with your domain and redirect URI (https://example.com/auth/google/callback)
- Copy the
Client IDandClient Secretto the.envfile
- Go to Azure App Registration
- Create a new app registration
- Go to
Certificates & secretstab - Create a new client secret
- Copy the
Client ID,Client SecretandTenant IDto the.envfile
Error: listen EADDRINUSE: address already in use :::3000- This error occurs when the port 3000 is already in use. You can change the port in the
.envfile by changing thePORTvariable.
- This error occurs when the port 3000 is already in use. You can change the port in the
Error: SQLITE_CANTOPEN: unable to open database file- This error occurs when the database file is not found. You can create the database file by running the application or by creating an empty file with the name
database.dbin the backend directory.
- This error occurs when the database file is not found. You can create the database file by running the application or by creating an empty file with the name
Error: SQLITE_CONSTRAINT: UNIQUE constraint failed: user.username- This error occurs when you try to add a user with an existing username. You can change the username or delete the existing user from the database. We are using email addresses as username. You can see that error if you try to connect with the same email address with different providers (Google, Azure, etc.).
TypeError: Invalid value for clientId.The value cannot be empty- This error occurs when the
GOOGLE_CLIENT_IDorAZURE_CLIENT_IDis not set in the.envfile. You need to set theGOOGLE_CLIENT_IDandGOOGLE_CLIENT_SECRETorAZURE_CLIENT_ID,AZURE_CLIENT_SECRETandAZURE_TENANT_IDin the.envfile.
- This error occurs when the