Skip to content

Commit

Permalink
more auth fixes.
Browse files Browse the repository at this point in the history
  • Loading branch information
Morgul committed Aug 20, 2023
1 parent ac5041a commit 7ea7d68
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 6 deletions.
2 changes: 1 addition & 1 deletion src/common/interfaces/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ export interface AuthConfig

export interface HTTPConfig
{
secure : boolean;
secure : string;
port : number;
}

Expand Down
4 changes: 2 additions & 2 deletions src/server/auth/google.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -99,7 +99,7 @@ export default {
// Redirect
app.get('/auth/google/redirect', passport.authenticate('google', {
successReturnToOrRedirect: '/',
failureRedirect: '/'
failWithError: true
}));

// Get Current User
Expand Down
8 changes: 5 additions & 3 deletions src/server/server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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
}));

Expand Down

0 comments on commit 7ea7d68

Please sign in to comment.