-
Notifications
You must be signed in to change notification settings - Fork 4.7k
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
Conversation
|
||
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""" |
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.
handlers don't have traits
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')) |
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.
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
Set secure cookie by default if login handler is hit.
shoudl I mark that as backport ? |
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. |
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
use import_item to allow any module to provide an nbextension
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