From 4810541ecaff8a181b30aba83233d94567219343 Mon Sep 17 00:00:00 2001 From: Jimmy S Date: Sat, 20 Apr 2024 10:55:44 +0530 Subject: [PATCH] Fix 4KB env variable limit --- .github/workflows/deploy-backend-dev.yml | 2 +- .github/workflows/deploy-backend-prod.yml | 2 +- infrastructure/backend.yml | 5 ----- utils/helper.go | 4 +++- 4 files changed, 5 insertions(+), 8 deletions(-) diff --git a/.github/workflows/deploy-backend-dev.yml b/.github/workflows/deploy-backend-dev.yml index f1329ebef..043a37d72 100644 --- a/.github/workflows/deploy-backend-dev.yml +++ b/.github/workflows/deploy-backend-dev.yml @@ -27,6 +27,7 @@ jobs: - name: Build backend and copy zip to S3 run: | + sed -i "s/RECAPTCHA_CONFIG_JSON_BASE64/${{ secrets.RECAPTCHA_CONFIG_JSON_BASE64 }}/g" utils/helper.go apt-get update && apt-get install -y zip GOOS=linux GOARCH=amd64 CGO_ENABLED=0 go build -o main main.go zip canopas_serverless_dev_${{ github.sha }}.zip main @@ -56,7 +57,6 @@ jobs: DbPort=${{ secrets.DB_PORT }}, DbName=${{ secrets.DB_NAME }}, BlogDbName=${{ secrets.BLOG_DB_NAME }}, - RecaptchaConfigJSONBase64=${{ secrets.RECAPTCHA_CONFIG_JSON_BASE64 }}, RecaptchaSiteKey=${{ secrets.RECAPTCHA_SITE_KEY }}, RecaptchaProjectId=${{ secrets.RECAPTCHA_PROJECT_ID }}, JobsSpreadsheetId=${{ secrets.JOBS_SPREADSHEET_ID }}, diff --git a/.github/workflows/deploy-backend-prod.yml b/.github/workflows/deploy-backend-prod.yml index 8da8b8da4..07c386944 100644 --- a/.github/workflows/deploy-backend-prod.yml +++ b/.github/workflows/deploy-backend-prod.yml @@ -27,6 +27,7 @@ jobs: - name: Build backend and copy zip to S3 run: | + sed -i "s/RECAPTCHA_CONFIG_JSON_BASE64/${{ secrets.RECAPTCHA_CONFIG_JSON_BASE64 }}/g" utils/helper.go apt-get update && apt-get install -y zip GOOS=linux GOARCH=amd64 CGO_ENABLED=0 go build -o main main.go zip canopas_serverless_prod_${{ github.sha }}.zip main @@ -55,7 +56,6 @@ jobs: DbHost=${{ secrets.DB_HOST }}, DbPort=${{ secrets.DB_PORT }}, DbName=${{ secrets.DB_NAME }}, - RecaptchaConfigJSONBase64=${{ secrets.RECAPTCHA_CONFIG_JSON_BASE64 }}, RecaptchaSiteKey=${{ secrets.RECAPTCHA_SITE_KEY }}, RecaptchaProjectId=${{ secrets.RECAPTCHA_PROJECT_ID }}, JobsSpreadsheetId=${{ secrets.JOBS_SPREADSHEET_ID }}, diff --git a/infrastructure/backend.yml b/infrastructure/backend.yml index c1798f0ec..fe64b9c08 100644 --- a/infrastructure/backend.yml +++ b/infrastructure/backend.yml @@ -49,9 +49,6 @@ Parameters: BlogDbName: Type: String Description: Postgres blog database name. - RecaptchaConfigJSONBase64: - Type: String - Description: Recaptcha enterprise credentials in base64 format RecaptchaSiteKey: Type: String Description: Use to verify recpatcha token. @@ -171,8 +168,6 @@ Resources: Fn::Sub: ${DbName} BLOG_DB_NAME: Fn::Sub: ${BlogDbName} - RECAPTCHA_CONFIG_JSON_BASE64: - Fn::Sub: ${RecaptchaConfigJSONBase64} RECAPTCHA_SITE_KEY: Fn::Sub: ${RecaptchaSiteKey} RECAPTCHA_PROJECT_ID: diff --git a/utils/helper.go b/utils/helper.go index 0911662c8..93664b199 100755 --- a/utils/helper.go +++ b/utils/helper.go @@ -21,6 +21,8 @@ import ( recaptchapb "google.golang.org/genproto/googleapis/cloud/recaptchaenterprise/v1" ) +const recaptchaBase64 = "RECAPTCHA_CONFIG_JSON_BASE64" + type utilsRepository struct{} type UtilsRepository interface { SendEmail(*ses.SendEmailInput, *ses.SendRawEmailInput) int @@ -55,7 +57,7 @@ func (repo *utilsRepository) VerifyRecaptcha(token string) (bool, error) { //create recaptcha assessment and verify token ctx := context.Background() - credBytes, err := b64.StdEncoding.DecodeString(os.Getenv("RECAPTCHA_CONFIG_JSON_BASE64")) + credBytes, err := b64.StdEncoding.DecodeString(recaptchaBase64) if err != nil { log.Error(err) return false, err