mirror of
https://github.com/jupyterhub/jupyterhub.git
synced 2025-10-15 14:03:02 +00:00
use JUPYTERHUB_API_TOKEN env in Spawner
to be more consistent with services deprecate JPY_API_TOKEN, but keep it around for compatibility
This commit is contained in:
@@ -228,11 +228,18 @@ class SingleUserNotebookApp(NotebookApp):
|
||||
super(SingleUserNotebookApp, self).start()
|
||||
|
||||
def init_hub_auth(self):
|
||||
if not os.environ.get('JPY_API_TOKEN'):
|
||||
self.exit("JPY_API_TOKEN env is required to run jupyterhub-singleuser. Did you launch it manually?")
|
||||
api_token = None
|
||||
if os.getenv('JPY_API_TOKEN'):
|
||||
# Deprecated env variable (as of 0.7.2)
|
||||
api_token = os.environ.pop('JPY_API_TOKEN')
|
||||
if os.getenv('JUPYTERHUB_API_TOKEN'):
|
||||
api_token = os.environ.pop('JUPYTERHUB_API_TOKEN')
|
||||
|
||||
if not api_token:
|
||||
self.exit("JUPYTERHUB_API_TOKEN env is required to run jupyterhub-singleuser. Did you launch it manually?")
|
||||
self.hub_auth = HubAuth(
|
||||
parent=self,
|
||||
api_token=os.environ.pop('JPY_API_TOKEN'),
|
||||
api_token=api_token,
|
||||
api_url=self.hub_api_url,
|
||||
)
|
||||
|
||||
|
@@ -190,7 +190,7 @@ class Spawner(LoggingConfigurable):
|
||||
Environment variables that end up in the single-user server's process come from 3 sources:
|
||||
- This `environment` configurable
|
||||
- The JupyterHub process' environment variables that are whitelisted in `env_keep`
|
||||
- Variables to establish contact between the single-user notebook and the hub (such as JPY_API_TOKEN)
|
||||
- Variables to establish contact between the single-user notebook and the hub (such as JUPYTERHUB_API_TOKEN)
|
||||
|
||||
The `enviornment` configurable should be set by JupyterHub administrators to add
|
||||
installation specific environment variables. It is a dict where the key is the name of the environment
|
||||
@@ -414,7 +414,9 @@ class Spawner(LoggingConfigurable):
|
||||
env[key] = value(self)
|
||||
else:
|
||||
env[key] = value
|
||||
|
||||
|
||||
env['JUPYTERHUB_API_TOKEN'] = self.api_token
|
||||
# deprecated (as of 0.7.2), for old versions of singleuser
|
||||
env['JPY_API_TOKEN'] = self.api_token
|
||||
|
||||
# Put in limit and guarantee info if they exist.
|
||||
|
Reference in New Issue
Block a user