I am migrating a JupyterHub project to k8s and am having difficulty passing the access_token to an environment variable in the pod in the way that I did it before. I am successfully authenticating via OAuth to my backend, I just need to get the access_token into the pod.
hub:
image:
name: hub_image
tag: <tag>
config:
GenericOAuthenticator:
client_id: <client_id>
client_secret: <client_secret>
oauth_callback_url: http://.../hub/oauth_callback
authorize_url: http://.../public/api/v1/oauth/authorize/
token_url: http://.../public/api/v1/oauth/token/
userdata_url: http://.../public/api/v1/oauth/userinfo/
scope:
- openid
- read
- write
username_key: username
auto_login: true
enable_auth_state: true
JupyterHub:
authenticator_class: generic-oauth
admin_access: true
extraConfig:
00-pass-auth-token: |
from oauthenticator.generic import GenericOAuthenticator
class MyCustomAuthenticator(GenericOAuthenticator):
async def pre_spawn_start(self, user, spawner):
auth_state = await user.get_auth_state()
if auth_state and "access_token" in auth_state:
c.KubeSpawner.environment.update(
{
"AUTH_TOKEN": auth_state["access_token"]
}
)
In my previous JupyterHub project I was able to set c.JupyterHub.authenticator_class = MyCustomAuthenticator in jupyterhub_config.py, do I need to set the authenticator_class to point to MyCustomAuthenticator somehow?
Thanks