Skip to content
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

Make cookie secure if used over https #231

Merged
merged 1 commit into from
Apr 17, 2015

Conversation

Carreau
Copy link
Member

@Carreau Carreau commented Apr 16, 2015

No description provided.

@@ -165,7 +166,9 @@ def set_hub_cookie(self, user):
self.set_secure_cookie(
self.hub.server.cookie_name,
user.cookie_id,
path=self.hub.server.base_url)
path=self.hub.server.base_url,
secure=(self.request.protocol == 'https')
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What happens if this is set to true when running over unencrypted HTTP?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It effectively negates setting the cookie at all. The browser will receive the cookie, see that it should only be sent over https, and then refuse to send it back to the server on any future request.

@minrk
Copy link
Member

minrk commented Apr 16, 2015

apparently setting secure=False effectively sets secure=True on tornado < 4.2 (4.1 is latest stable). So need to do a **kwargs approach:

kwargs = {}
if self.request.protocol == 'https':
    kwargs['secure'] = True
self.set_secure_cookie(
    ...,
    **kwargs
)

minrk added a commit that referenced this pull request Apr 17, 2015
Make cookie secure if used over https
@minrk minrk merged commit 6b32a5c into jupyterhub:master Apr 17, 2015
@Carreau Carreau deleted the secure-cookie branch July 21, 2017 22:56
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants