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

Added JWT auth + /pyewatercycle endpoint #29

Open
wants to merge 28 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
28 commits
Select commit Hold shift + click to select a range
914a2bb
Add /pyewatercycle endpoint
sverhoeven Aug 27, 2021
5f72e37
Stuff
sverhoeven Aug 27, 2021
5e8c133
Use latest pytest
sverhoeven Aug 27, 2021
06ca45c
Typos
sverhoeven Aug 27, 2021
302d42f
More tests
sverhoeven Aug 27, 2021
431299b
Removed out of date endpoints: assessment, bmi, opendap, threeclicksc…
sverhoeven Aug 27, 2021
e8bba84
Added JWT auth
sverhoeven Aug 27, 2021
1d37b68
Remove deprecated line
sverhoeven Aug 27, 2021
69eeaaa
More tests
sverhoeven Aug 27, 2021
8ec31ce
Use compatible coverage package
sverhoeven Aug 27, 2021
a0b5ec6
Formatting
sverhoeven Aug 27, 2021
174ffca
Prepend forcing root dir when forcing is relative
sverhoeven Aug 27, 2021
53cde10
Merge branch '27-pyewc' into jwt-auth
sverhoeven Aug 27, 2021
cee61d0
More docs + configurable FORCING_ROOT_DIR + join observation on date
sverhoeven Aug 30, 2021
ab4f1e8
Add progress print
sverhoeven Aug 31, 2021
4f6a6ee
Format with black
sverhoeven Aug 31, 2021
fa5cfbf
Addded pandas import
sverhoeven Aug 31, 2021
ead304d
Try to get rid of trailing spaces
sverhoeven Aug 31, 2021
6e5a603
Escape \r
sverhoeven Sep 1, 2021
23b9912
Add progress message to lumped model run
sverhoeven Sep 3, 2021
f9631d4
Try to git rid of trailing spaces
sverhoeven Sep 3, 2021
7fba6a5
No need for sudo when node comes from home dir
sverhoeven Sep 3, 2021
d0e9e29
Use Path to join pathsegments
sverhoeven Sep 3, 2021
29d6554
Remove unused arg
sverhoeven Sep 3, 2021
76c28ce
Dont cast to int twice
sverhoeven Sep 3, 2021
466ec43
Update tests/test_auth.py
sverhoeven Sep 3, 2021
10ea71e
Update ewatercycle_experiment_launcher/openapi.yaml
sverhoeven Sep 3, 2021
9a2dfff
Merge branch 'jwt-auth' of github.com:eWaterCycle/experiment-launcher…
sverhoeven Sep 3, 2021
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
15 changes: 12 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,12 @@ Instructions below have been tested on Linux, but should also work on OSX and Wi

The experiment launcher requires a JupyterHub server.

JupyterHub requires a NodeJS preferable installed in users home directory with [nvm](https://github.com/nvm-sh/nvm).

JupyterHub can be installed with the following commands
```bash
pip3 install jupyterhub jupyterlab
sudo npm install -g configurable-http-proxy
npm install -g configurable-http-proxy
```

JupyterHub must accept calls from the experiment launcher service to start a notebook server for any hub user and upload a notebook.
Expand Down Expand Up @@ -84,16 +86,23 @@ To start launcher use
```bash
# JUPYTERHUB_URL is URL where JupyterHub is running. If path like `/jupyter` then origin header is appended.
export JUPYTERHUB_URL=http://172.17.0.1:8000
# JWT_SECRET is secret with which JWT tokens are encoded/decoded

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think the sudo on L24 is not needed. Might be better to avoid.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

On L54 I get failed authentication (on WSL2)

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

sudo is needed for nodejs installed with apt. Switched to https://github.com/nvm-sh/nvm

export JWT_SECRET=$(openssl rand -hex 32)
# Root directory where read only forcings can be found
export FORCING_ROOT_DIR=/mnt/data/forcing
gunicorn -w 4 -b 0.0.0.0:8888 ewatercycle_experiment_launcher.serve:app
```

Goto http://localhost:8888/ui/ for Swagger UI.

The JupyterHub and Experiment Launcher both use local OS accounts for authentication and authorization.
To generate a notebook you need to
1. POST to /auth with Basic authentication to receive a JWT token
2. POST to a notebook path, like /hello, with `Authorization: Bearer <jwt token>` header.
Comment on lines +99 to +101

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Getting 401 unauthorized for everything I try (WSL problem?)

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hmm, JH uses the OS user accounts to authenticated against. Which works on my linux box. Not sure how accounts work in WSL. Mabye add user with sudo useradd someone;sudo passwd someone.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Still no luck


In the Swagger UI you must authorize before trying an operation.
In the Swagger UI you must authorize twice before trying a path.

When running on Internet make sure https is enforced so the authentication is secure.
When running on Internet make sure https is enforced, so the authentication is secure.

The webservice by default runs on `/` base path. This can be changed by setting the `BASE_PATH` environment variable.
For example `export BASE_PATH=/launcher` will host the Swagger UI on http://localhost:8888/launcher/ui/ .
213 changes: 0 additions & 213 deletions ewatercycle_experiment_launcher/api/assessment.py

This file was deleted.

124 changes: 0 additions & 124 deletions ewatercycle_experiment_launcher/api/bmi.py

This file was deleted.

Loading