diff --git a/src/common/interfaces/config.ts b/src/common/interfaces/config.ts index 34c8ef61..389d5eb4 100644 --- a/src/common/interfaces/config.ts +++ b/src/common/interfaces/config.ts @@ -19,7 +19,7 @@ export interface AuthConfig export interface HTTPConfig { - secure : boolean; + secure : string; port : number; } diff --git a/src/server/auth/google.ts b/src/server/auth/google.ts index d79f8185..6e1deab4 100644 --- a/src/server/auth/google.ts +++ b/src/server/auth/google.ts @@ -34,7 +34,7 @@ const config = serverConfig.auth.google; passport.use(new GoogleStrategy( { clientID: config.clientID, - clientSecret: config.clientID, + clientSecret: config.clientSecret, callbackURL, scope: [ 'profile', 'email' ], state: true @@ -99,7 +99,7 @@ export default { // Redirect app.get('/auth/google/redirect', passport.authenticate('google', { successReturnToOrRedirect: '/', - failureRedirect: '/' + failWithError: true })); // Get Current User diff --git a/src/server/server.ts b/src/server/server.ts index ac007c22..bc1a58f4 100644 --- a/src/server/server.ts +++ b/src/server/server.ts @@ -114,17 +114,19 @@ async function main() : Promise<{ app : Express, sio : any, server : any }> app.use(requestLogger(logger) as RequestHandler); // Auth support - app.use(cookieParser()); // lgtm [js/missing-token-validation] + app.use(cookieParser()); app.use(bodyParser.json()); - app.use(session({ // lgtm [js/missing-token-validation] + const httpSecureCookie = config.http.secure.toLowerCase() === 'true'; + + app.use(session({ secret: config.secret, key: config.key, resave: false, store, // maxAge = 7 days - cookie: { maxAge: 7 * 24 * 60 * 60 * 1000, secure: config.http.secure }, + cookie: { maxAge: 7 * 24 * 60 * 60 * 1000, secure: httpSecureCookie }, saveUninitialized: false }));