Skip to content

Commit

Permalink
added google sign-in feature for both frontend and backend
Browse files Browse the repository at this point in the history
  • Loading branch information
jgadsden authored Oct 8, 2024
2 parents 47206b7 + facd9ec commit 9c5e871
Show file tree
Hide file tree
Showing 52 changed files with 1,570 additions and 29 deletions.
4 changes: 4 additions & 0 deletions example.env
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,10 @@ GITLAB_CLIENT_SECRET=0123456789abcdef0123456789abcdef0123456
GITLAB_SCOPE=read_user read_repository write_repository profile read_api api
GITLAB_REDIRECT_URI=http://localhost:3000/api/oauth/return

GOOGLE_CLIENT_ID=01234567890123456789
GOOGLE_CLIENT_SECRET=0123456789abcdef0123456789abcdef0123456
GOOGLE_SCOPE=openid email profile
GOOGLE_REDIRECT_URI=http://localhost:3000/api/oauth/return

NODE_ENV=development
SERVER_API_PROTOCOL=http
17 changes: 11 additions & 6 deletions package-lock.json

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

198 changes: 196 additions & 2 deletions td.server/package-lock.json

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

1 change: 1 addition & 0 deletions td.server/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@
"dotenv": "^16.0.3",
"express": "^4.20.0",
"express-rate-limit": "^7.4.0",
"googleapis": "^144.0.0",
"helmet": "^6.0.1",
"jsonwebtoken": "^9.0.0",
"octonode": "^0.10.2",
Expand Down
3 changes: 3 additions & 0 deletions td.server/src/config/env.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import EncryptionEnv from '../env/Encryption.js';
import env from '../env/Env.js';
import GithubEnv from '../env/Github.js';
import GitlabEnv from "../env/Gitlab";
import GoogleEnv from '../env/Google.js';
import ThreatDragonEnv from '../env/ThreatDragon.js';

const tryLoadDotEnv = () => {
Expand All @@ -11,11 +12,13 @@ const tryLoadDotEnv = () => {
const bitbucket = new BitbucketEnv();
const encryption = new EncryptionEnv();
const threatDragon = new ThreatDragonEnv();
const google = new GoogleEnv();
env.get().addProvider(github);
env.get().addProvider(gitlab);
env.get().addProvider(encryption);
env.get().addProvider(bitbucket);
env.get().addProvider(threatDragon);
env.get().addProvider(google);
env.get().hydrate();
};

Expand Down
7 changes: 7 additions & 0 deletions td.server/src/config/routes.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import express from 'express';
import auth from '../controllers/auth.js';
import bearer from './bearer.config.js';
import configController from "../controllers/configcontroller";
import googleProviderThreatmodelController from '../controllers/googleProviderThreatmodelController.js';
import healthcheck from '../controllers/healthz.js';
import homeController from '../controllers/homecontroller.js';
import threatmodelController from '../controllers/threatmodelcontroller.js';
Expand Down Expand Up @@ -47,6 +48,12 @@ const routes = (router) => {

router.post('/api/threatmodel/:organisation/:repo/:branch/:model/create', threatmodelController.create);
router.put('/api/threatmodel/:organisation/:repo/:branch/:model/update', threatmodelController.update);

// Google Drive routes
router.get('/api/googleproviderthreatmodel/folders', googleProviderThreatmodelController.folders);
router.post('/api/googleproviderthreatmodel/:folder/create', googleProviderThreatmodelController.create);
router.put('/api/googleproviderthreatmodel/:file/update', googleProviderThreatmodelController.update);
router.get('/api/googleproviderthreatmodel/:file/data', googleProviderThreatmodelController.model);
};

const config = (app) => {
Expand Down
1 change: 1 addition & 0 deletions td.server/src/controllers/configcontroller.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ export const getConfig = () => ({
bitbucketEnabled: env.get().config.BITBUCKET_CLIENT_ID !== undefined && env.get().config.BITBUCKET_CLIENT_ID !== null,
githubEnabled: env.get().config.GITHUB_CLIENT_ID !== undefined && env.get().config.GITHUB_CLIENT_ID !== null,
gitlabEnabled: env.get().config.GITLAB_CLIENT_ID !== undefined && env.get().config.GITLAB_CLIENT_ID !== null,
googleEnabled: env.get().config.GOOGLE_CLIENT_ID !== undefined && env.get().config.GOOGLE_CLIENT_ID !== null,
localEnabled: true,
});

Expand Down
Loading

0 comments on commit 9c5e871

Please sign in to comment.