This repository contains a Node.js-based simple single sign-on (SSO) application with OAuth2 authentication. This application enables users to authenticate with a single account through various providers.
Ensure that you have the following installed on your machine:
-
Clone the Repository:
git clone https://github.com/muhannadsalkini/NodeJS-SingleSignOn cd NodeJS-SingleSignOn
-
Set Up Environment Variables: Create a
.env
file in the root of the project and set the following variables:PORT=4000 MONGO_URL=yourMongoUrl JWT_SECRET=YourJWTSecret JWT_EXPIRES_IN=1d
Replace
yourMongoUrl
andYourJWTSecret
with the credentials. -
Install Dependencies:
npm install
-
Start the Application:
npm start
This will start the server at
http://localhost:4000
. -
Access the Application: Open your browser and visit
http://localhost:4000/
. The application should be accessible, and users can initiate the OAuth2 authentication process.
For development, you can use the following command to run the application with nodemon for automatic server restarts:
npm run dev
This uses nodemon to automatically restart the server when changes are detected.
To run the application using Docker, make sure Docker is installed, and then execute the following commands:
-
Set Up Dockerfile: Edit the
Dockerfile
file in the root of the project and set the variables. -
Build The Image and Run:
docker build -t oauth2-sso-app . docker run -p 4000:4000 -d oauth2-sso-app
This will build a Docker image and run the container on port 4000.
Feel free to customize the application or Docker settings based on your requirements. Happy coding!