Skip to content

Commit

Permalink
fix: secure cookie configs.
Browse files Browse the repository at this point in the history
  • Loading branch information
morganney committed Dec 14, 2023
1 parent 38b72e3 commit 6463699
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 1 deletion.
8 changes: 8 additions & 0 deletions packages/api/src/handlers/authn.ts
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,14 @@ const authn = {
expires: req.session.cookie.expires
}

/**
* Doesn't seem necessary atm since the session
* is currently being saved to the store at the
* end of the HTTP response, however, consider
* using `req.session.regenerate` and `req.session.save`
* as exemplified in the documentation:
* @see https://www.npmjs.com/package/express-session#user-login
*/
debug('setting user to session', sessUser)
req.session.user = sessUser
debug('setting session user ID', user.id)
Expand Down
1 change: 1 addition & 0 deletions packages/api/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ const sess: SessionOptions = {
resave: false,
saveUninitialized: false,
unset: 'destroy',
proxy: true,
cookie: {
maxAge: SESSION_DURATION_MS,
httpOnly: true,
Expand Down
2 changes: 1 addition & 1 deletion packages/web/certs/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

1. Install [mkcert](https://github.com/FiloSottile/mkcert#installation).
2. `mkcert -install`.
3. `mkcert busmap.localhost`.
3. `mkcert -key-file busmap.localhost-key.pem -cert-file busmap.localhost.pem busmap.localhost localhost`.

That should install a CA in your OS trust store and produce two files:

Expand Down
1 change: 1 addition & 0 deletions packages/web/templates/default.conf.template
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ server {
proxy_pass http://api_server;
# Allow keepalive to work with the upstream
proxy_http_version 1.1;
proxy_set_header X-Forwarded-Proto $scheme;
proxy_set_header Connection "";
}

Expand Down

0 comments on commit 6463699

Please sign in to comment.