From 55fbb0b5fe3443548016c648a4806da66a92cbcd Mon Sep 17 00:00:00 2001 From: neerajnatu Date: Fri, 23 Sep 2022 16:50:13 +0530 Subject: [PATCH] review comments address --- docs/source/reference/authenticators.md | 19 +++++++++++++++++-- 1 file changed, 17 insertions(+), 2 deletions(-) diff --git a/docs/source/reference/authenticators.md b/docs/source/reference/authenticators.md index ef0fff61..4c3f0788 100644 --- a/docs/source/reference/authenticators.md +++ b/docs/source/reference/authenticators.md @@ -246,9 +246,24 @@ class MyAuthenticator(Authenticator): return spawner.environment['UPSTREAM_TOKEN'] = auth_state['upstream_token'] ``` +Note that environment variable names and values are always strings, so passing multiple values means setting multiple environment variables or serializing more complex data into a single variable, e.g. as a JSON string. + + +auth state can also be used to configure the spawner via _config_ without subclassing +by setting `c.Spawner.auth_state_hook`. This function will be called with `(spawner, auth_state)`, +only when auth_state is defined. + +For example: +(for KubeSpawner) + +```python +def auth_state_hook(spawner, auth_state): + spawner.volumes = auth_state['user_volumes'] + spawner.mounts = auth_state['user_mounts'] + +c.Spawner.auth_state_hook = auth_state_hook +``` -Please note the `spawner.environment` expects a string or byte array set in the environment but not dictionary. -To set anything complex other than string please look at {meth}`Spawner.auth_state_hook` available in most of the spawners which can read the entire `auth_state` dictionary. (authenticator-groups)=