Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adding a way to bypass the notebook token. #18

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,7 @@ ADD https://github.com/krallin/tini/releases/download/${TINI_VERSION}/tini /tini
ADD https://github.com/krallin/tini/releases/download/${TINI_VERSION}/tini.asc /tini.asc
RUN gpg --keyserver ha.pool.sks-keyservers.net --recv-keys 0527A9B7 && gpg --verify /tini.asc
ADD start.sh /start.sh
ADD ready.sh /ready.sh

RUN chmod +x /tini /start.sh

Expand All @@ -88,4 +89,4 @@ WORKDIR /notebooks

ENTRYPOINT ["/tini", "--"]

CMD ["/entrypoint", "/start.sh"]
CMD ["/entrypoint", "/start.sh"]
7 changes: 4 additions & 3 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,11 @@ clean:
docker rmi -f $(LOCAL_IMAGE)

run:
docker run -p 8888:8888 -e JUPYTER_NOTEBOOK_PASSWORD=developer $(USER)/base-notebook
docker run -ti --rm -p 8888:8888 -e JUPYTER_NOTEBOOK_DISABLE_TOKEN=true $(USER)/base-notebook

test:
docker run -d --name test-base-notebook -p 8888:8888 -e JUPYTER_NOTEBOOK_PASSWORD=developer $(USER)/base-notebook
-docker rm -f test-base-notebook || true
docker run -d --name test-base-notebook -p 8888:8888 -e JUPYTER_NOTEBOOK_DISABLE_TOKEN=true $(USER)/base-notebook
sleep $(WAIT_TIME)
./ready.sh && echo "Test completed successfully!"
docker rm -f test-base-notebook
-docker rm -f test-base-notebook || true
16 changes: 14 additions & 2 deletions ready.sh
Original file line number Diff line number Diff line change
@@ -1,6 +1,18 @@
#!/usr/bin/env bash

http_code=`curl -s -o /dev/null -w "%{http_code}" http://localhost:8888/api`
[[ "$http_code" -lt "200" || "$http_code" -gt "299" ]] && exit 1
checkUrl() {
[[ $# -lt 1 ]] && echo "usage: checkUrl <url>" && return
echo $1
http_code=`curl -s -o /dev/null -w "%{http_code}" $1`
[[ "$http_code" -lt "200" || "$http_code" -gt "299" ]] && exit 1
}

# this endpoint should be reachable even without auth
checkUrl "http://localhost:8888/api"

# check this endpoint if the authN is completely disabled
if [[ "$JUPYTER_NOTEBOOK_DISABLE_TOKEN" == "true" && -z "$JUPYTER_NOTEBOOK_PASSWORD" ]]; then
checkUrl "http://localhost:8888/tree"
fi

exit 0
4 changes: 4 additions & 0 deletions start.sh
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,10 @@ if [[ "x$JUPYTER_NOTEBOOK_PASSWORD" != "x" ]]; then
echo "c.NotebookApp.password = u'$HASH'" >> /home/$NB_USER/.jupyter/jupyter_notebook_config.py
fi

if [[ "$JUPYTER_NOTEBOOK_DISABLE_TOKEN" == "true" ]]; then
echo "c.NotebookApp.token = ''" >> /home/$NB_USER/.jupyter/jupyter_notebook_config.py
fi

if [[ -n "$JUPYTER_NOTEBOOK_X_INCLUDE" ]]; then
curl -O $JUPYTER_NOTEBOOK_X_INCLUDE
fi
Expand Down