From 571fb53dc0ef24ee95d32cc368670c55ee1c2582 Mon Sep 17 00:00:00 2001 From: palindaa Date: Mon, 4 Sep 2023 13:20:11 +0530 Subject: [PATCH 1/6] Update Dev email config --- backend/services/.env.dev | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/backend/services/.env.dev b/backend/services/.env.dev index b00feff20..57f80e468 100644 --- a/backend/services/.env.dev +++ b/backend/services/.env.dev @@ -11,7 +11,7 @@ LEDGER_TYPE=QLDB FILE_SERVICE=S3 LOCATION_SERVICE=MAPBOX ASYNC_OPERATIONS_TYPE=Queue -DISABLE_LOW_PRIORITY_EMAIL=true +DISABLE_LOW_PRIORITY_EMAIL=false ASYNC_QUEUE_NAME=https://sqs.us-east-1.amazonaws.com/302213478610/AsyncQueuedev.fifo DOMAIN_MAP=false EXPIRES_IN=7200 From 74af3ff2582f3f536b923c70cbf09f550a51179c Mon Sep 17 00:00:00 2001 From: palindaa Date: Mon, 4 Sep 2023 13:28:33 +0530 Subject: [PATCH 2/6] update CountryX --- .../workflows/frontend-deployment-prod.yml | 4 +-- backend/services/.env.prod | 3 +- web/public/Assets/i18n/homepage/en.json | 2 +- web/src/Pages/CookiePolicy/cookiePolicy.tsx | 8 ++--- web/src/Pages/PrivacyPolicy/privacyPolicy.tsx | 33 ++++++++++--------- 5 files changed, 27 insertions(+), 23 deletions(-) diff --git a/.github/workflows/frontend-deployment-prod.yml b/.github/workflows/frontend-deployment-prod.yml index d2d3b7dbb..bc311be27 100644 --- a/.github/workflows/frontend-deployment-prod.yml +++ b/.github/workflows/frontend-deployment-prod.yml @@ -11,8 +11,8 @@ jobs: runs-on: ubuntu-latest env: REACT_APP_BACKEND: https://api.carbreg.org - COUNTRY_NAME: 'CountryX' - COUNTRY_FLAG_URL: 'https://carbon-common-prod.s3.amazonaws.com/flag.png' + REACT_APP_COUNTRY_NAME: 'UNDP Digital Public Good National' + REACT_APP_COUNTRY_FLAG_URL: 'https://carbon-common-prod.s3.amazonaws.com/flag.png' COUNTRY_CODE: 'NG' REACT_APP_MAPBOXGL_ACCESS_TOKEN: ${{ secrets.MAPBOXGL_ACCESS_TOKEN }} REACT_APP_MAP_TYPE : "Mapbox" diff --git a/backend/services/.env.prod b/backend/services/.env.prod index ca5d8e291..5f1d31dc8 100644 --- a/backend/services/.env.prod +++ b/backend/services/.env.prod @@ -16,4 +16,5 @@ ASYNC_QUEUE_NAME=https://sqs.us-east-1.amazonaws.com/302213478610/AsyncQueueprod DOMAIN_MAP=true EXPIRES_IN=3600 SMTP_ENDPOINT=vpce-09f436c29698877f7-1edt380c.email-smtp.us-east-1.vpce.amazonaws.com -SMTP_USERNAME=AKIAUMXKTXDJLKSXTF3U \ No newline at end of file +SMTP_USERNAME=AKIAUMXKTXDJLKSXTF3U +systemCountryName="UNDP Digital Public Good National" diff --git a/web/public/Assets/i18n/homepage/en.json b/web/public/Assets/i18n/homepage/en.json index 1fd023104..aa0022878 100644 --- a/web/public/Assets/i18n/homepage/en.json +++ b/web/public/Assets/i18n/homepage/en.json @@ -22,7 +22,7 @@ "reslist2":"Access all the codes through the Carbon Registry GitHub Space, and start tailoring the system. Online Community of Practice : Visit our online forum, where UNDP, D4C working group members, with countries and practitioners are sharing lessons learned on national digital enhanced transparency systems and carbon registries to progress toward a federated digital public infrastructure for transparency under the Paris Agreement.", "reslist3":"For national governments interested to learn more about the open source National Carbon Registry, Please email digital4planet@undp.org.", "footertext1":"National Carbon Registry: This is a demo. Countries may wish to add a tagline here.", - "antarctic":"CountryX", + "antarctic":"UNDP Digital Public Good National", "Cookie":"Cookie Policy", "codeconduct":"Code of Conduct", "terms":"Terms of Use", diff --git a/web/src/Pages/CookiePolicy/cookiePolicy.tsx b/web/src/Pages/CookiePolicy/cookiePolicy.tsx index 253ea46bb..49f45973b 100644 --- a/web/src/Pages/CookiePolicy/cookiePolicy.tsx +++ b/web/src/Pages/CookiePolicy/cookiePolicy.tsx @@ -44,9 +44,9 @@ const CookiePolicy = () => {
SAMPLE COOKIE POLICY
Last updated February 02, 2023
- This Cookie Policy explains how CountryX ("Company", "we","us", - and "our") uses cookies and similar technologies to recognize you when you - visit our websites at{' '} + This Cookie Policy explains how {process.env.REACT_APP_COUNTRY_NAME || 'CountryX'} ( + "Company", "we","us", and "our") uses cookies and similar + technologies to recognize you when you visit our websites at{' '} https://carbreg.org @@ -616,7 +616,7 @@ const CookiePolicy = () => {


- CountryX + {process.env.REACT_APP_COUNTRY_NAME || 'CountryX'}
Address
diff --git a/web/src/Pages/PrivacyPolicy/privacyPolicy.tsx b/web/src/Pages/PrivacyPolicy/privacyPolicy.tsx index e55eb9e36..bbc9365c1 100644 --- a/web/src/Pages/PrivacyPolicy/privacyPolicy.tsx +++ b/web/src/Pages/PrivacyPolicy/privacyPolicy.tsx @@ -44,8 +44,9 @@ const PrivacyPolicy = () => {
SAMPLE PRIVACY NOTICE
Last updated February 02, 2023
- This privacy notice for CountryX ("Company", "we", "us", and{' '} - "our") describes how and why we might collect, store, use, and/or share (" + This privacy notice for {process.env.REACT_APP_COUNTRY_NAME || 'CountryX'} ( + "Company", "we", "us", and "our") describes how and why we + might collect, store, use, and/or share (" process")your information when you use our services ("Services"), such as when you:
    @@ -82,8 +83,9 @@ const PrivacyPolicy = () => {

    What personal information do we process? When you visit, use, or navigate our Services, we may process personal information depending on how you interact with - CountryX and the Services, the choices you make, and the products and features you - use. Click here to learn more. + {process.env.REACT_APP_COUNTRY_NAME || 'CountryX'} and the Services, the choices you + make, and the products and features you use. Click here{' '} + to learn more.

    Do we process any sensitive personal information? We do not process sensitive @@ -132,8 +134,9 @@ const PrivacyPolicy = () => { applicable data protection laws.

    - Want to learn more about what CountryX does with any information we collect? Click{' '} - here to review the notice in full. + Want to learn more about what {process.env.REACT_APP_COUNTRY_NAME || 'CountryX'}{' '} + does with any information we collect? Click here to review the + notice in full.

@@ -975,10 +978,10 @@ const PrivacyPolicy = () => { is not considered to be "selling" of your personal information.

- CountryX has not disclosed or sold any personal information to third parties for a - business or commercial purpose in the preceding twelve (12) months. CountryX will - not sell personal information in the future belonging to website visitors, users, - and other consumers. + {process.env.REACT_APP_COUNTRY_NAME || 'CountryX'} has not disclosed or sold any + personal information to third parties for a business or commercial purpose in the + preceding twelve (12) months. CountryX will not sell personal information in the + future belonging to website visitors, users, and other consumers.

Your rights with respect to your personal data @@ -1111,7 +1114,7 @@ const PrivacyPolicy = () => { Protection Officer (DPO) by email at address@CountryX.org, or by post to:

- CountryX + {process.env.REACT_APP_COUNTRY_NAME || 'CountryX'}
1 United Nations Plaza
@@ -1120,10 +1123,10 @@ const PrivacyPolicy = () => {

If you are a resident in the European Economic Area, the "data controller" of your - personal information is CountryX. United Nations Development Programme has - appointed DPO to be its representative in the EEA. You can contact them directly - regarding the processing of your information by United Nations Development - Programme, or by post to: + personal information is {process.env.REACT_APP_COUNTRY_NAME || 'CountryX'}. United + Nations Development Programme has appointed DPO to be its representative in the + EEA. You can contact them directly regarding the processing of your information by + United Nations Development Programme, or by post to:

From 18f469e361632078dc421544fa37e6d6f2ee2079 Mon Sep 17 00:00:00 2001 From: palindaa Date: Mon, 4 Sep 2023 14:40:38 +0530 Subject: [PATCH 3/6] update prod smtp endpoint --- backend/services/.env.prod | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/backend/services/.env.prod b/backend/services/.env.prod index 5f1d31dc8..1a2f4b38e 100644 --- a/backend/services/.env.prod +++ b/backend/services/.env.prod @@ -15,6 +15,6 @@ DISABLE_LOW_PRIORITY_EMAIL=true ASYNC_QUEUE_NAME=https://sqs.us-east-1.amazonaws.com/302213478610/AsyncQueueprod.fifo DOMAIN_MAP=true EXPIRES_IN=3600 -SMTP_ENDPOINT=vpce-09f436c29698877f7-1edt380c.email-smtp.us-east-1.vpce.amazonaws.com +SMTP_ENDPOINT=vpce-02cef9e74f152b675-b00ybiai.email-smtp.us-east-1.vpce.amazonaws.com SMTP_USERNAME=AKIAUMXKTXDJLKSXTF3U systemCountryName="UNDP Digital Public Good National" From 89dc60d493b32b50ce6690ce627c9517ab08519a Mon Sep 17 00:00:00 2001 From: palindaa Date: Tue, 12 Sep 2023 20:46:47 +0530 Subject: [PATCH 4/6] Update demo system --- backend/services/.env.prod | 1 + 1 file changed, 1 insertion(+) diff --git a/backend/services/.env.prod b/backend/services/.env.prod index 1a2f4b38e..9bfc1c9ba 100644 --- a/backend/services/.env.prod +++ b/backend/services/.env.prod @@ -18,3 +18,4 @@ EXPIRES_IN=3600 SMTP_ENDPOINT=vpce-02cef9e74f152b675-b00ybiai.email-smtp.us-east-1.vpce.amazonaws.com SMTP_USERNAME=AKIAUMXKTXDJLKSXTF3U systemCountryName="UNDP Digital Public Good National" +HOST=https://demo.carbreg.org From f4fa366ef0e89c2bb2f59d6be3a848cb2d74c895 Mon Sep 17 00:00:00 2001 From: palindaa Date: Fri, 15 Sep 2023 10:48:07 +0530 Subject: [PATCH 5/6] Enable API support for all users --- .../src/national-api/company.controller.ts | 19 ++++++++++++++----- .../src/national-api/programme.controller.ts | 7 +++++++ .../services/src/shared/user/user.service.ts | 2 +- 3 files changed, 22 insertions(+), 6 deletions(-) diff --git a/backend/services/src/national-api/company.controller.ts b/backend/services/src/national-api/company.controller.ts index 67fa83640..06e7d2526 100644 --- a/backend/services/src/national-api/company.controller.ts +++ b/backend/services/src/national-api/company.controller.ts @@ -23,6 +23,7 @@ import { FindOrganisationQueryDto } from "../shared/dto/find.organisation.dto"; import { OrganisationUpdateDto } from "../shared/dto/organisation.update.dto"; import { CountryService } from "../shared/util/country.service"; import { HelperService } from "../shared/util/helpers.service"; +import { ApiKeyJwtAuthGuard } from "../shared/auth/guards/api-jwt-key.guard"; @ApiTags("Organisation") @ApiBearerAuth() @@ -44,7 +45,8 @@ export class CompanyController { } @ApiBearerAuth() - @UseGuards(JwtAuthGuard, PoliciesGuardEx(true, Action.Read, Company, true)) + @ApiBearerAuth('api_key') + @UseGuards(ApiKeyJwtAuthGuard, PoliciesGuardEx(true, Action.Read, Company, true)) @Post("queryNames") queryNames(@Body() query: QueryDto, @Request() req) { console.log(req.abilityCondition); @@ -102,7 +104,8 @@ export class CompanyController { } @ApiBearerAuth() - @UseGuards(JwtAuthGuard, PoliciesGuardEx(true, Action.Read, Company)) + @ApiBearerAuth('api_key') + @UseGuards(ApiKeyJwtAuthGuard, PoliciesGuardEx(true, Action.Read, Company)) @Post("findByIds") async findByCompanyId( @Body() body: FindOrganisationQueryDto, @@ -118,20 +121,26 @@ export class CompanyController { } @ApiBearerAuth() - @UseGuards(JwtAuthGuard, PoliciesGuardEx(true, Action.Update, Company)) + @ApiBearerAuth('api_key') + @UseGuards(ApiKeyJwtAuthGuard, PoliciesGuardEx(true, Action.Update, Company)) @Put("update") async updateCompany(@Body() company: OrganisationUpdateDto, @Request() req) { global.baseUrl = `${req.protocol}://${req.get("Host")}`; return await this.companyService.update(company, req.abilityCondition); } - @UseGuards(JwtAuthGuard) + + @ApiBearerAuth() + @ApiBearerAuth('api_key') + @UseGuards(ApiKeyJwtAuthGuard) @Post("countries") async getCountries(@Body() query: QueryDto, @Request() req) { return await this.countryService.getCountryList(query); } - @UseGuards(JwtAuthGuard) + @ApiBearerAuth() + @ApiBearerAuth('api_key') + @UseGuards(ApiKeyJwtAuthGuard) @Get("countries") async getAvailableCountries(@Request() req) { return await this.countryService.getAvailableCountries(); diff --git a/backend/services/src/national-api/programme.controller.ts b/backend/services/src/national-api/programme.controller.ts index aadfd2811..e6757d404 100644 --- a/backend/services/src/national-api/programme.controller.ts +++ b/backend/services/src/national-api/programme.controller.ts @@ -131,6 +131,7 @@ export class ProgrammeController { } @ApiBearerAuth() + @ApiBearerAuth('api_key') @UseGuards(TransferFreezeGuard, ApiKeyJwtAuthGuard, PoliciesGuardEx(true, Action.Update, ProgrammeTransferRequest)) @Put('retire') async programmeRetire(@Body() body: ProgrammeRetire, @Request() req) { @@ -152,6 +153,7 @@ export class ProgrammeController { } @ApiBearerAuth() + @ApiBearerAuth('api_key') @UseGuards(TransferFreezeGuard, ApiKeyJwtAuthGuard, PoliciesGuardEx(true, Action.Create, ProgrammeTransferRequest)) @Post('transferRequest') async transferRequest(@Body() body: ProgrammeTransferRequest, @Request() req) { @@ -159,6 +161,7 @@ export class ProgrammeController { } @ApiBearerAuth() + @ApiBearerAuth('api_key') @UseGuards(TransferFreezeGuard, ApiKeyJwtAuthGuard, PoliciesGuardEx(true, Action.Create, ProgrammeTransferRequest)) @Post('transferApprove') async transferApprove(@Body() body: ProgrammeTransferApprove, @Request() req) { @@ -166,6 +169,7 @@ export class ProgrammeController { } @ApiBearerAuth() + @ApiBearerAuth('api_key') @UseGuards(TransferFreezeGuard, ApiKeyJwtAuthGuard, PoliciesGuardEx(true, Action.Delete, ProgrammeTransfer)) @Post('transferReject') async transferReject(@Body() body: ProgrammeTransferReject, @Request() req) { @@ -173,6 +177,7 @@ export class ProgrammeController { } @ApiBearerAuth() + @ApiBearerAuth('api_key') @UseGuards(TransferFreezeGuard, ApiKeyJwtAuthGuard, PoliciesGuardEx(true, Action.Delete, ProgrammeTransfer)) @Post('transferCancel') async transferCancel(@Body() body: ProgrammeTransferCancel, @Request() req) { @@ -180,6 +185,7 @@ export class ProgrammeController { } @ApiBearerAuth() + @ApiBearerAuth('api_key') @UseGuards(ApiKeyJwtAuthGuard, PoliciesGuardEx(true, Action.Read, ProgrammeTransfer, true)) @Post('transferQuery') queryUser(@Body()query: QueryDto, @Request() req) { @@ -188,6 +194,7 @@ export class ProgrammeController { } @ApiBearerAuth() + @ApiBearerAuth('api_key') @UseGuards(ApiKeyJwtAuthGuard, PoliciesGuardEx(true, Action.Read, ProgrammeTransfer, true)) @Get('transfersByProgrammeId') transfersByProgrammeId(@Query('programmeId') programmeId: string, @Request() req) { diff --git a/backend/services/src/shared/user/user.service.ts b/backend/services/src/shared/user/user.service.ts index 938cbc7e0..c0c362000 100644 --- a/backend/services/src/shared/user/user.service.ts +++ b/backend/services/src/shared/user/user.service.ts @@ -538,7 +538,7 @@ export class UserService { } u.password = this.helperService.generateRandomPassword(); - if (userDto.role == Role.Admin && u.companyRole == CompanyRole.API) { + if (userDto.role == Role.Admin) { u.apiKey = await this.generateApiKey(userDto.email); } From e3bb87d5025d9ba27a957e8c53348110a4234508 Mon Sep 17 00:00:00 2001 From: palindaa Date: Fri, 15 Sep 2023 11:07:17 +0530 Subject: [PATCH 6/6] Api key for query --- backend/services/src/national-api/programme.controller.ts | 1 + 1 file changed, 1 insertion(+) diff --git a/backend/services/src/national-api/programme.controller.ts b/backend/services/src/national-api/programme.controller.ts index e6757d404..48f30183d 100644 --- a/backend/services/src/national-api/programme.controller.ts +++ b/backend/services/src/national-api/programme.controller.ts @@ -85,6 +85,7 @@ export class ProgrammeController { } @ApiBearerAuth() + @ApiBearerAuth('api_key') @UseGuards(ApiKeyJwtAuthGuard, PoliciesGuardEx(true, Action.Read, Programme, true)) // @UseGuards(JwtAuthGuard, PoliciesGuardEx(true, Action.Read, User, true)) @Post('query')