Skip to content

Commit

Permalink
Merge pull request #869 from isomerpages/release/0.36.0
Browse files Browse the repository at this point in the history
Release/0.36.0
  • Loading branch information
harishv7 authored Jul 27, 2023
2 parents dd277c9 + 6f15ace commit dcac9e2
Show file tree
Hide file tree
Showing 13 changed files with 454 additions and 15 deletions.
8 changes: 7 additions & 1 deletion .env-example
Original file line number Diff line number Diff line change
Expand Up @@ -68,4 +68,10 @@ export SITE_LAUNCH_DYNAMO_DB_TABLE_NAME=""
# GitGuardian
export GITGUARDIAN_API_KEY=""

export NETLIFY_ACCESS_TOKEN=""
export NETLIFY_ACCESS_TOKEN=""

# sgID
export SGID_CLIENT_ID=""
export SGID_CLIENT_SECRET=""
export SGID_PRIVATE_KEY=""
export SGID_REDIRECT_URI=""
6 changes: 6 additions & 0 deletions .env.test
Original file line number Diff line number Diff line change
Expand Up @@ -73,3 +73,9 @@ export STEP_FUNCTIONS_ARN="arn:aws:some-arn"
export SITE_PASSWORD_SECRET_KEY="1234567812345678123456781234567812345678123456781234567812345678"

export NETLIFY_ACCESS_TOKEN="blahblah"

# sgID
export SGID_CLIENT_ID="client"
export SGID_CLIENT_SECRET="secret"
export SGID_PRIVATE_KEY="private"
export SGID_REDIRECT_URI="http://localhost:8081/v2/auth/sgid/auth-redirect"
14 changes: 14 additions & 0 deletions .platform/hooks/postdeploy/01_fetch_ssm_parameters.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
#!/bin/bash

ENV_TYPE=$(/opt/elasticbeanstalk/bin/get-config environment -k SSM_PREFIX)
ENV_VARS=("SGID_CLIENT_ID" "SGID_CLIENT_SECRET" "SGID_PRIVATE_KEY" "SGID_REDIRECT_URI") # Add any additional env vars to this array

echo "Set AWS region"
aws configure set default.region ap-southeast-1

for ENV_VAR in "${ENV_VARS[@]}"; do
echo "Fetching ${ENV_VAR} from SSM"
VALUE=$(aws ssm get-parameter --name "${ENV_TYPE}_${ENV_VAR}" --with-decryption --query "Parameter.Value" --output text)
echo "${ENV_VAR}=${VALUE}" >> /opt/elasticbeanstalk/deployment/env
echo "Saved ${ENV_VAR}"
done
21 changes: 13 additions & 8 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,18 @@ All notable changes to this project will be documented in this file. Dates are d

Generated by [`auto-changelog`](https://github.com/CookPete/auto-changelog).

#### [v0.36.0](https://github.com/isomerpages/isomercms-backend/compare/v0.35.0...v0.36.0)

- Feat/sgid experimental integration [`#860`](https://github.com/isomerpages/isomercms-backend/pull/860)
- Revert "chore(e2e): change naming for clarity (#857)" [`#864`](https://github.com/isomerpages/isomercms-backend/pull/864)
- feat(axios): add method to github api logs [`#862`](https://github.com/isomerpages/isomercms-backend/pull/862)
- chore(e2e): change naming for clarity [`#857`](https://github.com/isomerpages/isomercms-backend/pull/857)
- 0.35.0 [`#846`](https://github.com/isomerpages/isomercms-backend/pull/846)

#### [v0.35.0](https://github.com/isomerpages/isomercms-backend/compare/v0.34.0...v0.35.0)

> 20 July 2023
- fix: review request placeholder files [`#847`](https://github.com/isomerpages/isomercms-backend/pull/847)
- Feat: add site lastUpdated with caching [`#830`](https://github.com/isomerpages/isomercms-backend/pull/830)
- Feat/is 21 repo privatisation [`#806`](https://github.com/isomerpages/isomercms-backend/pull/806)
Expand Down Expand Up @@ -144,14 +154,7 @@ Generated by [`auto-changelog`](https://github.com/CookPete/auto-changelog).
- fix: token capacity alarm message ordering [`43ac12b`](https://github.com/isomerpages/isomercms-backend/commit/43ac12bab0114f7563428ce90cc9f55584a43422)

#### [v0.24.1](https://github.com/isomerpages/isomercms-backend/compare/v0.24.0...v0.24.1)

> 27 April 2023
- fix(review request service): use repo name rather than site name [`a323551`](https://github.com/isomerpages/isomercms-backend/commit/a323551feda7b077a7d5d6c2d11ae841ece9bf8d)
- fix(test cases): fix failing tests [`c843865`](https://github.com/isomerpages/isomercms-backend/commit/c84386549a28602e1af10cd2eda9f056212afaa7)

#### [v0.24.0](https://github.com/isomerpages/isomercms-backend/compare/v0.23.1...v0.24.0)
#### [v0.24.1](https://github.com/isomerpages/isomercms-backend/compare/v0.23.1...v0.24.1)

> 27 April 2023
Expand All @@ -163,6 +166,8 @@ Generated by [`auto-changelog`](https://github.com/CookPete/auto-changelog).
- build(deps): bump vm2 from 3.9.16 to 3.9.17 [`#725`](https://github.com/isomerpages/isomercms-backend/pull/725)
- build(deps): bump vm2 from 3.9.16 to 3.9.17 in /microservices [`#724`](https://github.com/isomerpages/isomercms-backend/pull/724)
- 0.23.0 (develop) [`#722`](https://github.com/isomerpages/isomercms-backend/pull/722)
- fix(review request service): use repo name rather than site name [`a323551`](https://github.com/isomerpages/isomercms-backend/commit/a323551feda7b077a7d5d6c2d11ae841ece9bf8d)
- fix(test cases): fix failing tests [`c843865`](https://github.com/isomerpages/isomercms-backend/commit/c84386549a28602e1af10cd2eda9f056212afaa7)

#### [v0.23.1](https://github.com/isomerpages/isomercms-backend/compare/v0.23.0...v0.23.1)

Expand Down
88 changes: 86 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "isomercms",
"version": "0.35.0",
"version": "0.36.0",
"private": true,
"scripts": {
"build": "tsc -p tsconfig.build.json",
Expand Down Expand Up @@ -31,6 +31,7 @@
"@aws-sdk/lib-dynamodb": "^3.370.0",
"@octokit/rest": "^18.12.0",
"@opengovsg/formsg-sdk": "^0.9.0",
"@opengovsg/sgid-client": "^2.0.0",
"auto-bind": "^4.0.0",
"aws-lambda": "^1.0.7",
"aws-sdk": "^2.1416.0",
Expand Down
26 changes: 26 additions & 0 deletions src/config/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -393,6 +393,32 @@ const config = convict({
default: "",
},
},
sgid: {
clientId: {
doc: "sgID client ID provided during client registration",
env: "SGID_CLIENT_ID",
format: "required-string",
default: "",
},
clientSecret: {
doc: "sgID client secret provided during client registration",
env: "SGID_CLIENT_SECRET",
format: "required-string",
default: "",
},
privateKey: {
doc: "sgID client private key provided during client registration",
env: "SGID_PRIVATE_KEY",
format: "required-string",
default: "",
},
redirectUri: {
doc: "URL to redirect to after authentication with sgID",
env: "SGID_REDIRECT_URI",
format: "required-string",
default: "",
},
},
})

// Perform validation
Expand Down
31 changes: 31 additions & 0 deletions src/errors/SgidErrors.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
import { BaseIsomerError } from "@root/errors/BaseError"

export class SgidCreateRedirectUrlError extends BaseIsomerError {
constructor(message = "Error while creating redirect URL") {
super({
status: 500,
code: "SgidCreateRedirectUrlError",
message,
})
}
}

export class SgidFetchAccessTokenError extends BaseIsomerError {
constructor(message = "Error while fetching access token") {
super({
status: 500,
code: "SgidFetchAccessTokenError",
message,
})
}
}

export class SgidFetchUserInfoError extends BaseIsomerError {
constructor(message = "Error while fetching user info") {
super({
status: 500,
code: "SgidFetchUserInfoError",
message,
})
}
}
3 changes: 3 additions & 0 deletions src/routes/v2/auth.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,12 +22,14 @@ class AuthRouter {
statsMiddleware,
apiLogger,
rateLimiter,
sgidAuthRouter,
}) {
this.authService = authService
this.authenticationMiddleware = authenticationMiddleware
this.statsMiddleware = statsMiddleware
this.apiLogger = apiLogger
this.rateLimiter = rateLimiter
this.sgidAuthRouter = sgidAuthRouter
// We need to bind all methods because we don't invoke them from the class directly
autoBind(this)
}
Expand Down Expand Up @@ -118,6 +120,7 @@ class AuthRouter {
router.use(this.apiLogger)

router.use(this.rateLimiter)
router.use("/sgid", this.sgidAuthRouter.getRouter())
router.get(
"/github-redirect",
attachReadRouteHandlerWrapper(this.authRedirect)
Expand Down
Loading

0 comments on commit dcac9e2

Please sign in to comment.