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

register contents_manager.files_handler_class directly #2917

Merged
merged 1 commit into from Oct 11, 2017

Conversation

@minrk
Copy link
Member

@minrk minrk commented Oct 10, 2017

rather than trying to call one handler from another, which is unreliable and can cause misbehavior.

closes jupyter/jupyter#292

Normally used when ContentsManager is not a FileContentsManager.
FileContentsManager subclasses use AuthenticatedFilesManager by default,
a subclass of StaticFileManager.
Copy link
Member

@takluyver takluyver Oct 10, 2017

Choose a reason for hiding this comment

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

"AuthenticatedFilesManager" and "StaticFileManager" should be "...Handler", I think?

Loading

Copy link
Member Author

@minrk minrk Oct 11, 2017

Choose a reason for hiding this comment

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

I got Managers on the mind. Fixed.

Loading

@@ -299,7 +299,8 @@ def init_handlers(self, settings):
handlers.extend(load_handlers('services.kernelspecs.handlers'))
handlers.extend(load_handlers('services.security.handlers'))
handlers.extend(load_handlers('services.shutdown'))

handlers.extend(settings['contents_manager'].get_extra_handlers())
Copy link
Member

@takluyver takluyver Oct 10, 2017

Choose a reason for hiding this comment

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

This is being added after the default files handler (the one which uses the contents manager). Doesn't that mean that this one (using static files) will never actually be used?

Loading

Copy link
Member Author

@minrk minrk Oct 11, 2017

Choose a reason for hiding this comment

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

I removed the global registration of the default files handler here, so this is where it gets registered, whichever class it is. On the base ContentsManager, it will be the generic FilesHandler, but on FileContentsManager subclasses it will be AuthenticatedFileHandler.

Loading

Copy link
Member Author

@minrk minrk Oct 11, 2017

Choose a reason for hiding this comment

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

The relevant change below is that the base ContentsManager has files_handler_class = FilesHandler by default, so get_extra_handlers always returns something unless a ContentsManager explicitly overrides files_handler_class = None, in which case the /files/ endpoint is disabled.

Loading

Copy link
Member

@takluyver takluyver Oct 11, 2017

Choose a reason for hiding this comment

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

Got it, thanks.

Loading

@takluyver takluyver added this to the 5.2 milestone Oct 10, 2017
@ebraminio
Copy link
Contributor

@ebraminio ebraminio commented Oct 10, 2017

Thank you @minrk, just for the sake of curiosity, do you know why this could cause more issue on Safari? Thanks

Loading

rather than trying to call one handler from another,
which is unreliable and can cause misbehavior.
@minrk minrk force-pushed the fix-auth-file-handler branch from 618b99e to a69ddb6 Oct 11, 2017
@minrk
Copy link
Member Author

@minrk minrk commented Oct 11, 2017

@ebraminio I have no idea why I can only reproduce this in Safari. My guess is that it's a coincidence of how it implements fetching and/or caching of requests that makes it more likely to trigger.

Loading

@@ -299,7 +299,8 @@ def init_handlers(self, settings):
handlers.extend(load_handlers('services.kernelspecs.handlers'))
handlers.extend(load_handlers('services.security.handlers'))
handlers.extend(load_handlers('services.shutdown'))

handlers.extend(settings['contents_manager'].get_extra_handlers())
Copy link
Member

@takluyver takluyver Oct 11, 2017

Choose a reason for hiding this comment

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

Got it, thanks.

Loading

@takluyver takluyver merged commit dd8b695 into jupyter:master Oct 11, 2017
4 checks passed
Loading
@ebraminio
Copy link
Contributor

@ebraminio ebraminio commented Oct 11, 2017

Confirmed the fix, thanks!

Loading

@minrk minrk deleted the fix-auth-file-handler branch Oct 13, 2017
@gnestor gnestor removed this from the 5.2 milestone Oct 13, 2017
@gnestor gnestor added this to the 5.2 milestone Oct 13, 2017
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Apr 4, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Linked issues

Successfully merging this pull request may close these issues.

4 participants