Skip to content

Commit

Permalink
Replaces the Google OAuth passport library by a different one (#304)
Browse files Browse the repository at this point in the history
  • Loading branch information
antoinejaussoin authored Sep 29, 2021
1 parent e879990 commit b7d4404
Show file tree
Hide file tree
Showing 13 changed files with 73 additions and 54 deletions.
6 changes: 2 additions & 4 deletions .github/workflows/alpha.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,10 @@ jobs:

- name: Read VERSION
id: package
uses: juliangruber/read-file-action@v1
with:
path: ./VERSION
uses: martinbeentjes/npm-get-version-action@master

- name: Echo VERSION
run: echo ${{ steps.package.outputs.content }}
run: echo ${{ steps.package.outputs.current-version }}

- name: Setup QEMU
uses: docker/setup-qemu-action@master
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/canary.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,12 @@ jobs:

- name: Read VERSION
id: package
uses: juliangruber/read-file-action@v1
uses: martinbeentjes/npm-get-version-action@master
with:
path: ./VERSION

- name: Echo VERSION
run: echo ${{ steps.package.outputs.content }}
run: echo ${{ steps.package.outputs.current-version }}

- name: Setup QEMU
uses: docker/setup-qemu-action@master
Expand Down
10 changes: 5 additions & 5 deletions .github/workflows/master.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,12 @@ jobs:

- name: Read VERSION
id: package
uses: juliangruber/read-file-action@v1
uses: martinbeentjes/npm-get-version-action@master
with:
path: ./VERSION

- name: Echo VERSION
run: echo ${{ steps.package.outputs.content }}
run: echo ${{ steps.package.outputs.current-version }}

- name: Setup QEMU
uses: docker/setup-qemu-action@master
Expand All @@ -43,7 +43,7 @@ jobs:
builder: ${{ steps.buildx.outputs.name }}
file: backend/Dockerfile
context: .
tags: antoinejaussoin/retro-board-backend:latest,antoinejaussoin/retro-board-backend:${{ steps.package.outputs.content }}
tags: antoinejaussoin/retro-board-backend:latest,antoinejaussoin/retro-board-backend:${{ steps.package.outputs.current-version }}
platforms: linux/amd64,linux/arm64,linux/arm/v7
push: true

Expand All @@ -53,7 +53,7 @@ jobs:
builder: ${{ steps.buildx.outputs.name }}
file: frontend/Dockerfile
context: .
tags: antoinejaussoin/retro-board-frontend:latest,antoinejaussoin/retro-board-frontend:${{ steps.package.outputs.content }}
tags: antoinejaussoin/retro-board-frontend:latest,antoinejaussoin/retro-board-frontend:${{ steps.package.outputs.current-version }}
platforms: linux/amd64,linux/arm64,linux/arm/v7
push: true

Expand All @@ -63,6 +63,6 @@ jobs:
builder: ${{ steps.buildx.outputs.name }}
file: maintenance/Dockerfile
context: maintenance
tags: antoinejaussoin/maintenance:latest,antoinejaussoin/maintenance:${{ steps.package.outputs.content }}
tags: antoinejaussoin/maintenance:latest,antoinejaussoin/maintenance:${{ steps.package.outputs.current-version }}
platforms: linux/amd64,linux/arm64,linux/arm/v7
push: true
4 changes: 4 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -145,6 +145,10 @@ When using the Docker deployment, your database runs from a container. But if yo

## Versions History

### Version 4.7.2

- Replacing Google OAuth passport library, to try and reduce Google OAuth errors on production

### Version 4.7.1 (hotfix)

- 🐛 Fixed a bug highlighted by Sentry, where anonymous account without a password would trigger an exception.
Expand Down
1 change: 0 additions & 1 deletion VERSION

This file was deleted.

6 changes: 3 additions & 3 deletions backend/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@retrospected/backend",
"version": "4.7.1",
"version": "4.7.2",
"license": "GNU GPLv3",
"private": true,
"scripts": {
Expand Down Expand Up @@ -33,7 +33,7 @@
"@types/node-fetch": "^2.5.12",
"@types/passport": "^1.0.7",
"@types/passport-github2": "^1.2.5",
"@types/passport-google-oauth": "^1.0.42",
"@types/passport-google-oauth20": "^2.0.10",
"@types/passport-local": "^1.0.34",
"@types/passport-microsoft": "^0.0.0",
"@types/passport-twitter": "^1.0.37",
Expand Down Expand Up @@ -71,7 +71,7 @@
"passport": "^0.5.0",
"passport-github2": "^0.1.12",
"passport-google-auth": "^1.0.2",
"passport-google-oauth": "^2.0.0",
"passport-google-oauth20": "^2.0.0",
"passport-local": "^1.0.0",
"passport-microsoft": "^0.1.0",
"passport-okta-oauth20": "^1.0.1",
Expand Down
4 changes: 2 additions & 2 deletions backend/src/auth/config.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { IStrategyOption } from 'passport-twitter';
import { IOAuth2StrategyOption } from 'passport-google-oauth';
import { StrategyOptions as GoogleStrategyOptions } from 'passport-google-oauth20';
import { StrategyOptions as GitHubStrategy } from 'passport-github2';
import { MicrosoftStrategyOptions } from 'passport-microsoft';
import { OktaStrategyOptions } from 'passport-okta-oauth20';
Expand All @@ -26,7 +26,7 @@ export const TWITTER_CONFIG: IStrategyOption | null =
}
: null;

export const GOOGLE_CONFIG: IOAuth2StrategyOption | null =
export const GOOGLE_CONFIG: GoogleStrategyOptions | null =
config.GOOGLE_KEY && config.GOOGLE_SECRET
? {
clientID: config.GOOGLE_KEY || '',
Expand Down
18 changes: 11 additions & 7 deletions backend/src/auth/passport.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import passport from 'passport';
import { Strategy as LocalStrategy, IVerifyOptions } from 'passport-local';
import { Strategy as TwitterStrategy } from 'passport-twitter';
import { OAuth2Strategy as GoogleStrategy } from 'passport-google-oauth';
import { Strategy as GoogleStrategy } from 'passport-google-oauth20';
import { Strategy as GithubStrategy } from 'passport-github2';
import { Strategy as SlackStrategy } from 'passport-slack';
import { Strategy as MicrosoftStrategy } from 'passport-microsoft';
Expand Down Expand Up @@ -189,37 +189,41 @@ export default () => {
};
}

function logSuccess(provider: string) {
console.log(chalk`{blue 🔑 {red ${provider}} authentication activated}`);
}

// Adding each OAuth provider's strategy to passport
if (TWITTER_CONFIG) {
passport.use(new TwitterStrategy(TWITTER_CONFIG, callback('twitter')));
console.log(chalk`{blue 🔑 {red Twitter} authentication activated}`);
logSuccess('Twitter');
}

if (GOOGLE_CONFIG) {
passport.use(new GoogleStrategy(GOOGLE_CONFIG, callback('google')));
console.log(chalk`{blue 🔑 {red Google} authentication activated}`);
logSuccess('Google');
}

if (GITHUB_CONFIG) {
passport.use(new GithubStrategy(GITHUB_CONFIG, callback('github')));
console.log(chalk`{blue 🔑 {red GitHub} authentication activated}`);
logSuccess('GitHub');
}

if (SLACK_CONFIG) {
passport.use(new SlackStrategy(SLACK_CONFIG, callback('slack')));
console.log(chalk`{blue 🔑 {red Slack} authentication activated}`);
logSuccess('Slack');
}

if (MICROSOFT_CONFIG) {
passport.use(
new MicrosoftStrategy(MICROSOFT_CONFIG, callback('microsoft'))
);
console.log(chalk`{blue 🔑 {red Microsoft} authentication activated}`);
logSuccess('Microsoft');
}

if (OKTA_CONFIG) {
passport.use(new OktaStrategy(OKTA_CONFIG, callback('okta')));
console.log(chalk`{blue 🔑 {red Okta} authentication activated}`);
logSuccess('Okta');
}

passport.use(
Expand Down
2 changes: 1 addition & 1 deletion common/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@retrospected/common",
"version": "4.7.1",
"version": "4.7.2",
"license": "GNU GPLv3",
"private": true,
"main": "dist/src/index.js",
Expand Down
2 changes: 1 addition & 1 deletion frontend/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@retrospected/frontend",
"version": "4.7.1",
"version": "4.7.2",
"license": "GNU GPLv3",
"private": true,
"dependencies": {
Expand Down
5 changes: 3 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "retrospected",
"version": "4.7.1",
"version": "4.7.2",
"description": "An agile retrospective board - Powering www.retrospected.com",
"private": true,
"workspaces": [
Expand All @@ -24,7 +24,8 @@
"start": "yarn build-common && yarn backend & yarn frontend",
"migrate": "cd backend && yarn migrate && cd ..",
"stripe-login": "stripe login",
"stripe-listen": "stripe listen --forward-to localhost:3000/api/stripe/webhook"
"stripe-listen": "stripe listen --forward-to localhost:3000/api/stripe/webhook",
"bump": ". ./scripts/bump.sh"
},
"repository": {
"type": "git",
Expand Down
27 changes: 27 additions & 0 deletions scripts/bump.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
VERSION_TYPE="${1:-patch}"
ORIG_DIR=$(pwd)

declare -a arr=("frontend" "backend" "common")

npm config set git-tag-version false
npm config set commit-hooks false

# git stash

cd ./scripts

for dir in "${arr[@]}"
do
cd ../${dir}
echo npm version ${VERSION_TYPE}
npm version ${VERSION_TYPE}
done

cd ../
echo npm version ${VERSION_TYPE}
npm version ${VERSION_TYPE}


# git stash pop

cd ${ORIG_DIR}
38 changes: 12 additions & 26 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -2546,13 +2546,14 @@
"@types/passport" "*"
"@types/passport-oauth2" "*"

"@types/passport-google-oauth@^1.0.42":
version "1.0.42"
resolved "https://registry.yarnpkg.com/@types/passport-google-oauth/-/passport-google-oauth-1.0.42.tgz#27aa2df9e838e69e702cfc759f860cdb8d2c59d7"
integrity sha512-0M9Wezbbkgn4VZtHdtEbQru5Kl3qeb2CHoKYvAD2svJDAg8nK1bLG4uBQPudOUuux56igXkFfNGR3gBlsSlTCg==
"@types/passport-google-oauth20@^2.0.10":
version "2.0.10"
resolved "https://registry.yarnpkg.com/@types/passport-google-oauth20/-/passport-google-oauth20-2.0.10.tgz#6aac4eec5ecdd305bd23565969550f63832ba553"
integrity sha512-oOYXZLDN4XSPzDtnGo4hSHPpdalxgoY+wzaS8Aty2t9Hropr1Cua2UcddOIMBnCt9L8HfKkbPTgOZquOmV8J6g==
dependencies:
"@types/express" "*"
"@types/passport" "*"
"@types/passport-oauth2" "*"

"@types/passport-local@^1.0.34":
version "1.0.34"
Expand Down Expand Up @@ -2717,9 +2718,9 @@
"@types/react" "*"

"@types/react@*", "@types/react@>=16.9.0", "@types/react@^17.0.24":
version "17.0.24"
resolved "https://registry.yarnpkg.com/@types/react/-/react-17.0.24.tgz#7e1b3f78d0fc53782543f9bce6d949959a5880bd"
integrity sha512-eIpyco99gTH+FTI3J7Oi/OH8MZoFMJuztNRimDOJwH4iGIsKV2qkGnk4M9VzlaVWeEEWLWSQRy0FEA0Kz218cg==
version "17.0.25"
resolved "https://registry.yarnpkg.com/@types/react/-/react-17.0.25.tgz#8b88c226e54910762decc9de2aa36b4dc9240503"
integrity sha512-IXrzSOr3CVbEQgmjEdCWF57J7CVaJ7lL/n4penxHm8h0XIcr0AxqGucogh2zj3qRxgk4M4JImOP/MfomkPOhvQ==
dependencies:
"@types/prop-types" "*"
"@types/scheduler" "*"
Expand Down Expand Up @@ -8133,9 +8134,9 @@ is-glob@^3.1.0:
is-extglob "^2.1.0"

is-glob@^4.0.0, is-glob@^4.0.1, is-glob@~4.0.1:
version "4.0.2"
resolved "https://registry.yarnpkg.com/is-glob/-/is-glob-4.0.2.tgz#859fc2e731e58c902f99fcabccb75a7dd07d29d8"
integrity sha512-ZZTOjRcDjuAAAv2cTBQP/lL59ZTArx77+7UzHdWW/XB1mrfp7DEaVpKmZ0XIzx+M7AxfhKcqV+nMetUQmFifwg==
version "4.0.3"
resolved "https://registry.yarnpkg.com/is-glob/-/is-glob-4.0.3.tgz#64f61e42cbbb2eec2071a9dac0b28ba1e65d5084"
integrity sha512-xelSayHH36ZgE7ZWhli7pW34hNbNl8Ojv5KVmkJD4hBdD3th8Tfk9vYasLM+mXWOZhFkgZfxhLSnrwRr4elSSg==
dependencies:
is-extglob "^2.1.1"

Expand Down Expand Up @@ -11249,28 +11250,13 @@ passport-google-auth@^1.0.2:
googleapis "^16.0.0"
passport-strategy "1.x"

[email protected]:
version "1.0.0"
resolved "https://registry.yarnpkg.com/passport-google-oauth1/-/passport-google-oauth1-1.0.0.tgz#af74a803df51ec646f66a44d82282be6f108e0cc"
integrity sha1-r3SoA99R7GRvZqRNgigr5vEI4Mw=
dependencies:
passport-oauth1 "1.x.x"

[email protected]:
passport-google-oauth20@^2.0.0:
version "2.0.0"
resolved "https://registry.yarnpkg.com/passport-google-oauth20/-/passport-google-oauth20-2.0.0.tgz#0d241b2d21ebd3dc7f2b60669ec4d587e3a674ef"
integrity sha512-KSk6IJ15RoxuGq7D1UKK/8qKhNfzbLeLrG3gkLZ7p4A6DBCcv7xpyQwuXtWdpyR0+E0mwkpjY1VfPOhxQrKzdQ==
dependencies:
passport-oauth2 "1.x.x"

passport-google-oauth@^2.0.0:
version "2.0.0"
resolved "https://registry.yarnpkg.com/passport-google-oauth/-/passport-google-oauth-2.0.0.tgz#f6eb4bc96dd6c16ec0ecfdf4e05ec48ca54d4dae"
integrity sha512-JKxZpBx6wBQXX1/a1s7VmdBgwOugohH+IxCy84aPTZNq/iIPX6u7Mqov1zY7MKRz3niFPol0KJz8zPLBoHKtYA==
dependencies:
passport-google-oauth1 "1.x.x"
passport-google-oauth20 "2.x.x"

passport-local@^1.0.0:
version "1.0.0"
resolved "https://registry.yarnpkg.com/passport-local/-/passport-local-1.0.0.tgz#1fe63268c92e75606626437e3b906662c15ba6ee"
Expand Down

0 comments on commit b7d4404

Please sign in to comment.