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

Set secure cookie by default if login handler is hit. #22

Merged
merged 1 commit into from
Apr 17, 2015

Conversation

Carreau
Copy link
Member

@Carreau Carreau commented Apr 16, 2015

There is few chances that logged-in people do not use https connexion,
but I guess it can happened if the server is ran in front of a proxy
that does the https termination, so leave it configurable.

closes ipython/ipython#8325

@minrk minrk added this to the 4.0 milestone Apr 16, 2015

class LoginHandler(IPythonHandler):
"""The basic tornado login handler

authenticates with a hashed password from the configuration.
"""

secure_cookie = Bool(default_value=True, help="""set login cookie "secure" flag, so it will"""
Copy link
Member

Choose a reason for hiding this comment

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

handlers don't have traits

@Carreau
Copy link
Member Author

Carreau commented Apr 16, 2015

used settings.get, fallback on request protocol if not set.

@@ -37,7 +37,8 @@ def post(self):
typed_password = self.get_argument('password', default=u'')
if self.login_available(self.settings):
if passwd_check(self.hashed_password, typed_password):
self.set_secure_cookie(self.cookie_name, str(uuid.uuid4()))
self.set_secure_cookie(self.cookie_name, str(uuid.uuid4()),
secure=self.settings.get('secure_cookie', (self.request.protocol == 'https'))
Copy link
Member

Choose a reason for hiding this comment

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

as discovered on JupyterHub, secure=False doesn't actually work. The secure kwarg can only be specified when it should be True (a bug in Tornado, fixed in 4.2)

There is few chances that logged-in people do not use https connexion,
but I guess it can happened if the server is ran in front of a proxy
that does the https termination, so leave it configurable.

closes ipython/ipython#8325
minrk added a commit that referenced this pull request Apr 17, 2015
Set secure cookie by default if login handler is hit.
@minrk minrk merged commit b59150f into jupyter:master Apr 17, 2015
@Carreau
Copy link
Member Author

Carreau commented Apr 17, 2015

shoudl I mark that as backport ?

@minrk
Copy link
Member

minrk commented Apr 17, 2015

I don't think it's useful to mark for backport, since we can't backport automatically anymore. It probably makes sense to open a PR against 3.x, though.

Carreau added a commit to Carreau/ipython that referenced this pull request Apr 17, 2015
    backport of jupyter/notebook#22 b8e99bc

>   There is few chances that logged-in people do not use https connexion,
>   but I guess it can happened if the server is ran in front of a proxy
>   that does the https termination, so leave it configurable.
>
>   closes ipython#8325
@Carreau Carreau deleted the secure-cookie branch April 17, 2015 20:19
bollwyvl pushed a commit to bollwyvl/notebook that referenced this pull request Mar 21, 2016
use import_item to allow any module to provide an nbextension
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Apr 28, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Security issue: Missing Secure Attribute in Encrypted Session (SSL) Cookie
2 participants