diff --git a/.env b/.env index 2baa7d1..ae35736 100755 --- a/.env +++ b/.env @@ -33,14 +33,9 @@ DOCKER_NOTEBOOK_DIR=/home/jovyan/work # DO NOT CHANGE THIS. It is how the docker-stacks notebooks launch the single-user servers. DOCKER_SPAWN_CMD=start-singleuser.sh -# Name of JupyterHub container data volume -#DATA_VOLUME_HOST=stathub-data -# Data volume container mount point -#DATA_VOLUME_CONTAINER=/data - -# Name of JupyterHub postgres database data volume -#DB_VOLUME_HOST=stathub-db-data - -# The name of the postgres database containing JupyterHub state -#POSTGRES_DB=stathub +# provide at least one user from `userlist` so that `make login` can show you the associated password +# (useful when changing secret keys or creating hub for the first time) +# afterwards, you can visit /hub/login_list (if enabled and you are an admin) to see everyone's passwords. +USERNAME=default +PASSWORD_LENGTH=6 diff --git a/Makefile b/Makefile index 1842584..ec6ac77 100755 --- a/Makefile +++ b/Makefile @@ -2,6 +2,7 @@ # Distributed under the terms of the Modified BSD License. include .env +include secrets/oauth.env .DEFAULT_GOAL=build @@ -17,8 +18,11 @@ secrets/postgres.env: @echo "POSTGRES_PASSWORD=$(shell openssl rand -hex 32)" > $@ secrets/oauth.env: - @echo "Need oauth.env file in secrets with GitHub parameters" - @exit 1 + @echo "Generating postgres password in $@" + @echo "HASH_SECRET_KEY=$(shell openssl rand -hex 32)" > $@ + +login: + @docker run $(HUB_NAME) hashauthpw --length $(PASSWORD_LENGTH) $(USERNAME) $(HASH_SECRET_KEY) secrets/jupyterhub.crt: @echo "Need an SSL certificate in secrets/jupyterhub.crt" diff --git a/docker-compose.yml b/docker-compose.yml index c3decee..980f42c 100755 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -41,17 +41,18 @@ services: links: - hub-db environment: - HUB_NAME: ${HUB_NAME} + #HUB_NAME: ${HUB_NAME} # Notebook directory inside user image - DOCKER_NOTEBOOK_DIR: ${DOCKER_NOTEBOOK_DIR} + #DOCKER_NOTEBOOK_DIR: ${DOCKER_NOTEBOOK_DIR} # Using this run command (optional) - DOCKER_SPAWN_CMD: ${DOCKER_SPAWN_CMD} + #DOCKER_SPAWN_CMD: ${DOCKER_SPAWN_CMD} # Postgres db info POSTGRES_DB: ${HUB_NAME} POSTGRES_HOST: hub-db env_file: - secrets/postgres.env - secrets/oauth.env + - .env command: > jupyterhub -f /srv/jupyterhub/jupyterhub_config.py diff --git a/jupyterhub_config.py b/jupyterhub_config.py index 5a08e38..f5f3f74 100755 --- a/jupyterhub_config.py +++ b/jupyterhub_config.py @@ -92,7 +92,7 @@ c.JupyterHub.authenticator_class = 'hashauthenticator.HashAuthenticator' # You can generate a good "secret key" by running `openssl rand -hex 32` in terminal. # it is recommended to do this from time-to-time to change passwords (including changing their length) c.HashAuthenticator.secret_key = os.environ['HASH_SECRET_KEY'] # Defaults to '' -c.HashAuthenticator.password_length = 6 # Defaults to 6 +c.HashAuthenticator.password_length = int(os.environ['PASSWORD_LENGTH']) # Defaults to 6 # Can find your password by looking at `hashauthpw --length 10 [username] [key]` # If the `show_logins` option is set to `True`, a CSV file containing #login names and passwords will be served (to admins only) at `/hub/login_list`.