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

multiple entries or wildcards in allow_origin #24

Closed
havok2063 opened this issue Oct 15, 2021 · 4 comments
Closed

multiple entries or wildcards in allow_origin #24

havok2063 opened this issue Oct 15, 2021 · 4 comments

Comments

@havok2063
Copy link

Does the Voila.tornado_settings allow_origin key allow multiple entries, or wildcards? In order to use the cookie passing feature, we set "allow_credentials": "true" but with that, we can no longer use a general wildcard in allow_origin: "*". Does voila allow passing a list of allowed domains? or is there a syntax for specifying all subdomains. e.g. *.stsci.edu? I couldn't find anything in the Jupyter server documentation.

@mariobuikhuizen
Copy link
Owner

I found allow_origin_pat in jupyter_server: https://github.com/jupyter-server/jupyter_server/blob/1a6a481acb43c34fee201cab80774ab69eab5bb6/jupyter_server/base/handlers.py#L297

But it seems to have a bug, which is fixed by:

diff --git a/jupyter_server/base/handlers.py b/jupyter_server/base/handlers.py
index 60d0e5fea..81bf7b36b 100644
--- a/jupyter_server/base/handlers.py
+++ b/jupyter_server/base/handlers.py
@@ -295,7 +295,8 @@ class JupyterHandler(AuthenticatedHandler):
     @property
     def allow_origin_pat(self):
         """Regular expression version of allow_origin"""
-        return self.settings.get("allow_origin_pat", None)
+        pat_str = self.settings.get("allow_origin_pat", None)
+        return re.compile(pat_str) if pat_str else None
​
     @property
     def allow_credentials(self):

I can make a PR for this.

After that, you should be able to use 'allow_origin_pat': 'http[s]?:\/\/.+\.stsci\.edu'

@havok2063
Copy link
Author

Oh cool. I completely missed the allow_origin_pat config setting. That should do it.

@havok2063
Copy link
Author

@mariobuikhuizen Any update on the PR fix for this?

@havok2063
Copy link
Author

I think this is now fixed.

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

No branches or pull requests

2 participants