From b7e981d1ba9987d0803da1577c0f7a686d8f5b1e Mon Sep 17 00:00:00 2001 From: Sylvain Briat Date: Fri, 10 Nov 2023 16:17:08 +0100 Subject: [PATCH] add auth default configuration --- .env.dist | 4 + package-lock.json | 215 +++++++++--------- package.json | 30 +-- src/app.module.ts | 2 + src/config/auth.config.ts | 10 + .../configurations-manager.service.ts | 5 + .../configurations-manager.service.spec.ts | 6 +- 7 files changed, 149 insertions(+), 123 deletions(-) create mode 100644 src/config/auth.config.ts diff --git a/.env.dist b/.env.dist index 05f5fe0..4983b28 100644 --- a/.env.dist +++ b/.env.dist @@ -15,6 +15,10 @@ REDIS_PORT=6379 # DEFAULT CONFIGURATION +# AUTH +# encryption algorithm : BCRYPT / ARGON2 / ARGON2I / ARGON2D / ARGON2ID +ENCRYPTION_ALGORITHM=BCRYPT + # CARPOOL # default carpool departure time margin (in seconds) DEPARTURE_TIME_MARGIN=900 diff --git a/package-lock.json b/package-lock.json index a667c9f..d1cfb9f 100644 --- a/package-lock.json +++ b/package-lock.json @@ -11,17 +11,17 @@ "dependencies": { "@grpc/grpc-js": "^1.9.9", "@grpc/proto-loader": "^0.7.10", - "@mobicoop/configuration-module": "^7.2.1", - "@mobicoop/ddd-library": "^2.1.1", + "@mobicoop/configuration-module": "^7.3.0", + "@mobicoop/ddd-library": "^2.3.0", "@mobicoop/health-module": "^2.3.1", "@mobicoop/message-broker-module": "^2.1.1", - "@nestjs/common": "^10.2.7", + "@nestjs/common": "^10.2.8", "@nestjs/config": "^3.1.1", - "@nestjs/core": "^10.2.7", + "@nestjs/core": "^10.2.8", "@nestjs/cqrs": "^10.2.6", - "@nestjs/event-emitter": "^2.0.2", - "@nestjs/microservices": "^10.2.7", - "@nestjs/platform-express": "^10.2.7", + "@nestjs/event-emitter": "^2.0.3", + "@nestjs/microservices": "^10.2.8", + "@nestjs/platform-express": "^10.2.8", "@nestjs/terminus": "^10.1.1", "class-transformer": "^0.5.1", "class-validator": "^0.14.0", @@ -31,15 +31,15 @@ "devDependencies": { "@nestjs/cli": "^10.2.1", "@nestjs/schematics": "^10.0.3", - "@nestjs/testing": "^10.2.7", - "@types/express": "^4.17.20", - "@types/jest": "29.5.7", - "@types/node": "^20.8.10", - "@types/supertest": "^2.0.15", - "@typescript-eslint/eslint-plugin": "^6.9.1", - "@typescript-eslint/parser": "^6.9.1", + "@nestjs/testing": "^10.2.8", + "@types/express": "^4.17.21", + "@types/jest": "29.5.8", + "@types/node": "^20.9.0", + "@types/supertest": "^2.0.16", + "@typescript-eslint/eslint-plugin": "^6.10.0", + "@typescript-eslint/parser": "^6.10.0", "dotenv-cli": "^7.3.0", - "eslint": "^8.52.0", + "eslint": "^8.53.0", "eslint-config-prettier": "^9.0.0", "eslint-plugin-prettier": "^5.0.1", "jest": "29.7.0", @@ -887,9 +887,9 @@ } }, "node_modules/@eslint/eslintrc": { - "version": "2.1.2", - "resolved": "https://registry.npmjs.org/@eslint/eslintrc/-/eslintrc-2.1.2.tgz", - "integrity": "sha512-+wvgpDsrB1YqAMdEUCcnTlpfVBH7Vqn6A/NT3D8WVXFIaKMlErPIZT3oCIAVCOtarRpMtelZLqJeU3t7WY6X6g==", + "version": "2.1.3", + "resolved": "https://registry.npmjs.org/@eslint/eslintrc/-/eslintrc-2.1.3.tgz", + "integrity": "sha512-yZzuIG+jnVu6hNSzFEN07e8BxF3uAzYtQb6uDkaYZLo6oYZDCq454c5kB8zxnzfCYyP4MIuyBn10L0DqwujTmA==", "dev": true, "dependencies": { "ajv": "^6.12.4", @@ -932,9 +932,9 @@ "dev": true }, "node_modules/@eslint/js": { - "version": "8.52.0", - "resolved": "https://registry.npmjs.org/@eslint/js/-/js-8.52.0.tgz", - "integrity": "sha512-mjZVbpaeMZludF2fsWLD0Z9gCref1Tk4i9+wddjRvpUNqqcndPkBD09N/Mapey0b3jaXbLm2kICwFv2E64QinA==", + "version": "8.53.0", + "resolved": "https://registry.npmjs.org/@eslint/js/-/js-8.53.0.tgz", + "integrity": "sha512-Kn7K8dx/5U6+cT1yEhpX1w4PCSg0M+XyRILPgvwcEBjerFWCwQj5sbr3/VmxqV0JGHCBCzyd6LxypEuehypY1w==", "dev": true, "engines": { "node": "^12.22.0 || ^14.17.0 || >=16.0.0" @@ -1668,9 +1668,9 @@ } }, "node_modules/@mobicoop/configuration-module": { - "version": "7.2.1", - "resolved": "https://registry.npmjs.org/@mobicoop/configuration-module/-/configuration-module-7.2.1.tgz", - "integrity": "sha512-PGY80+uN33yKSxvqcR2CPlAbhEY67xYfVDqkphIoqGb5qAwioVZH5a8InJw4Zg0Q5bx0ZQG5pcK0jha7kSxqzQ==", + "version": "7.3.0", + "resolved": "https://registry.npmjs.org/@mobicoop/configuration-module/-/configuration-module-7.3.0.tgz", + "integrity": "sha512-11Pezs1O+NcOL9aTmMmwsj9BQRqygdk44ubS2SXnZmi9sZUAFwet/lFe77YgKcOAhTeRc5GT9KkebA7r7EmpzQ==", "dependencies": { "@songkeys/nestjs-redis": "^10.0.0", "ioredis": "^5.3.2" @@ -1680,12 +1680,13 @@ } }, "node_modules/@mobicoop/ddd-library": { - "version": "2.1.1", - "resolved": "https://registry.npmjs.org/@mobicoop/ddd-library/-/ddd-library-2.1.1.tgz", - "integrity": "sha512-Up9d0Ad6aM8Eoc7u3cTMMhQ6uP16thvXLy7h8OL3pfM4QPUNdSygxFjJhwg+wUyjGRH1bsb3xuWp8+GsOVI7+g==", + "version": "2.3.0", + "resolved": "https://registry.npmjs.org/@mobicoop/ddd-library/-/ddd-library-2.3.0.tgz", + "integrity": "sha512-Hgdno1b/kqcfodUaCcriicsfznVnd1MIugyCNXxFt2zN3oc5wTNQHNxx/E7RzAJDJr6xvuCleJEf7oExAroo5w==", "dependencies": { "@nestjs/event-emitter": "^2.0.2", "@nestjs/microservices": "^10.2.7", + "@nestjs/swagger": "^7.1.14", "class-transformer": "^0.5.1", "class-validator": "^0.14.0", "uuid": "^9.0.1" @@ -1856,9 +1857,9 @@ } }, "node_modules/@nestjs/common": { - "version": "10.2.7", - "resolved": "https://registry.npmjs.org/@nestjs/common/-/common-10.2.7.tgz", - "integrity": "sha512-cUtCRXiUstDmh4bSBhVbq4cI439Gngp4LgLGLBmd5dqFQodfXKnSD441ldYfFiLz4rbUsnoMJz/8ZjuIEI+B7A==", + "version": "10.2.8", + "resolved": "https://registry.npmjs.org/@nestjs/common/-/common-10.2.8.tgz", + "integrity": "sha512-rmpwcdvq2IWMmsUVP8rsdKub6uDWk7dwCYo0aif50JTwcvcxzaP3iKVFKoSgvp0RKYu8h15+/AEOfaInmPpl0Q==", "dependencies": { "iterare": "1.2.1", "tslib": "2.6.2", @@ -1907,9 +1908,9 @@ } }, "node_modules/@nestjs/core": { - "version": "10.2.7", - "resolved": "https://registry.npmjs.org/@nestjs/core/-/core-10.2.7.tgz", - "integrity": "sha512-5GSu53QUUcwX17sNmlJPa1I0wIeAZOKbedyVuQx0ZAwWVa9g0wJBbsNP+R4EJ+j5Dkdzt/8xkiZvnKt8RFRR8g==", + "version": "10.2.8", + "resolved": "https://registry.npmjs.org/@nestjs/core/-/core-10.2.8.tgz", + "integrity": "sha512-9+MZ2s8ixfY9Bl/M9ofChiyYymcwdK9ZWNH4GDMF7Am7XRAQ1oqde6MYGG05rhQwiVXuTwaYLlXciJKfsrg5qg==", "hasInstallScript": true, "dependencies": { "@nuxtjs/opencollective": "0.3.2", @@ -1966,9 +1967,9 @@ } }, "node_modules/@nestjs/event-emitter": { - "version": "2.0.2", - "resolved": "https://registry.npmjs.org/@nestjs/event-emitter/-/event-emitter-2.0.2.tgz", - "integrity": "sha512-qxJE+6yKSW/ReBzT1jKES2m3zZh6gmgunDtIvCl66G8i9zZ4TQciwoq01MigqnruTgXjH/AzNPqtr6ZUt207mg==", + "version": "2.0.3", + "resolved": "https://registry.npmjs.org/@nestjs/event-emitter/-/event-emitter-2.0.3.tgz", + "integrity": "sha512-Pt7KAERrgK0OjvarSI3wfVhwZ8X1iLq1lXuodyRe+Zx3aLLP7fraFUHirASbFkB6KIQ1Zj+gZ1g8a9eu4GfFhw==", "dependencies": { "eventemitter2": "6.4.9" }, @@ -1998,9 +1999,9 @@ } }, "node_modules/@nestjs/microservices": { - "version": "10.2.7", - "resolved": "https://registry.npmjs.org/@nestjs/microservices/-/microservices-10.2.7.tgz", - "integrity": "sha512-ggpng1yRuugPufn+OKeHV6Dcw3TWI7lmOvXkyYRwatVHQMvb3MlPpbzsA5PfUlg5DsjPGEWRbkIWN7OFb8OTyw==", + "version": "10.2.8", + "resolved": "https://registry.npmjs.org/@nestjs/microservices/-/microservices-10.2.8.tgz", + "integrity": "sha512-zfrD7hgN3ygrjicASQUVdnsh3V7vTmhZfttZ7ZNjihwqEoweJFgWmqKkpAfbCrIP7z19gT4JQ8hO4W0Alwdt0w==", "dependencies": { "iterare": "1.2.1", "tslib": "2.6.2" @@ -2055,9 +2056,9 @@ } }, "node_modules/@nestjs/platform-express": { - "version": "10.2.7", - "resolved": "https://registry.npmjs.org/@nestjs/platform-express/-/platform-express-10.2.7.tgz", - "integrity": "sha512-p+kp6aJtkgAdVpUrCVmM6MKtOvjsbt7QofBiZMidjYesZkMeG5gZ1D2SK8XzvQ8VXHJfFgEdY2xcKGB+wJLOYQ==", + "version": "10.2.8", + "resolved": "https://registry.npmjs.org/@nestjs/platform-express/-/platform-express-10.2.8.tgz", + "integrity": "sha512-WoSSVtwIRc5AdGMHWVzWZK4JZLT0f4o2xW8P9gQvcX+omL8W1kXCfY8GQYXNBG84XmBNYH8r0FtC8oMe/lH5NQ==", "dependencies": { "body-parser": "1.20.2", "cors": "2.8.5", @@ -2191,9 +2192,9 @@ } }, "node_modules/@nestjs/testing": { - "version": "10.2.7", - "resolved": "https://registry.npmjs.org/@nestjs/testing/-/testing-10.2.7.tgz", - "integrity": "sha512-d2SIqiJIf/7NSILeNNWSdRvTTpHSouGgisGHwf5PVDC7z4/yXZw/wPO9eJhegnxFlqk6n2LW4QBTmMzbqjAfHA==", + "version": "10.2.8", + "resolved": "https://registry.npmjs.org/@nestjs/testing/-/testing-10.2.8.tgz", + "integrity": "sha512-9Kj5IQhM67/nj/MT6Wi2OmWr5YQnCMptwKVFrX1TDaikpY12196v7frk0jVjdT7wms7rV07GZle9I2z0aSjqtQ==", "dev": true, "dependencies": { "tslib": "2.6.2" @@ -2522,9 +2523,9 @@ "dev": true }, "node_modules/@types/express": { - "version": "4.17.20", - "resolved": "https://registry.npmjs.org/@types/express/-/express-4.17.20.tgz", - "integrity": "sha512-rOaqlkgEvOW495xErXMsmyX3WKBInbhG5eqojXYi3cGUaLoRDlXa5d52fkfWZT963AZ3v2eZ4MbKE6WpDAGVsw==", + "version": "4.17.21", + "resolved": "https://registry.npmjs.org/@types/express/-/express-4.17.21.tgz", + "integrity": "sha512-ejlPM315qwLpaQlQDTjPdsUFSc6ZsP4AN6AlWnogPjQ7CVi7PYF3YVz+CY3jE2pwYf7E/7HlDAN0rV2GxTG0HQ==", "dev": true, "dependencies": { "@types/body-parser": "*", @@ -2585,9 +2586,9 @@ } }, "node_modules/@types/jest": { - "version": "29.5.7", - "resolved": "https://registry.npmjs.org/@types/jest/-/jest-29.5.7.tgz", - "integrity": "sha512-HLyetab6KVPSiF+7pFcUyMeLsx25LDNDemw9mGsJBkai/oouwrjTycocSDYopMEwFhN2Y4s9oPyOCZNofgSt2g==", + "version": "29.5.8", + "resolved": "https://registry.npmjs.org/@types/jest/-/jest-29.5.8.tgz", + "integrity": "sha512-fXEFTxMV2Co8ZF5aYFJv+YeA08RTYJfhtN5c9JSv/mFEMe+xxjufCb+PHL+bJcMs/ebPUsBu+UNTEz+ydXrR6g==", "dev": true, "dependencies": { "expect": "^29.0.0", @@ -2607,9 +2608,9 @@ "dev": true }, "node_modules/@types/node": { - "version": "20.8.10", - "resolved": "https://registry.npmjs.org/@types/node/-/node-20.8.10.tgz", - "integrity": "sha512-TlgT8JntpcbmKUFzjhsyhGfP2fsiz1Mv56im6enJ905xG1DAYesxJaeSbGqQmAw8OWPdhyJGhGSQGKRNJ45u9w==", + "version": "20.9.0", + "resolved": "https://registry.npmjs.org/@types/node/-/node-20.9.0.tgz", + "integrity": "sha512-nekiGu2NDb1BcVofVcEKMIwzlx4NjHlcjhoxxKBNLtz15Y1z7MYf549DFvkHSId02Ax6kGwWntIBPC3l/JZcmw==", "dependencies": { "undici-types": "~5.26.4" } @@ -2627,9 +2628,9 @@ "dev": true }, "node_modules/@types/semver": { - "version": "7.5.4", - "resolved": "https://registry.npmjs.org/@types/semver/-/semver-7.5.4.tgz", - "integrity": "sha512-MMzuxN3GdFwskAnb6fz0orFvhfqi752yjaXylr0Rp4oDg5H0Zn1IuyRhDVvYOwAXoJirx2xuS16I3WjxnAIHiQ==", + "version": "7.5.5", + "resolved": "https://registry.npmjs.org/@types/semver/-/semver-7.5.5.tgz", + "integrity": "sha512-+d+WYC1BxJ6yVOgUgzK8gWvp5qF8ssV5r4nsDcZWKRWcDQLQ619tvWAxJQYGgBrO1MnLJC7a5GtiYsAoQ47dJg==", "dev": true }, "node_modules/@types/send": { @@ -2670,9 +2671,9 @@ } }, "node_modules/@types/supertest": { - "version": "2.0.15", - "resolved": "https://registry.npmjs.org/@types/supertest/-/supertest-2.0.15.tgz", - "integrity": "sha512-jUCZZ/TMcpGzoSaed9Gjr8HCf3HehExdibyw3OHHEL1als1KmyzcOZZH4MjbObI8TkWsEr7bc7gsW0WTDni+qQ==", + "version": "2.0.16", + "resolved": "https://registry.npmjs.org/@types/supertest/-/supertest-2.0.16.tgz", + "integrity": "sha512-6c2ogktZ06tr2ENoZivgm7YnprnhYE4ZoXGMY+oA7IuAf17M8FWvujXZGmxLv8y0PTyts4x5A+erSwVUFA8XSg==", "dev": true, "dependencies": { "@types/superagent": "*" @@ -2699,16 +2700,16 @@ "dev": true }, "node_modules/@typescript-eslint/eslint-plugin": { - "version": "6.9.1", - "resolved": "https://registry.npmjs.org/@typescript-eslint/eslint-plugin/-/eslint-plugin-6.9.1.tgz", - "integrity": "sha512-w0tiiRc9I4S5XSXXrMHOWgHgxbrBn1Ro+PmiYhSg2ZVdxrAJtQgzU5o2m1BfP6UOn7Vxcc6152vFjQfmZR4xEg==", + "version": "6.10.0", + "resolved": "https://registry.npmjs.org/@typescript-eslint/eslint-plugin/-/eslint-plugin-6.10.0.tgz", + "integrity": "sha512-uoLj4g2OTL8rfUQVx2AFO1hp/zja1wABJq77P6IclQs6I/m9GLrm7jCdgzZkvWdDCQf1uEvoa8s8CupsgWQgVg==", "dev": true, "dependencies": { "@eslint-community/regexpp": "^4.5.1", - "@typescript-eslint/scope-manager": "6.9.1", - "@typescript-eslint/type-utils": "6.9.1", - "@typescript-eslint/utils": "6.9.1", - "@typescript-eslint/visitor-keys": "6.9.1", + "@typescript-eslint/scope-manager": "6.10.0", + "@typescript-eslint/type-utils": "6.10.0", + "@typescript-eslint/utils": "6.10.0", + "@typescript-eslint/visitor-keys": "6.10.0", "debug": "^4.3.4", "graphemer": "^1.4.0", "ignore": "^5.2.4", @@ -2734,15 +2735,15 @@ } }, "node_modules/@typescript-eslint/parser": { - "version": "6.9.1", - "resolved": "https://registry.npmjs.org/@typescript-eslint/parser/-/parser-6.9.1.tgz", - "integrity": "sha512-C7AK2wn43GSaCUZ9do6Ksgi2g3mwFkMO3Cis96kzmgudoVaKyt62yNzJOktP0HDLb/iO2O0n2lBOzJgr6Q/cyg==", + "version": "6.10.0", + "resolved": "https://registry.npmjs.org/@typescript-eslint/parser/-/parser-6.10.0.tgz", + "integrity": "sha512-+sZwIj+s+io9ozSxIWbNB5873OSdfeBEH/FR0re14WLI6BaKuSOnnwCJ2foUiu8uXf4dRp1UqHP0vrZ1zXGrog==", "dev": true, "dependencies": { - "@typescript-eslint/scope-manager": "6.9.1", - "@typescript-eslint/types": "6.9.1", - "@typescript-eslint/typescript-estree": "6.9.1", - "@typescript-eslint/visitor-keys": "6.9.1", + "@typescript-eslint/scope-manager": "6.10.0", + "@typescript-eslint/types": "6.10.0", + "@typescript-eslint/typescript-estree": "6.10.0", + "@typescript-eslint/visitor-keys": "6.10.0", "debug": "^4.3.4" }, "engines": { @@ -2762,13 +2763,13 @@ } }, "node_modules/@typescript-eslint/scope-manager": { - "version": "6.9.1", - "resolved": "https://registry.npmjs.org/@typescript-eslint/scope-manager/-/scope-manager-6.9.1.tgz", - "integrity": "sha512-38IxvKB6NAne3g/+MyXMs2Cda/Sz+CEpmm+KLGEM8hx/CvnSRuw51i8ukfwB/B/sESdeTGet1NH1Wj7I0YXswg==", + "version": "6.10.0", + "resolved": "https://registry.npmjs.org/@typescript-eslint/scope-manager/-/scope-manager-6.10.0.tgz", + "integrity": "sha512-TN/plV7dzqqC2iPNf1KrxozDgZs53Gfgg5ZHyw8erd6jd5Ta/JIEcdCheXFt9b1NYb93a1wmIIVW/2gLkombDg==", "dev": true, "dependencies": { - "@typescript-eslint/types": "6.9.1", - "@typescript-eslint/visitor-keys": "6.9.1" + "@typescript-eslint/types": "6.10.0", + "@typescript-eslint/visitor-keys": "6.10.0" }, "engines": { "node": "^16.0.0 || >=18.0.0" @@ -2779,13 +2780,13 @@ } }, "node_modules/@typescript-eslint/type-utils": { - "version": "6.9.1", - "resolved": "https://registry.npmjs.org/@typescript-eslint/type-utils/-/type-utils-6.9.1.tgz", - "integrity": "sha512-eh2oHaUKCK58qIeYp19F5V5TbpM52680sB4zNSz29VBQPTWIlE/hCj5P5B1AChxECe/fmZlspAWFuRniep1Skg==", + "version": "6.10.0", + "resolved": "https://registry.npmjs.org/@typescript-eslint/type-utils/-/type-utils-6.10.0.tgz", + "integrity": "sha512-wYpPs3hgTFblMYwbYWPT3eZtaDOjbLyIYuqpwuLBBqhLiuvJ+9sEp2gNRJEtR5N/c9G1uTtQQL5AhV0fEPJYcg==", "dev": true, "dependencies": { - "@typescript-eslint/typescript-estree": "6.9.1", - "@typescript-eslint/utils": "6.9.1", + "@typescript-eslint/typescript-estree": "6.10.0", + "@typescript-eslint/utils": "6.10.0", "debug": "^4.3.4", "ts-api-utils": "^1.0.1" }, @@ -2806,9 +2807,9 @@ } }, "node_modules/@typescript-eslint/types": { - "version": "6.9.1", - "resolved": "https://registry.npmjs.org/@typescript-eslint/types/-/types-6.9.1.tgz", - "integrity": "sha512-BUGslGOb14zUHOUmDB2FfT6SI1CcZEJYfF3qFwBeUrU6srJfzANonwRYHDpLBuzbq3HaoF2XL2hcr01c8f8OaQ==", + "version": "6.10.0", + "resolved": "https://registry.npmjs.org/@typescript-eslint/types/-/types-6.10.0.tgz", + "integrity": "sha512-36Fq1PWh9dusgo3vH7qmQAj5/AZqARky1Wi6WpINxB6SkQdY5vQoT2/7rW7uBIsPDcvvGCLi4r10p0OJ7ITAeg==", "dev": true, "engines": { "node": "^16.0.0 || >=18.0.0" @@ -2819,13 +2820,13 @@ } }, "node_modules/@typescript-eslint/typescript-estree": { - "version": "6.9.1", - "resolved": "https://registry.npmjs.org/@typescript-eslint/typescript-estree/-/typescript-estree-6.9.1.tgz", - "integrity": "sha512-U+mUylTHfcqeO7mLWVQ5W/tMLXqVpRv61wm9ZtfE5egz7gtnmqVIw9ryh0mgIlkKk9rZLY3UHygsBSdB9/ftyw==", + "version": "6.10.0", + "resolved": "https://registry.npmjs.org/@typescript-eslint/typescript-estree/-/typescript-estree-6.10.0.tgz", + "integrity": "sha512-ek0Eyuy6P15LJVeghbWhSrBCj/vJpPXXR+EpaRZqou7achUWL8IdYnMSC5WHAeTWswYQuP2hAZgij/bC9fanBg==", "dev": true, "dependencies": { - "@typescript-eslint/types": "6.9.1", - "@typescript-eslint/visitor-keys": "6.9.1", + "@typescript-eslint/types": "6.10.0", + "@typescript-eslint/visitor-keys": "6.10.0", "debug": "^4.3.4", "globby": "^11.1.0", "is-glob": "^4.0.3", @@ -2846,17 +2847,17 @@ } }, "node_modules/@typescript-eslint/utils": { - "version": "6.9.1", - "resolved": "https://registry.npmjs.org/@typescript-eslint/utils/-/utils-6.9.1.tgz", - "integrity": "sha512-L1T0A5nFdQrMVunpZgzqPL6y2wVreSyHhKGZryS6jrEN7bD9NplVAyMryUhXsQ4TWLnZmxc2ekar/lSGIlprCA==", + "version": "6.10.0", + "resolved": "https://registry.npmjs.org/@typescript-eslint/utils/-/utils-6.10.0.tgz", + "integrity": "sha512-v+pJ1/RcVyRc0o4wAGux9x42RHmAjIGzPRo538Z8M1tVx6HOnoQBCX/NoadHQlZeC+QO2yr4nNSFWOoraZCAyg==", "dev": true, "dependencies": { "@eslint-community/eslint-utils": "^4.4.0", "@types/json-schema": "^7.0.12", "@types/semver": "^7.5.0", - "@typescript-eslint/scope-manager": "6.9.1", - "@typescript-eslint/types": "6.9.1", - "@typescript-eslint/typescript-estree": "6.9.1", + "@typescript-eslint/scope-manager": "6.10.0", + "@typescript-eslint/types": "6.10.0", + "@typescript-eslint/typescript-estree": "6.10.0", "semver": "^7.5.4" }, "engines": { @@ -2871,12 +2872,12 @@ } }, "node_modules/@typescript-eslint/visitor-keys": { - "version": "6.9.1", - "resolved": "https://registry.npmjs.org/@typescript-eslint/visitor-keys/-/visitor-keys-6.9.1.tgz", - "integrity": "sha512-MUaPUe/QRLEffARsmNfmpghuQkW436DvESW+h+M52w0coICHRfD6Np9/K6PdACwnrq1HmuLl+cSPZaJmeVPkSw==", + "version": "6.10.0", + "resolved": "https://registry.npmjs.org/@typescript-eslint/visitor-keys/-/visitor-keys-6.10.0.tgz", + "integrity": "sha512-xMGluxQIEtOM7bqFCo+rCMh5fqI+ZxV5RUUOa29iVPz1OgCZrtc7rFnz5cLUazlkPKYqX+75iuDq7m0HQ48nCg==", "dev": true, "dependencies": { - "@typescript-eslint/types": "6.9.1", + "@typescript-eslint/types": "6.10.0", "eslint-visitor-keys": "^3.4.1" }, "engines": { @@ -4744,15 +4745,15 @@ } }, "node_modules/eslint": { - "version": "8.52.0", - "resolved": "https://registry.npmjs.org/eslint/-/eslint-8.52.0.tgz", - "integrity": "sha512-zh/JHnaixqHZsolRB/w9/02akBk9EPrOs9JwcTP2ek7yL5bVvXuRariiaAjjoJ5DvuwQ1WAE/HsMz+w17YgBCg==", + "version": "8.53.0", + "resolved": "https://registry.npmjs.org/eslint/-/eslint-8.53.0.tgz", + "integrity": "sha512-N4VuiPjXDUa4xVeV/GC/RV3hQW9Nw+Y463lkWaKKXKYMvmRiRDAtfpuPFLN+E1/6ZhyR8J2ig+eVREnYgUsiag==", "dev": true, "dependencies": { "@eslint-community/eslint-utils": "^4.2.0", "@eslint-community/regexpp": "^4.6.1", - "@eslint/eslintrc": "^2.1.2", - "@eslint/js": "8.52.0", + "@eslint/eslintrc": "^2.1.3", + "@eslint/js": "8.53.0", "@humanwhocodes/config-array": "^0.11.13", "@humanwhocodes/module-importer": "^1.0.1", "@nodelib/fs.walk": "^1.2.8", diff --git a/package.json b/package.json index 0c7863f..2d03e3c 100644 --- a/package.json +++ b/package.json @@ -26,17 +26,17 @@ "dependencies": { "@grpc/grpc-js": "^1.9.9", "@grpc/proto-loader": "^0.7.10", - "@mobicoop/configuration-module": "^7.2.1", - "@mobicoop/ddd-library": "^2.1.1", + "@mobicoop/configuration-module": "^7.3.0", + "@mobicoop/ddd-library": "^2.3.0", "@mobicoop/health-module": "^2.3.1", "@mobicoop/message-broker-module": "^2.1.1", - "@nestjs/common": "^10.2.7", + "@nestjs/common": "^10.2.8", "@nestjs/config": "^3.1.1", - "@nestjs/core": "^10.2.7", + "@nestjs/core": "^10.2.8", "@nestjs/cqrs": "^10.2.6", - "@nestjs/event-emitter": "^2.0.2", - "@nestjs/microservices": "^10.2.7", - "@nestjs/platform-express": "^10.2.7", + "@nestjs/event-emitter": "^2.0.3", + "@nestjs/microservices": "^10.2.8", + "@nestjs/platform-express": "^10.2.8", "@nestjs/terminus": "^10.1.1", "class-transformer": "^0.5.1", "class-validator": "^0.14.0", @@ -46,15 +46,15 @@ "devDependencies": { "@nestjs/cli": "^10.2.1", "@nestjs/schematics": "^10.0.3", - "@nestjs/testing": "^10.2.7", - "@types/express": "^4.17.20", - "@types/jest": "29.5.7", - "@types/node": "^20.8.10", - "@types/supertest": "^2.0.15", - "@typescript-eslint/eslint-plugin": "^6.9.1", - "@typescript-eslint/parser": "^6.9.1", + "@nestjs/testing": "^10.2.8", + "@types/express": "^4.17.21", + "@types/jest": "29.5.8", + "@types/node": "^20.9.0", + "@types/supertest": "^2.0.16", + "@typescript-eslint/eslint-plugin": "^6.10.0", + "@typescript-eslint/parser": "^6.10.0", "dotenv-cli": "^7.3.0", - "eslint": "^8.52.0", + "eslint": "^8.53.0", "eslint-config-prettier": "^9.0.0", "eslint-plugin-prettier": "^5.0.1", "jest": "29.7.0", diff --git a/src/app.module.ts b/src/app.module.ts index 34984eb..d9fa881 100644 --- a/src/app.module.ts +++ b/src/app.module.ts @@ -19,12 +19,14 @@ import redisConfig from './config/redis.config'; import { Transport } from '@nestjs/microservices'; import matchConfig from './config/match.config'; import geographyConfig from './config/geography.config'; +import authConfig from './config/auth.config'; @Module({ imports: [ ConfigModule.forRoot({ isGlobal: true, load: [ + authConfig, brokerConfig, carpoolConfig, geographyConfig, diff --git a/src/config/auth.config.ts b/src/config/auth.config.ts new file mode 100644 index 0000000..bee00b0 --- /dev/null +++ b/src/config/auth.config.ts @@ -0,0 +1,10 @@ +import { registerAs } from '@nestjs/config'; +import { Config } from './config'; + +export interface AuthConfig extends Config { + encryptionAlgorithm: string; +} + +export default registerAs('match', () => ({ + encryptionAlgorithm: process.env.ENCRYPTION_ALGORITHM ?? 'BCRYPT', +})); diff --git a/src/modules/configuration/core/application/services/configurations-manager.service.ts b/src/modules/configuration/core/application/services/configurations-manager.service.ts index 79dab75..646826c 100644 --- a/src/modules/configuration/core/application/services/configurations-manager.service.ts +++ b/src/modules/configuration/core/application/services/configurations-manager.service.ts @@ -7,6 +7,7 @@ import { import { NotFoundException } from '@mobicoop/ddd-library'; import { Injectable } from '@nestjs/common'; import { ConfigService } from '@nestjs/config'; +import { AuthConfig } from '@src/config/auth.config'; import { CarpoolConfig } from '@src/config/carpool.config'; import { Config } from '@src/config/config'; import { GeographyConfig } from '@src/config/geography.config'; @@ -19,6 +20,10 @@ export class ConfigurationsManagerService { list = (): Config[] => { return [ + { + ...(this.configService.get('auth') as AuthConfig), + domain: ConfigurationDomain.AUTH, + }, { ...(this.configService.get('carpool') as CarpoolConfig), domain: ConfigurationDomain.CARPOOL, diff --git a/src/modules/configuration/tests/unit/core/configurations-manager.service.spec.ts b/src/modules/configuration/tests/unit/core/configurations-manager.service.spec.ts index 9ac9513..0f75bff 100644 --- a/src/modules/configuration/tests/unit/core/configurations-manager.service.spec.ts +++ b/src/modules/configuration/tests/unit/core/configurations-manager.service.spec.ts @@ -12,6 +12,10 @@ import { Config } from '@src/config/config'; const mockConfigService = { get: jest.fn().mockImplementation((domain: string) => { switch (domain) { + case 'auth': + return { + encryptionAlgorithm: 'BCRYPT', + }; case 'carpool': return { departureTimeMargin: 900, @@ -69,7 +73,7 @@ describe('Configurations Manager Service', () => { it('should return the list of configuration elements', () => { const list: Config[] = configurationsManagerService.list(); - expect(list).toHaveLength(4); + expect(list).toHaveLength(5); }); describe('identifierType', () => {