Jupyter - token authentication

Hi, I caught the Mathworks presentation a month ago and implemented the jupyter-matlab-proxy. It worked pretty much out of the box with one exception. Using the Matlab kernel in Jupyter, rather than open full blown Matlab IDE, we get the following message:

I followed up with Mathworks and they responded that token authentication is the only method supported. So even if you do go delete your Notebook password file it still fails.

Token authentication can be passed in the URL, or perhaps through the “Extra command line parameters to pass to Jupyter”. I’m happy to give this a run to make this work, but could use some guidance.

Kenny, MSU RCI

1 Like

Sorry, we’re not familiar with Matlab + Jupyter integration. I’m not entirely sure what to do - I’d checkout their github and/or open tickets on that github repo and maybe they’ll know.

Hi Jeff :slight_smile:

There’s only a slight change to the config file generated by the before script. This sets a static token “MyToken” for using Matlab in Jupyter. This opens up to a page where you need to enter the token manually. I only got this far before we fell under cyberattack and I never got to work on this again. It works, though :slight_smile:, so I hope to revisit soon to automate this further.

I’m loading modules cuDNN (for GPU instance), Python 3.10.4, Xvfb/1.20.11, and Matlab2023a. Other than that I’m using the standard OSC Jupyter App form.yml.erb.

file: jmatlab/template/before.sh.erb:

# Export the module function if it exists
[[ $(type -t module) == "function" ]] && export -f module

# Find available port to run server on
port=$(find_port)

# Generate SHA1 encrypted password (requires OpenSSL installed)
SALT="$(create_passwd 16)"
password="$(create_passwd 16)"
PASSWORD_SHA1="$(echo -n "${password}${SALT}" | openssl dgst -sha1 | awk '{print $NF}')"

# The `$CONFIG_FILE` environment variable is exported as it is used in the main
# `script.sh.erb` file when launching the Jupyter Notebook server.
export CONFIG_FILE="${PWD}/config.py"
export JUPYTER_TOKEN_FILE="${PWD}/jupyter.token"
export JUPYTER_TOKEN="MyToken"

(
umask 077
cat > "${JUPYTER_TOKEN_FILE}" << EOL
${JUPYTER_TOKEN}
EOL
)


#c.NotebookApp.password = u'sha1:${SALT}:${PASSWORD_SHA1}'
# Generate Jupyter configuration file with secure file permissions
(
umask 077
cat > "${CONFIG_FILE}" << EOL
c.NotebookApp.ip = '*'
c.NotebookApp.port = ${port}
c.NotebookApp.port_retries = 0
c.NotebookApp.token = '${JUPYTER_TOKEN}'
c.NotebookApp.base_url = '/node/${host}/${port}/'
c.NotebookApp.open_browser = False
c.NotebookApp.allow_origin = '*'
c.NotebookApp.notebook_dir = '${HOME}'
c.NotebookApp.disable_check_xsrf = True
EOL
)

P.S. Follow instructions here for intergration with Python & Jupyter

Kenny, MSU RCI

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.