Skip to content

Commit

Permalink
Revert changes for recaptcha json and remove lambda timeout varibale
Browse files Browse the repository at this point in the history
  • Loading branch information
cp-dharti-r committed Apr 22, 2024
1 parent e01adcf commit b3c853c
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 11 deletions.
5 changes: 1 addition & 4 deletions .github/workflows/deploy-backend-dev.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,6 @@ jobs:

- name: Build backend and copy zip to S3
run: |
echo "${{ secrets.RECAPTCHA_CONFIG_JSON_BASE64 }}" | base64 -d > temp.json
sed -i "s/RECAPTCHA_CONFIG_JSON_BASE64/$(sed 's:/:\\/:g' temp.json)/g" utils/helper.go
rm temp.json
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
Expand Down Expand Up @@ -59,14 +56,14 @@ 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 }},
GithubAccessToken=${{ secrets.PERSONAL_ACCESS_TOKEN_GITHUB }},
ResourcesURL=${{secrets.RESOURCES_URL}},
LambdaBucket=canopas-lambda-handlers,
LambdaUrl=canopas_serverless_dev_${{ github.sha }}.zip,
LambdaTimeout=10,
LambdaRoleName=canopas-dev-lambda-role,
LambdaName=canopas-dev-lambda-function,
ApiGatewayName=canopas-dev-lambda-api,
Expand Down
10 changes: 6 additions & 4 deletions infrastructure/backend.yml
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,9 @@ 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.
Expand Down Expand Up @@ -76,9 +79,6 @@ Parameters:
LambdaUrl:
Type: String
Description: Path of lambda
LambdaTimeout:
Type: Number
Description: Timeout for lambda function
LambdaRoleName:
Type: String
Description: Name of the lambda role
Expand Down Expand Up @@ -129,7 +129,7 @@ Resources:
Handler: main
MemorySize: 256
Timeout:
Fn::Sub: ${LambdaTimeout}
Fn::Sub: 10
Role:
Fn::GetAtt: "LambdaExecutionRole.Arn"
VpcConfig:
Expand Down Expand Up @@ -168,6 +168,8 @@ 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:
Expand Down
4 changes: 1 addition & 3 deletions utils/helper.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,6 @@ 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
Expand Down Expand Up @@ -57,7 +55,7 @@ func (repo *utilsRepository) VerifyRecaptcha(token string) (bool, error) {
//create recaptcha assessment and verify token
ctx := context.Background()

credBytes, err := b64.StdEncoding.DecodeString(recaptchaBase64)
credBytes, err := b64.StdEncoding.DecodeString(os.Getenv("RECAPTCHA_CONFIG_JSON_BASE64"))
if err != nil {
log.Error(err)
return false, err
Expand Down

0 comments on commit b3c853c

Please sign in to comment.