REMOTE_USER Authenticator: An Authenticator for Jupyterhub to read user information from HTTP request headers, as when running behind an authenticating proxy. Based on https://github.com/cwaldbieser/jhub_remote_user_authenticator and https://github.com/rasmunk/jhub-authenticators


Keywords
Interactive, Interpreter, Shell, Web
License
GPL-3.0
Install
pip install jhub-remote-login==0.2.119

Documentation

Jupyterhub Authenticators

https://travis-ci.org/cbjuan/jhub_remote_login.svg?branch=master

Authenticate to Jupyterhub using an HTTP headers. 1 to pass the JupyterHub username and other to pass a valid JHub token for that user.

Architecture and Security Recommendations

This type of authentication relies on an HTTP headers, and a malicious client could spoof the REMOTE_USER header.

For that reason, we provide also asymmetric encryption capabilities (RSA-based) to pass the username and token.

Installation

This package can be installed with pip either from a local git repository or from PyPi.

Installation from local git repository:

cd jhub_remote_login
pip install .

Installation from PyPi:

pip install jhub-remote-login

Alternately, you can add the local project folder must be on your PYTHONPATH.

## Configuration

You should edit your jupyterhub_config.py (in the JupyterHub) config file to set the authenticator class and the proper config variables:

hub:
    image:
        name: cbjuan/k8s-hub-remotelogin
        tag: v0.0.119
    extraConfig: |
        c.JupyterHub.authenticator_class = 'jhub_remote_login.RemoteUserAuthenticator'
        c.Authenticator.whitelist = {'cbjuan'}
        c.Authenticator.admin_users = {'cbjuan'}
        c.Authenticator.header_user_key = 'username'
        c.Authenticator.header_token_key = 'token'
        c.Authenticator.url_hub_api = 'https://ibm-q-jupyter-hub.us-south.containers.appdomain.cloud/hub/api'

        c.Authenticator.use_encryption = False
        c.Authenticator.rsa_private_key_pem = '-----BEGIN ENCRYPTED PRIVATE KEY-----\nMIIFLTBXBgkqhkiG9w0BBQ0wSjApBgkqhkiG9w0BBQwwHAQIZgzl2iM/LbcCAggA\nMAwGCCqGSIb3DQIJBQAwHQYJYIZIAWUDBAEqBBCq9uPHHV/11PcYdX/QpH2dBIIE\n0B1mPFLY9UdYx4eps1XoYnMecvTB+fUNeyA3FkAQfqOswbMAl2vjjiDSudF4gNps\ntXAzUV/OEKXqTN5SXYB/qbw3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KuWdFC+3WtxrY7peVBanXh+ONjyED\n8D1LQOyNKYha3EmsNeKz3jgvVbUnJ3udDistmpqG8yfOZ7yTRSzror2tvbC/ff17\nUdMx22y9S+xZW58vrHKqy9Am665Mi7OSLWgNLY3N/uG66iFvu+loIQOT5cFprOKP\nZmb7ijHOxOXmwPh7G6CdkAYvmLIZoC9sfPYRypQxhx+OMc3fx/9loq6gDb67/Pty\nGRJFkC4KcwhkcSX0IfL2AXKBsMBct93asaTsGmHKBFzOSSZ70+WQvtIIrrslI2Yt\n5ZWeIkkjvbg0JC1Io1fuMtFzVMB+oIvhMEcErOHtktYNd1eWhkfBv/jswAdikyAq\nDEpVdGBx/SdBKBD4RAGJNU3ogD0RKDQk808EPcSsRLT+px47J/K7I/wBGrdG/nJ+\nJI7axu0AjM1tPjiiZfMLIo+9zdMnGIQrBkvFnLDRUehclbfLujAa5rHhyq4vYLEv\nIK+LWk+zJRjGz9ZB90VkoKVTB88hVm4e5sL0dnB9F9IU\n-----END ENCRYPTED PRIVATE KEY-----\n'
        c.Authenticator.rsa_private_key_password = 'mypassword'
        c.Authenticator.rsa_public_key_pem = '-----BEGIN PUBLIC KEY-----\nMIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEApbAH3Z397pRp/0peApCX\nPYvyMB1/F79z7BS89FZXiVBbIuw+TZJEfxFxuVfrg3jpWjDCPFnd/g3fG9Alr3JK\nMGOQ+f4r2UfMEZ/Glq52tLw6gsyfBEmn2haH0EQS6FPT6hdzZk3IjVwQ/iMm4+Tz\n3BD+NDXFURR4mopYtgpnbqV60Mbz29JC583w6kFyQHLx+5slBEvZgF5k5YWgmZ49\nCkQfc9zhPVDqzz2m7AuV2/lDrgTtkQmluW/o/XYryfriWc+D74a7/cyQuErEs9gh\nXIAZUPF82bE3VvPX2G1FP3OITO9uf9hqSuYAUfPwaxl1NMv11b/svYwvJPxawPz1\ngQIDAQAB\n-----END PUBLIC KEY-----\n'

To use the login from outside you may need to use one of the following JS scripts.

  1. Code to log in into JupyterHub using plain text credentials:

    var myHeaders = new Headers();
    myHeaders.append("username", "userName");
    myHeaders.append("token", "userNameToken");
    var myInit = { method: 'GET',
                   headers: myHeaders,
                   mode: 'cors',
                   cache: 'default' };
    
    var myRequest = new Request('https://ibm-q-jupyter-hub.us-south.containers.appdomain.cloud/hub/login', myInit);
    fetch(myRequest).then(function(response) {
      return response.text();
    }).then(function(text) {
        document.write('<iframe src="https://ibm-q-jupyter-hub.us-south.containers.appdomain.cloud/user/userName/tree?" />')
    });
    
  2. Code to log in into JupyterHub using encrypted credentials:

    var myHeaders = new Headers();
    myHeaders.append("username", "RSAEncryptedStringForTheUserName");
    myHeaders.append("token", "RSAEncryptedStringForTheToken");
    var myInit = { method: 'GET',
                   headers: myHeaders,
                   mode: 'cors',
                   cache: 'default' };
    var myRequest = new Request('https://ibm-q-jupyter-hub.us-south.containers.appdomain.cloud/hub/login', myInit);
    fetch(myRequest).then(function(response) {
      return response.text();
    }).then(function(text) {
        document.write('<iframe src="https://ibm-q-jupyter-hub.us-south.containers.appdomain.cloud/user/userName/tree?" />')
    });