jupyterhub / tmpauthenticator

JupyterHub authenticator that hands out temporary accounts for everyone. For use in tmpnb.org
BSD 3-Clause "New" or "Revised" License
22 stars 18 forks source link

route to different images #16

Closed rodriguez-facundo closed 1 year ago

rodriguez-facundo commented 5 years ago

Hi, I wanted to spawn different images without authentication/forms, so I implemented something like this:

        request = self.request.uri

        if request == '/hub/app1':
            image = "app1:latest"
        elif request == '/hub/app2':
            image = "app2:latest"
        else:
            image = user.spawners[''].image_spec

        user.spawners[''].image_spec = image
  def get_handlers(self, app):
        # FIXME: How to do this better?
        extra_settings = {
            'force_new_server': self.force_new_server,
            'process_user': self.process_user
        }
        return [
            ('/app1', TmpAuthenticateHandler, extra_settings),
            ('/app2', TmpAuthenticateHandler, extra_settings)
        ]

With a little bit of work, I could convert the above code into something more useful: Maybe something along these lines?

c.tmpauthenticator.spawners = {
    "app1":  "app1:latest",
    "app2":  "app2:lates"
}
consideRatio commented 1 year ago

This is a very late response, but I think if you wanted to spawn with different configurations without authentication (using this authenticator), and without using forms, then I presume you wanted to use query parameters to configure your spawn options.

This can be done, but is out of scope for the JupyterHub configured Authenticator. I think the spawner can be configured to handle this though via hooks and such. I don't have clear details about this for you, but if someone wants to ask for help about that raise a question at discourse.jupyter.org.