-
Notifications
You must be signed in to change notification settings - Fork 86
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
Made the www-frame-origin for rserver environment-configurable #148
Conversation
…SERVER_TIMEOUT, RSESSION_TIMEOUT
Add configuration information
Thanks for submitting your first pull request! You are awesome! 🤗 |
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.
Preferring environment variables instead of traitlets is totally fine. It also makes sense given that we're currently not putting in traitlets
directly. Also, thanks for documenting the environment variables in the README!
I think I prefer to have the value retrieval happen in separate functions, akin to _get_timeout(), rather than a single get_env_value function for all variables. Perhaps this is just a style choice, although using separate functions would allow us to one day pivot to using traitlets' default decorator.
I'm wondering whether the environment variable names should indicate the jupyter-rsession-proxy context in some way. e.g. JUPYTER_RSESSION_PROXY_FOO
, instead of just FOO
. This helps to clarify that the variables are not consumed by the actual rsession or rserver binaries. The downside is that variables are kind of long:
JUPYTER_RSESSION_PROXY_WWW_FRAME_ORIGIN
JUPYTER_RSESSION_PROXY_RSERVER_TIMEOUT
We'd also need to communicate this if we were to change an existing env var.
This issue inspired me to create #149.
Lastly, it looks like you accidentally included jupyter_rsession_proxy.egg-info and its contents.
If what I wrote isn't clear, or if you'd just prefer, I think I can modify the PR to reflect the above.
@ryanlovett The only reason I would do this is to learn how, but I think I already know and you doing it saves us a loop. Sold, with (as always) thanks!
Please go ahead and make all those changes. Thanks again for everything |
@rickmcgeer Is the setting to allow edits from maintainers enabled in your fork's PR? I don't think I can edit the PR otherwise. (I've tried and failed, but I could be doing something wrong.) Alternatively, I can make a new PR and pull in your changes. |
@ryanlovett my apologies; I don't know. The doc you referenced says "On user-owned forks, if you want to allow anyone with push access to the upstream repository to make changes to your pull request, select Allow edits from maintainers.". I've been unable to find the screen with the field "Allow edits from maintainers" (as with many infrastructures, Github has a security/permissions system designed by Franz Kafka and administered by the DMV and the City of Dis as told by Niven and Pournelle in Inferno). Anyway, I made you an admin of our repo, so I hope that's enough. Sorry for the trouble,... |
@rickmcgeer :) "It was on display in the bottom of a locked filing cabinet stuck in a disused lavatory with a sign on the door saying 'Beware of the Leopard.'" Its no trouble, thanks! I think this should be sufficient. |
With this PR, I've confirmed that setting I didn't change the other env vars as part of this PR to avoid breaking things for others. That can be done separately in an announced change. |
Thanks @rickmcgeer ! |
Thanks @ryanlovett ! It was a real pleasure to work with you and I hope to do so again soon. |
Absolutely @rickmcgeer ! We'd be happy to receive more code contributions. :) |
@ryanlovett Happy to contribute! On that note, should we enhance the Shiny proxy the same way? |
This is the proposed solution to: #147. Configuration by traitlets, as proposed in the issue, is inappropriate since the command to set up the rserver and rsession is invoked when the package is loaded, so any configuration has to be present in the environment when the package is loaded. Adding configuration by environment variables is consistent with the existing package architecture, and in fact it was done (hardcoded) in
setup_rserver._get_timeout
andsetup_rsession._get_timeout
.Changes made:
get_env_value(env_var_name)
to get the value for the given environment variable. Defaults are provided for configurable environment variables.RSERVER_FRAME_ORIGIN
environment variable to makewww-frame-origin
environment-configurable. The default value is the same as the current hard-coded value.RSERVER_TIMEOUT
environment variable and replacedsetup_rserver._get_timeout()
withget_env_value('RSERVER_TIMEOUT')
. Default is the same as the current hardcoded default (15)RSESSION_TIMEOUT
environment variable and replacedsetup_rsession._get_timeout()
withget_env_value('RSESSION_TIMEOUT')
. Default is the same as the current hardcoded default (15)user = os.environ.get('NB_USER', getpass.getuser())
withget_env_value('NB_USER')
. Default forNB_USER
isgetpass.get_user()