-
Notifications
You must be signed in to change notification settings - Fork 33
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
adding 'auto' to secure attribute #86
Conversation
Suggestion: See https://github.com/expressjs/session The cookie.secure option can also be set to the special value 'auto' to have this setting automatically match the determined security of the connection. Be careful when using this setting if the site is available both as HTTP and HTTPS, as once the cookie is set on HTTPS, it will no longer be visible over HTTP. This is useful when the Express "trust proxy" setting is properly setup to simplify development vs production configuration. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
I think this is a good idea. @zekth What do you think? |
I agree. I will change to it. This just add polymorphism that's why i added another attribute but as long as you're ok with it i'll do it. |
ready for review @SerayaEryn . I'm not sure about the Documentation. Maybe @williamzhao87 can review it as you're english native speaking. |
Documentation looks fine to me. Thanks for the update! |
lib/fastifySession.js
Outdated
@@ -89,7 +89,7 @@ function onSend (options) { | |||
reply.setCookie( | |||
options.cookieName, | |||
session.encryptedSessionId, | |||
session.cookie.options() | |||
session.cookie.options(getRequestProto(request)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we should also do some other checks besides just the X-Forwarded-Proto
header, if possible:
See the issecure function in express-session:
https://github.com/expressjs/session/blob/b22384b712fea118f1c3eb5b0d79312ebd25e97c/index.js#L612
We may also want a way to check a custom header in the case that X-Forwarded-Proto
header is overwritten by some ELBs such as AWS ALB)
Can we add another option?
cookie.secureAutoHeader
e.g. If cookie.secureAutoHeader
= X-Forwarded-Scheme
, instead of checking X-Forwarded-Proto
header, we will check the header X-Forwarded-Scheme
instead to determine the value for secure
when set to auto
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Adding secureAutoHeader is too custom here. A solution for that would be to add a function for the auto behavior but it's out of scope here IMO
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Okay that's fine, thanks
@SerayaEryn I've fixed a case regarding secure : |
Should we update the possibility of |
Nice catch tho. |
Thanks for your contribution. |
Fix #84
secureAuto will set the
Secure
flag regarding the protocol used for the request. I'd prefer to add another attribute to not arm the current behaviour.