I don't recall if you can get a user name from JS Web APIs, but if you can, you should be able to pass it to the kernel using a comm
On Aug 11, 2016 6:29 AM, "MinRK" <[email protected]> wrote: On Tue, Aug 9, 2016 at 4:55 PM, Paul A <[email protected]> wrote: > Sorry, the question was about retrieving the username of the *client* > connection to the notebook. > > The server-side username can be easily returned as: > > username = jupyter_client.session.Session().msg_header('')['username'] > The browser never communicates directly with the kernel. All communication is mediated through the server. The server has access to HTTP headers, etc. It could use this information when starting a kernel to define an environment variable, for instance, when starting the kernel. This could also be done more simply on notebook-server startup, since the server is presumably launched for a given user. -Min > > > On Tuesday, August 9, 2016 at 2:29:46 PM UTC+1, Min RK wrote: >> >> Since the kernel is a different process from the server, objects in the >> server are not available to the kernels. Environment variables can be used >> to share little bits of information throughout the server and kernels, e.g. >> >> export MY_USERNAME='something' >> jupyter notebook >> >> in which case the MY_USERNAME env will be available to the server and all >> of its kernel subprocesses. If the server doesn’t know its name until some >> time later, you can modify how kernels are started, to pass this >> environment variable on each kernel launch. >> >> -MinRK >> >> >> On Tue, Aug 9, 2016 at 2:19 PM, Paul A <[email protected]> wrote: >> >>> Hi all, I have a user id passed via HttpContext, so in principle the >>> notebook should know who is connecting. I know this is not secure, but >>> should work for "Hey {}".format(context['username']. >>> >>> How can I get access to that HttpContext instance? >>> >>> -- >>> You received this message because you are subscribed to the Google >>> Groups "Project Jupyter" group. >>> To unsubscribe from this group and stop receiving emails from it, send >>> an email to [email protected]. >>> To post to this group, send email to [email protected]. >>> To view this discussion on the web visit https://groups.google.com/d/ms >>> gid/jupyter/45b3039b-41d8-464c-a041-81a108fc8450%40googlegroups.com >>> <https://groups.google.com/d/msgid/jupyter/45b3039b-41d8-464c-a041-81a108fc8450%40googlegroups.com?utm_medium=email&utm_source=footer> >>> . >>> For more options, visit https://groups.google.com/d/optout. >>> >> >> -- > You received this message because you are subscribed to the Google Groups > "Project Jupyter" group. > To unsubscribe from this group and stop receiving emails from it, send an > email to [email protected]. > To post to this group, send email to [email protected]. > To view this discussion on the web visit https://groups.google.com/d/ms > gid/jupyter/fe856710-a5fb-4a4b-9cc7-2dc11778b368%40googlegroups.com > <https://groups.google.com/d/msgid/jupyter/fe856710-a5fb-4a4b-9cc7-2dc11778b368%40googlegroups.com?utm_medium=email&utm_source=footer> > . > > For more options, visit https://groups.google.com/d/optout. > -- You received this message because you are subscribed to the Google Groups "Project Jupyter" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. To post to this group, send email to [email protected]. To view this discussion on the web visit https://groups.google.com/d/ msgid/jupyter/CAHNn8BWPzs4oPQ6utOSB54wEbJGGs%2Bz%3DLGkdE6AXF5hF2pwXmA% 40mail.gmail.com <https://groups.google.com/d/msgid/jupyter/CAHNn8BWPzs4oPQ6utOSB54wEbJGGs%2Bz%3DLGkdE6AXF5hF2pwXmA%40mail.gmail.com?utm_medium=email&utm_source=footer> . For more options, visit https://groups.google.com/d/optout. -- You received this message because you are subscribed to the Google Groups "Project Jupyter" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. To post to this group, send email to [email protected]. To view this discussion on the web visit https://groups.google.com/d/msgid/jupyter/CAAoBLw3QBvH%3DVoeUWFswVmOUXf9CXvhvBOOx0_sUyZRsOngZYg%40mail.gmail.com. For more options, visit https://groups.google.com/d/optout.
