From bc63422fb8c8293e468b9880346b51de750d92c0 Mon Sep 17 00:00:00 2001 From: gandalfran Date: Sat, 12 Dec 2020 13:10:50 +0100 Subject: [PATCH 1/2] . --- soa-web-app/node-server/config/config.json | 13 ++++-- soa-web-app/node-server/src/app.ts | 25 +++++++++-- soa-web-app/node-server/src/config.ts | 37 ++++++++++------ .../src/controller/authController.ts | 42 +++++++++++++++++-- 4 files changed, 94 insertions(+), 23 deletions(-) diff --git a/soa-web-app/node-server/config/config.json b/soa-web-app/node-server/config/config.json index 8c7a37f..1490aa3 100644 --- a/soa-web-app/node-server/config/config.json +++ b/soa-web-app/node-server/config/config.json @@ -14,8 +14,15 @@ "caFile": "certs/server.ca-bundle" }, "auth": { - "id": "706477281622-fc5smi1o8hhu3kjp94ttfkdbno22tv9d.apps.googleusercontent.com", - "secret": "MekxIl70WrvBkW7X5qCJj13F", - "callback": "https://soa.servehttp.com/auth/google/callback" + "google": { + "id": "706477281622-fc5smi1o8hhu3kjp94ttfkdbno22tv9d.apps.googleusercontent.com", + "secret": "MekxIl70WrvBkW7X5qCJj13F", + "callback": "https://soa.servehttp.com/auth/google/callback" + }, + "github": { + "id": "088435c6236d21c6c4fe", + "secret": "05ec9b4f795e229bfa9f72351aaab8ad8e8498ae", + "callback": "https://soa.servehttp.com/auth/github/callback" + }, } } \ No newline at end of file diff --git a/soa-web-app/node-server/src/app.ts b/soa-web-app/node-server/src/app.ts index d33a8c0..b7aeb3c 100644 --- a/soa-web-app/node-server/src/app.ts +++ b/soa-web-app/node-server/src/app.ts @@ -10,11 +10,12 @@ import * as Path from "path"; import Express from "express"; import * as HTTPS from "https"; import Passport from 'passport'; +import Session from 'express-session'; import Compression from "compression"; import CookieParser from 'cookie-parser'; import CookieSession from 'cookie-session'; -import Session from 'express-session'; import * as BodyParser from 'body-parser'; +import GitHubStrategy from 'passport-github2'; import GoogleStrategy from 'passport-google-oauth'; import { log } from "./log"; @@ -96,10 +97,12 @@ export class Application { public configurePassportAuth(){ this.application.use(Passport.initialize()); this.application.use(Passport.session()); + + // google oauth Passport.use(new GoogleStrategy.OAuth2Strategy({ - clientID: Config.getInstance().auth.clientId, - callbackURL: Config.getInstance().auth.callback, - clientSecret: Config.getInstance().auth.clientSecret + clientID: Config.getInstance().auth.google.clientId, + callbackURL: Config.getInstance().auth.google.callback, + clientSecret: Config.getInstance().auth.google.clientSecret }, function(token, refreshToken, profile, done){ return done(null, { profile: profile, @@ -107,6 +110,20 @@ export class Application { refreshToken: refreshToken }); })); + + // github oauth + Passport.use(new GitHubStrategy({ + clientID: Config.getInstance().auth.github.clientId, + callbackURL: Config.getInstance().auth.github.callback, + clientSecret: Config.getInstance().auth.github.clientSecret + }, function(token, refreshToken, profile, done) { + return done(null, { + profile: profile, + token: token, + refreshToken: refreshToken + }); + })); + Passport.serializeUser((user, done) => { done(null, user); }); diff --git a/soa-web-app/node-server/src/config.ts b/soa-web-app/node-server/src/config.ts index 6dfe508..bc9601d 100644 --- a/soa-web-app/node-server/src/config.ts +++ b/soa-web-app/node-server/src/config.ts @@ -49,18 +49,18 @@ export class HttpsConfig extends HttpConfig{ } } -/** Class to store the Google OAuth2.0. */ -export class GoogleAuthConfig { +/** Class to store the OAuth2.0 flow info. */ +export class AuthConfig { - /** Google OAuth2.0 application client id. */ + /** OAuth2.0 application client id. */ public clientId: string; - /** Google OAuth2.0 application client secret. */ + /**OAuth2.0 application client secret. */ public clientSecret: string; - /** Google OAuth2.0 application client callback endpoint to receive the auth params and tokens. */ + /**OAuth2.0 application client callback endpoint to receive the auth params and tokens. */ public callback: string; /** - * Create a GoogleAuthConfig. + * Create a AuthConfig. */ constructor(){ this.clientId = ""; @@ -120,12 +120,20 @@ export class Config { config.https.certFile = rawConfig.https.certFile; } - // load auth info - config.auth = new GoogleAuthConfig(); - if (typeof rawConfig === "object" && typeof rawConfig.auth === "object") { - config.auth.clientId = rawConfig.auth.id; - config.auth.callback = rawConfig.auth.callback; - config.auth.clientSecret = rawConfig.auth.secret; + // load google auth info + config.auth.google = new AuthConfig(); + if (typeof rawConfig === "object" && typeof rawConfig.auth === "object" && typeof rawConfig.auth.google === "object") { + config.auth.google.clientId = rawConfig.auth.google.id; + config.auth.google.callback = rawConfig.auth.google.callback; + config.auth.google.clientSecret = rawConfig.google.auth.secret; + } + + // load github auth info + config.auth.github = new AuthConfig(); + if (typeof rawConfig === "object" && typeof rawConfig.auth === "object" && typeof rawConfig.auth.github === "object") { + config.auth.github.clientId = rawConfig.auth.github.id; + config.auth.github.callback = rawConfig.auth.github.callback; + config.auth.github.clientSecret = rawConfig.auth.github.secret; } } @@ -140,5 +148,8 @@ export class Config { /** HTTPS configuration. */ public https: HttpsConfig; /** Google OAuth2.0 configuration. */ - public auth: GoogleAuthConfig; + public auth: any = { + google: null, + github: null, + }; } diff --git a/soa-web-app/node-server/src/controller/authController.ts b/soa-web-app/node-server/src/controller/authController.ts index be8c3f2..3af18fc 100644 --- a/soa-web-app/node-server/src/controller/authController.ts +++ b/soa-web-app/node-server/src/controller/authController.ts @@ -18,6 +18,8 @@ export class AuthController{ * @param application - the express aplication. */ public registerController(application: Express.Express): any { + + // google login application.get("/auth/google", Passport.authenticate('google', { scope: ['https://www.googleapis.com/auth/plus.login', @@ -26,10 +28,22 @@ export class AuthController{ ); application.get("/auth/google/callback", Passport.authenticate('google', {failureRedirect: '/#/forbidden' }), - this.authCallback.bind(this) + this.googleAuthCallback.bind(this) ); application.get("/auth/google/logout", this.logout.bind(this)); + // github login + application.get('/auth/github', + Passport.authenticate('github', { + scope: [ 'user:email' ] + }) + ); + application.get('/auth/github/callback', + Passport.authenticate('github', { failureRedirect: '/#/forbidden' }), + this.githubAuthCallback.bind(this) + ); + + // auth check application.post("/auth/check", this.checkAuth.bind(this)); } @@ -38,14 +52,36 @@ export class AuthController{ * @param request - the express request. * @param response - the express response. */ - public async authCallback(request: Express.Request, response: Express.Response) { + public async googleAuthCallback(request: Express.Request, response: Express.Response) { const user: any = request.user; const email: string = user.profile.emails[0].value; if(WhiteList.isInWhitelist(email)){ request.session.user = { id: user.profile.id, - email: user.profile.emails[0].value + email: email + } + request.session.token = user.token; + response.redirect('/#/dashboard'); + }else{ + response.redirect('/#/forbidden'); + } + } + + /** + * Callback endpoint for GitHub OAuth2.0. Here the user login session is generated. + * @param request - the express request. + * @param response - the express response. + */ + public async githubAuthCallback(request: Express.Request, response: Express.Response) { + const user: any = request.user; + console.log(user) + const email: string = user.profile.email; + + if(WhiteList.isInWhitelist(email)){ + request.session.user = { + id: user.profile.id, + email: email } request.session.token = user.token; response.redirect('/#/dashboard'); From 93c79952a83927f11f289bb900c32b40f8f5ea2b Mon Sep 17 00:00:00 2001 From: Francisco Pinto Santos Date: Sat, 12 Dec 2020 16:05:21 +0100 Subject: [PATCH 2/2] . --- .github/workflows/main.yml | 24 ++++----- soa-web-app/certificates/create.bash | 16 ------ soa-web-app/certificates/server.ca-bundle | 58 ---------------------- soa-web-app/certificates/server.crt | 31 ------------ soa-web-app/certificates/server.key | 28 ----------- soa-web-app/certificates/validate-cert.js | 9 ---- soa-web-app/node-server/config/config.json | 2 +- soa-web-app/node-server/package-lock.json | 45 +++++++++++++++-- soa-web-app/node-server/package.json | 2 + soa-web-app/node-server/src/app.ts | 6 +-- soa-web-app/node-server/src/config.ts | 2 +- 11 files changed, 61 insertions(+), 162 deletions(-) delete mode 100644 soa-web-app/certificates/create.bash delete mode 100644 soa-web-app/certificates/server.ca-bundle delete mode 100644 soa-web-app/certificates/server.crt delete mode 100644 soa-web-app/certificates/server.key delete mode 100644 soa-web-app/certificates/validate-cert.js diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index ccca2b6..4b35ffc 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -10,18 +10,18 @@ jobs: steps: - name: download new changes uses: actions/checkout@v2 - build_web: - runs-on: [self-hosted, linux, x64] - needs: download - steps: - - name: install dependencies - run: cd /opt/soa-final/_work/TwiCo/TwiCo/soa-web-app/vue-web; npm install - - name: build vue web - run: cd /opt/soa-final/_work/TwiCo/TwiCo/soa-web-app/vue-web; npm run build - - name: create final location directory - run: mkdir /opt/soa-final/_work/TwiCo/TwiCo/soa-web-app/node-server/static - - name: copy web to final location - run: mv /opt/soa-final/_work/TwiCo/TwiCo/soa-web-app/vue-web/dist/* /opt/soa-final/_work/TwiCo/TwiCo/soa-web-app/node-server/static/ + #build_web: + # runs-on: [self-hosted, linux, x64] + # needs: download + # steps: + # - name: install dependencies + # run: cd /opt/soa-final/_work/TwiCo/TwiCo/soa-web-app/vue-web; npm install + # - name: build vue web + # run: cd /opt/soa-final/_work/TwiCo/TwiCo/soa-web-app/vue-web; npm run build + # - name: create final location directory + # run: mkdir /opt/soa-final/_work/TwiCo/TwiCo/soa-web-app/node-server/static + # - name: copy web to final location + # run: mv /opt/soa-final/_work/TwiCo/TwiCo/soa-web-app/vue-web/dist/* /opt/soa-final/_work/TwiCo/TwiCo/soa-web-app/node-server/static/ build_web_server: runs-on: [self-hosted, linux, x64] needs: download diff --git a/soa-web-app/certificates/create.bash b/soa-web-app/certificates/create.bash deleted file mode 100644 index 4157da7..0000000 --- a/soa-web-app/certificates/create.bash +++ /dev/null @@ -1,16 +0,0 @@ -#!/bin/bash -# src: https://medium.com/@saurabh6790/generate-wildcard-ssl-certificate-using-lets-encrypt-certbot-273e432794d7 - -# prepare letsencrypt certificates -export LC_ALL="en_US.UTF-8" -export LC_CTYPE="en_US.UTF-8" - -# install letsencript -sudo apt install letsencrypt -y - -# create certificate -letsencrypt certonly \ - --manual \ - --email franpintosantos@usal.es \ - --server https://acme-v02.api.letsencrypt.org/directory \ - --agree-tos -d soa.servehttp.com \ No newline at end of file diff --git a/soa-web-app/certificates/server.ca-bundle b/soa-web-app/certificates/server.ca-bundle deleted file mode 100644 index 494fcae..0000000 --- a/soa-web-app/certificates/server.ca-bundle +++ /dev/null @@ -1,58 +0,0 @@ ------BEGIN CERTIFICATE----- -MIIFWTCCBEGgAwIBAgISBJMOwRrezBr+VwsYzoNliGCmMA0GCSqGSIb3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Vi4MFU5aMqrSDE6ea73Mj2tcMyo5jMd6jmeWUHK8so/joWUoHOUgwu -X4Po1QYz+3dszkDqMp4fklxBwXRsW10KXzPMTZ+sOPAveyxindmjkW8lGy+QsRlG -PfZ+G6Z6h7mjem0Y+iWlkYcV4PIWL1iwBi8saCbGS5jN2p8M+X+Q7UNKEkROb3N6 -KOqkqm57TH2H3eDJAkSnh6/DNFu0Qg== ------END CERTIFICATE----- diff --git a/soa-web-app/certificates/server.crt b/soa-web-app/certificates/server.crt deleted file mode 100644 index d738d66..0000000 --- a/soa-web-app/certificates/server.crt +++ /dev/null @@ -1,31 +0,0 @@ ------BEGIN CERTIFICATE----- -MIIFWTCCBEGgAwIBAgISBJMOwRrezBr+VwsYzoNliGCmMA0GCSqGSIb3DQEBCwUA -MEoxCzAJBgNVBAYTAlVTMRYwFAYDVQQKEw1MZXQncyBFbmNyeXB0MSMwIQYDVQQD -ExpMZXQncyBFbmNyeXB0IEF1dGhvcml0eSBYMzAeFw0yMDExMDgxMTQ4MTlaFw0y -MTAyMDYxMTQ4MTlaMBwxGjAYBgNVBAMTEXNvYS5zZXJ2ZWh0dHAuY29tMIIBIjAN -BgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAyvuzyn430aKD/gYwWzE2z2B10jsK -he1dUMy03KaIoW81fITtwNUtAnevq9Mh0L+ZXo7NPnBGKC01FUsX8ugPTWVKb+wh -4Xfe6awvG8v9k6TtUfnMPLjg3oqchTSdvDuKnTBABVcXhJbPNSP3olQ953YWzQ26 -yeJrQgpwurNY2sSUpOeRGM0dtQHM0vvlZIsU42ZD4WJcp5/i6nd/rGAGSoZP4TYT -DsbYUU7zTEn02gIGkkg46+jUql+8Od0zpYhDCbUm24yi703QT7JAVAC+5UpK/zsF -KmzXoKtDk75jLt1bNp5/FyoCqQqg9geCcrOg8qDf8sIQ/6bfUnXlbzEfmQIDAQAB -o4ICZTCCAmEwDgYDVR0PAQH/BAQDAgWgMB0GA1UdJQQWMBQGCCsG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WiRJ7yCJxNnW2nsfj+giF8uqFghZfIPkmPvjXQ8iEl61FKul -+94hx8XRmheCKTFjTHPo4shlB5yw/H4uwowvPnM= ------END CERTIFICATE----- diff --git a/soa-web-app/certificates/server.key b/soa-web-app/certificates/server.key deleted file mode 100644 index 2671395..0000000 --- a/soa-web-app/certificates/server.key +++ /dev/null @@ -1,28 +0,0 @@ ------BEGIN PRIVATE KEY----- -MIIEvQIBADANBgkqhkiG9w0BAQEFAASCBKcwggSjAgEAAoIBAQDK+7PKfjfRooP+ -BjBbMTbPYHXSOwqF7V1QzLTcpoihbzV8hO3A1S0Cd6+r0yHQv5lejs0+cEYoLTUV -Sxfy6A9NZUpv7CHhd97prC8by/2TpO1R+cw8uODeipyFNJ28O4qdMEAFVxeEls81 -I/eiVD3ndhbNDbrJ4mtCCnC6s1jaxJSk55EYzR21AczS++VkixTjZkPhYlynn+Lq -d3+sYAZKhk/hNhMOxthRTvNMSfTaAgaSSDjr6NSqX7w53TOliEMJtSbbjKLvTdBP -skBUAL7lSkr/OwUqbNegq0OTvmMu3Vs2nn8XKgKpCqD2B4Jys6DyoN/ywhD/pt9S -deVvMR+ZAgMBAAECggEAIn5tii6yy6QjbAqfMxAE8W7B9uzjl+jDX9S5s3l1ZIGi -hDuOr6NKV84BA2EIsRGuPXxk8oRf17n++FRfiH7ZAt0Ark5hX5BgSDNjegTLXci8 -L58UjwkX5ZmGibhsSa2Qm6+0YXPwYi7CnZQ0I9jPAEN4EnaP1HjuozVk/MU3h01t -IQcic+zWEx7ouaa0oebm80XIytlAmzlBEdAGsoctxvaS5t3FpHW0Vmgw+ZmPGVJF -C5bzANLnBz3IVL96xQtwUe14ii+iPI83SW6+1MFrBf8Dx50KzUFX5R6IUhZhsz98 -r2Mww9lUs5AAGY/jDBmTHFBk//Xq+bqwtL7UnFzBAQKBgQDw5UP/WKtgUAZfa53+ -yl3p2UpPa+jPuXGeG6Es/ss97Td2re7PH9vDCHAerQKW4L8QY1U2uRgw8tD/NRqF -47HU8fgfMfJaLkPLimKukitGSfLmdJZdsS9yBrik4cUiugQBjYtagAoiu+YVz2F3 -cyqFiSzrXVRWZ/l3CdyFKKqY4QKBgQDXteL6VmM0iL/ZnG6+SwWWv/vpCwYIfpuV -5xANnTHXjiVoMFf2/gkP5zwfrX6/k60PAxF5mGTtryA6uCDF+QvXl5IgYX1+1jMB -ymPcPqT/b40j46aZNxTeSuM1eNYQfgQs7oUJiM0/sLffFaORxJtmQiJwMlYCImiB -ydzPYzRFuQKBgBXgvIw0QVw96FZCL9c0CdNzKIyOAFbdQLRbTggIG+1D3gWpRkcJ -XawY2BXxIIsTXkbevp55sPjBFLoY2I/QXhY444/xuVD3YrDZoJy6KbP4g1bqv71C -mkyAz8QpvP2qZzK86CsP9duxtPPGIdP3YaU/EBVQJJi0WLO28ZAmYVgBAoGAVdmy -+1UUaJ0gVdhXju7Gy6ee97IGda0F+RQcJH7yjkqpgpzy9X9HVgf+utDPCCobD0V2 -WAGZ8aroVdZgXMpwtx5A7xg93RQc+tJ1Cfv4qRzZfHYnIQV2Db6aTPbJo4iz2roX -QqMqpPWNSIERN3ubKYiasjKmXnUZSMZxViyyaikCgYEAnAcmXgrVMztudbApwiOY -XNmjz0XlwwLoM8dXkSiWm4sRBBR+3GbPrXgwHJRZXGTtOEfle1zhNGw5HTP9PCLo -5DEmxv9iDfmYEGqabn//A2vdpwxLhOLUkOX/WcpOFgFWieYkIgUyQnNVHWJYE4S4 -/QYlMNABXW2mXQURDLdCo+8= ------END PRIVATE KEY----- diff --git a/soa-web-app/certificates/validate-cert.js b/soa-web-app/certificates/validate-cert.js deleted file mode 100644 index 9e17298..0000000 --- a/soa-web-app/certificates/validate-cert.js +++ /dev/null @@ -1,9 +0,0 @@ -const port = 80; -const hostname = '0.0.0.0'; -const endpoint = '/.well-known/acme-challenge/lTtG_Gr_dwcHNcUucN-8-MYdYuQ0qN1o_xXPSqJQOhM'; -const toServe = 'lTtG_Gr_dwcHNcUucN-8-MYdYuQ0qN1o_xXPSqJQOhM.UGxa30kE1WhZWoiBWnwNmpmHasZXnx9h4L4-ox6l1OU'; - -require('http').createServer(function(request, response) { - response.writeHead(200, {'Content-Type': 'text/plain'}); - response.end(toServe); -}).listen(port, hostname); \ No newline at end of file diff --git a/soa-web-app/node-server/config/config.json b/soa-web-app/node-server/config/config.json index 1490aa3..10bcd75 100644 --- a/soa-web-app/node-server/config/config.json +++ b/soa-web-app/node-server/config/config.json @@ -23,6 +23,6 @@ "id": "088435c6236d21c6c4fe", "secret": "05ec9b4f795e229bfa9f72351aaab8ad8e8498ae", "callback": "https://soa.servehttp.com/auth/github/callback" - }, + } } } \ No newline at end of file diff --git a/soa-web-app/node-server/package-lock.json b/soa-web-app/node-server/package-lock.json index c0f5fb2..c2b4280 100644 --- a/soa-web-app/node-server/package-lock.json +++ b/soa-web-app/node-server/package-lock.json @@ -132,6 +132,15 @@ "integrity": "sha512-6QlRuqsQ/Ox/aJEQWBEJG7A9+u7oSYl3mem/K8IzxXG/kAGbV1YPD9Bg9Zw3vyxC/YP+zONKwy8hGkSt1jxFMw==", "dev": true }, + "@types/oauth": { + "version": "0.9.1", + "resolved": "https://registry.npmjs.org/@types/oauth/-/oauth-0.9.1.tgz", + "integrity": "sha512-a1iY62/a3yhZ7qH7cNUsxoI3U/0Fe9+RnuFrpTKr+0WVOzbKlSLojShCKe20aOD1Sppv+i8Zlq0pLDuTJnwS4A==", + "dev": true, + "requires": { + "@types/node": "*" + } + }, "@types/passport": { "version": "1.0.4", "resolved": "https://registry.npmjs.org/@types/passport/-/passport-1.0.4.tgz", @@ -141,6 +150,17 @@ "@types/express": "*" } }, + "@types/passport-github2": { + "version": "1.2.4", + "resolved": "https://registry.npmjs.org/@types/passport-github2/-/passport-github2-1.2.4.tgz", + "integrity": "sha512-dtGtA0Uyzk6ne3SrgQi/I1ClClLE3i7JmSiMaJgkGH8v1nbE9JdBpG7QWJ1XPlLdcf7EvoPdHmkWN2+Kln9y8g==", + "dev": true, + "requires": { + "@types/express": "*", + "@types/passport": "*", + "@types/passport-oauth2": "*" + } + }, "@types/passport-google-oauth": { "version": "1.0.41", "resolved": "https://registry.npmjs.org/@types/passport-google-oauth/-/passport-google-oauth-1.0.41.tgz", @@ -151,6 +171,17 @@ "@types/passport": "*" } }, + "@types/passport-oauth2": { + "version": "1.4.9", + "resolved": "https://registry.npmjs.org/@types/passport-oauth2/-/passport-oauth2-1.4.9.tgz", + "integrity": "sha512-QP0q+NVQOaIu2r0e10QWkiUA0Ya5mOBHRJN0UrI+LolMLOP1/VN4EVIpJ3xVwFo+xqNFRoFvFwJhBvKnk7kpUA==", + "dev": true, + "requires": { + "@types/express": "*", + "@types/oauth": "*", + "@types/passport": "*" + } + }, "@types/qs": { "version": "6.9.5", "resolved": "https://registry.npmjs.org/@types/qs/-/qs-6.9.5.tgz", @@ -1360,9 +1391,9 @@ "dev": true }, "ini": { - "version": "1.3.5", - "resolved": "https://registry.npmjs.org/ini/-/ini-1.3.5.tgz", - "integrity": "sha512-RZY5huIKCMRWDUqZlEi72f/lmXKMvuszcMBduliQ3nnWbx9X/ZBQO7DijMEYS9EhHBb2qacRUMtC7svLwe0lcw==", + "version": "1.3.8", + "resolved": "https://registry.npmjs.org/ini/-/ini-1.3.8.tgz", + "integrity": "sha512-JV/yugV2uzW5iMRSiZAyDtQd+nxtUnjeLt0acNdw98kKLrvuRVyB80tsREOE7yvGVgalhZ6RNXCmEHkUKBKxew==", "dev": true }, "ipaddr.js": { @@ -1928,6 +1959,14 @@ "pause": "0.0.1" } }, + "passport-github2": { + "version": "0.1.12", + "resolved": "https://registry.npmjs.org/passport-github2/-/passport-github2-0.1.12.tgz", + "integrity": "sha512-3nPUCc7ttF/3HSP/k9sAXjz3SkGv5Nki84I05kSQPo01Jqq1NzJACgMblCK0fGcv9pKCG/KXU3AJRDGLqHLoIw==", + "requires": { + "passport-oauth2": "1.x.x" + } + }, "passport-google-oauth": { "version": "2.0.0", "resolved": "https://registry.npmjs.org/passport-google-oauth/-/passport-google-oauth-2.0.0.tgz", diff --git a/soa-web-app/node-server/package.json b/soa-web-app/node-server/package.json index 07633f1..adb7467 100644 --- a/soa-web-app/node-server/package.json +++ b/soa-web-app/node-server/package.json @@ -34,6 +34,7 @@ "@types/express": "^4.17.8", "@types/express-session": "^1.17.0", "@types/passport": "^1.0.4", + "@types/passport-github2": "^1.2.4", "@types/passport-google-oauth": "^1.0.41", "@types/request": "^2.48.5", "nodemon": "^2.0.6", @@ -54,6 +55,7 @@ "http": "0.0.1-security", "https": "^1.0.0", "passport": "^0.4.1", + "passport-github2": "^0.1.12", "passport-google-oauth": "^2.0.0", "request": "^2.88.2" } diff --git a/soa-web-app/node-server/src/app.ts b/soa-web-app/node-server/src/app.ts index b7aeb3c..87ed359 100644 --- a/soa-web-app/node-server/src/app.ts +++ b/soa-web-app/node-server/src/app.ts @@ -103,7 +103,7 @@ export class Application { clientID: Config.getInstance().auth.google.clientId, callbackURL: Config.getInstance().auth.google.callback, clientSecret: Config.getInstance().auth.google.clientSecret - }, function(token, refreshToken, profile, done){ + }, function(token:any, refreshToken:any, profile:any, done:any){ return done(null, { profile: profile, token: token, @@ -112,11 +112,11 @@ export class Application { })); // github oauth - Passport.use(new GitHubStrategy({ + Passport.use(new GitHubStrategy.Strategy({ clientID: Config.getInstance().auth.github.clientId, callbackURL: Config.getInstance().auth.github.callback, clientSecret: Config.getInstance().auth.github.clientSecret - }, function(token, refreshToken, profile, done) { + }, function(token:any, refreshToken:any, profile:any, done:any) { return done(null, { profile: profile, token: token, diff --git a/soa-web-app/node-server/src/config.ts b/soa-web-app/node-server/src/config.ts index bc9601d..75fca04 100644 --- a/soa-web-app/node-server/src/config.ts +++ b/soa-web-app/node-server/src/config.ts @@ -125,7 +125,7 @@ export class Config { if (typeof rawConfig === "object" && typeof rawConfig.auth === "object" && typeof rawConfig.auth.google === "object") { config.auth.google.clientId = rawConfig.auth.google.id; config.auth.google.callback = rawConfig.auth.google.callback; - config.auth.google.clientSecret = rawConfig.google.auth.secret; + config.auth.google.clientSecret = rawConfig.auth.google.secret; } // load github auth info