From 18b9796b7aca1a88dd89fe8bd0e833066cdc42f0 Mon Sep 17 00:00:00 2001 From: ebrahimmfadae Date: Thu, 14 Sep 2023 23:41:52 +0330 Subject: [PATCH 1/2] chore: Update README.md --- README.md | 32 +++++++++++++++----------------- package.json | 8 ++++---- 2 files changed, 19 insertions(+), 21 deletions(-) diff --git a/README.md b/README.md index 37f851e..ec19ab4 100644 --- a/README.md +++ b/README.md @@ -21,17 +21,17 @@ ## Article reference -The article associated to this repository is written in 4 parts plus an introduction. +This repository is associated with an article series that provides a step-by-step guide on implementing OIDC ([OpenID Connect 1.0](https://openid.net/specs/openid-connect-core-1_0.html)) with Node.js, TypeScript, and MongoDB: -- Series: [How to Implement OpenID with Node.js & Typescript & MongoDB](https://dev.to/ebrahimmfadae/setup-openid-with-nodejs-and-mongodb-451j) -- Part I: [Develop Simple OpenID Authorization Server with Node.js & Typescript](https://dev.to/ebrahimmfadae/develop-an-openid-server-with-nodejs-typescript-9n1) -- Part II: [Persist OpenID Server Data on MongoDB with Node.js](https://dev.to/ebrahimmfadae/persist-openid-server-data-with-mongodb-5f95) -- Part III: [Add Resource Server Authorization to OpenID with Node.js](https://dev.to/ebrahimmfadae/add-a-resource-server-to-an-openid-provider-noo) -- Part IV: [Set OpenID Security Configs in Node.js](https://dev.to/ebrahimmfadae/openid-security-configuration-4nn8) +- [Series: Implementing OpenID with Node.js, TypeScript, and MongoDB - A Step-by-Step Guide](https://dev.to/ebrahimmfadae/setup-openid-with-nodejs-and-mongodb-451j) +- [Part I: Developing Simple OpenID Authorization Server with Node.js & Typescript](https://dev.to/ebrahimmfadae/develop-an-openid-server-with-nodejs-typescript-9n1) +- [Part II: Persisting OpenID Server Data on MongoDB with Node.js](https://dev.to/ebrahimmfadae/persist-openid-server-data-with-mongodb-5f95) +- [Part III: Adding Resource Server Authorization to OpenID with Node.js](https://dev.to/ebrahimmfadae/add-a-resource-server-to-an-openid-provider-noo) +- [Part IV: Configuring OpenID Security Settings in Node.js](https://dev.to/ebrahimmfadae/openid-security-configuration-4nn8) ## Project requirements -The project is developed and tested in this environment. +The project has been developed and tested in the following environment: ``` $ node -v @@ -47,30 +47,28 @@ $ docker compose version Docker Compose version v2.15.1 ``` -## Run & Stop +## Getting started -Install dependencies +**Install dependencies** Open a terminal and run the following command to install the project dependencies: ``` $ yarn install ``` -_Note: We can move the `yarn install` step to the container, but installing the dependencies inside the container when we have no caching bothers me! Especially in the development phase._ - -Run containers +**Run containers** Start the project containers by running the command: ``` -$ yarn docker-compose:up +$ yarn compose:up ``` You can see the front end by navigating to [http://localhost:3005](http://localhost:3005) with your browser. -Stop containers +**Stop containers** When you're done using the application, stop the containers by running the command: ``` -$ yarn docker-compose:down +$ yarn compose:down ``` -## How to Contribute +## How to contribute -To suggest code change, Open an issue or create a pull request. +If you have any suggestions or want to propose code changes, you can open an issue or create a pull request with your proposed changes. Feel free to make any further adjustments or additions to the README to suit your project's specific requirements and conventions. diff --git a/package.json b/package.json index 60db427..dafd8c1 100644 --- a/package.json +++ b/package.json @@ -1,18 +1,18 @@ { "name": "openid-connect-app", - "version": "2.1.0", + "version": "2.2.0", "description": "", "keywords": [], "license": "MIT", "author": "ebrahimmfadae@gmail.com", "type": "commonjs", "scripts": { - "docker-compose:up": "docker-compose up -d", - "docker-compose:down": "docker-compose down", + "compose:up": "docker compose up -d", + "compose:down": "docker compose down", "start:api": "ts-node api/src", "start:app": "ts-node app/src", "start:oidc": "ts-node oidc/src", - "test": "echo \"Error: no test specified\" && exit 1" + "test": "echo \"Gandalf: You shall !not pass!\" && exit 1" }, "dependencies": { "@koa/cors": "^3.1.0", From e5f63621ae34397243fa952afd4bf4beebc2495f Mon Sep 17 00:00:00 2001 From: ebrahimmfadae Date: Thu, 14 Sep 2023 23:57:47 +0330 Subject: [PATCH 2/2] refactor: Improve envs --- .env | 10 ++++++++-- docker-compose.yml | 4 ++-- 2 files changed, 10 insertions(+), 4 deletions(-) diff --git a/.env b/.env index 1b5df83..a427a64 100644 --- a/.env +++ b/.env @@ -1,2 +1,8 @@ -OIDC_ISSUER=http://oidc -MONGODB_URI=mongodb://mongo/oidc \ No newline at end of file +# Internal envs +INTERNAL_OIDC_ISSUER=http://oidc +MONGODB_URI=mongodb://mongo/oidc + +# Public addresses +PUBLIC_OIDC_ISSUER=http://localhost:3000 +PUBLIC_APP_URL=http://localhost:3005 +PUBLIC_API_URL=http://localhost:3006 \ No newline at end of file diff --git a/docker-compose.yml b/docker-compose.yml index d360a32..1e6a6f7 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -5,7 +5,7 @@ services: working_dir: /app environment: - PORT=80 - - OIDC_ISSUER=$OIDC_ISSUER + - OIDC_ISSUER=$INTERNAL_OIDC_ISSUER - MONGODB_URI=$MONGODB_URI ports: - '3000:80' @@ -17,7 +17,7 @@ services: working_dir: /app environment: - PORT=80 - - OIDC_ISSUER=$OIDC_ISSUER + - OIDC_ISSUER=$INTERNAL_OIDC_ISSUER - CLIENT_ID=api - CLIENT_SECRET=night-wolf ports: