On Wed, Nov 16, 2016 at 9:32 PM, Joshua Dunham <[email protected]>
wrote:
Hi Jupyters,
>
> I'm working through setting up JupyterHub and am trying to think
> through how to provide a few group of people access to a single hub. Some
> questions:
>
> - I've noticed that {username} is a variable I can use in some capacity
> (like directing the user to a specific path), Can I do the same with a
> group variable? My plan is to keep the config file sparse in terms of
> allowed users and instead start the server and populate the database. The
> API shows that users can be a part of groups but I can't find how I can use
> this (if at all). I can populate the database with a Jupyter service if
> this variable is useable in the config.
>
Group’s tricky, because a user can be in multiple groups. But if you assume
that you only put users in one group, then you can accomplish this. An
powerful but oft-overlooked tool is that you can have fully custom logic
for paths and things by implementing tiny subclasses in your config file:
# jupyterhub_config.py
from jupyterhub.spawner import LocalProcessSpawner
class MySpawner(LocalProcessSpawner):
def template_namespace(self):
# add the user's first group as 'group' in the template namespace
ns = super().template_namespace()
ns['group'] = self.user.groups[0]
c.MySpawner.notebook_dir = '/shared/{group}/{username}'
> - The API on swagger shows that there is a way to get a username based on
> API key, is there a way to set a user's api key using the API? I'd like to
> inject a JWT 'key' that allows access to external systems. If possible, how
> could a user call this key in their notebook? Another option is to get a
> token using the authenticator but I'm not sure how I could store this for
> the duration of the token lifetime.
>
The API key is a key for accessing JupyterHub itself, not for accessing
external systems. Do you want to inject environment variables into the
user’s server? You can do this with Authenticator.pre_spawn_start
<http://jupyterhub.readthedocs.io/en/latest/api/auth.html?highlight=pre_spawn_start#jupyterhub.auth.Authenticator.pre_spawn_start>,
or augmenting Spawner.environment, depending on where the token comes from.
> - The HTML form in the config seems like it could be useful to spawn a
> specific docker container for a user. Is this possible?
>
Yes! imagespawner <https://github.com/ryanlovett/imagespawner> is an
example of using this form to allow users to pick from a list of supported
docker images.
-Min
>
> Thanks for your help and patience!
>
> -Joshua
>
> --
> 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/2884f464-ae46-4996-bb84-312cddc69743%40googlegroups.com
> <https://groups.google.com/d/msgid/jupyter/2884f464-ae46-4996-bb84-312cddc69743%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/CAHNn8BW9dJb-WhF69ccaj0zM0amYCF7OzYEZzjOZvSNRrtqcog%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.