added some utilty functions for passwords into makefile.

This commit is contained in:
mathematicalmichael 2019-01-11 11:26:26 -07:00
parent 389d934f40
commit 2623ec044d
4 changed files with 16 additions and 16 deletions

15
.env
View File

@ -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

View File

@ -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"

View File

@ -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

View File

@ -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`.