Fix handling of preflight requests #1325
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Hi,
I believe I've found a bug in the way that OPTIONS requests are handled by the notebook server. Pre-flighted OPTIONS requests do not include authentication information, which means that we should not expect these to be authenticated and so should not be using the @web.authenticated decorator. Authentication will be validated when the real PUT/POST etc request is issued after the preflight.
FWIW this behaviour is documented by others in different contexts (see for example: http://giix.nl/2015/03/10/cross-origin-resource-sharing-cors-and-kerberos-webserver-auth/).
Thanks,
Carl
P.S. to provide some context, in our environment, we use Kerberos for authenticating against the notebook server to provide single sign-on, and we're working on developing a tool that uses jupyter-js-services to programatically launch kernels via the notebook server and run commands on them. This mostly works great except when the js-services API initiates a POST request with content-type of application/json. The CORS specification dictates that these requests must be pre-flighted, and because the pre-flighted OPTIONS request does not include authenticating material it gets rejected.