fastify / fastify/session

Questioning the plugin responsibility on checking secure connection

Open
#272 4 comments 5 reactions 0 assignees View on GitHub
Dominant language
JavaScript
Stars
130
Forks
58
PR merge metrics
No merged PRs in 30d

Description

### Prerequisites

- [X] I have written a descriptive issue title
- [X] I have searched existing issues to ensure the issue has not already been raised

### Issue

Hello,

I'm questioning the relevance of checking whether the connection is secure before responding with a `secure` session cookie, [as done here](https://github.com/fastify/session/blob/4ad874e6b2bcd65ead6b44ae35e3c8abfe66a8cc/lib/fastifySession.js#L170-L171).

To my understanding, this is not the responsibility of the server to choose whether a secure cookie should be sent or not. It is **the browser** that own the responsibility of using cookies according to their policies. Hence, the cookie should always be set to the response, even though the subsequent unsecure connections cannot use the cookie. Am I missing something ?

References:
- https://developer.mozilla.org/en-US/docs/Web/HTTP/Cookies#block_access_to_your_cookies
- https://security.stackexchange.com/questions/251675/should-the-server-send-secure-cookies-on-unsecured-http-response

Best regards

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.