Compare commits

..

No commits in common. "c143d96fab487f6c5cd533a01324ecc0d3a1e558" and "913980a02761ff5e6d318ece722228526da8da80" have entirely different histories.

View file

@ -15,28 +15,25 @@ hub:
from oauthenticator.generic import GenericOAuthenticator
def post_auth_hook(authenticator, handler, authentication):
user = authentication['auth_state']['oauth_user']['ocs']['data']['id']
authentication['auth_state']['token_expires'] = time.time() + auth_state['token_response']['expires_in']
auth_state = authentication['auth_state']
auth_state['token_expires'] = time.time() + auth_state['token_response']['expires_in']
authenticator.user_dict[user] = auth_state
return authentication
class NextcloudOAuthenticator(GenericOAuthenticator):
def __init__(self, *args, **kwargs):
super().__init__(*args, **kwargs)
self.user_dict = {}
async def pre_spawn_start(self, user, spawner):
def pre_spawn_start(self, user, spawner):
super().pre_spawn_start(user, spawner)
auth_state = await user.get_auth_state()
if not auth_state:
return
access_token = auth_state['access_token']
access_token = self.user_dict[user.name]['access_token']
spawner.environment['NEXTCLOUD_ACCESS_TOKEN'] = access_token
async def refresh_user(self, user, handler=None):
auth_state = await user.get_auth_state()
if not auth_state:
return False
access_token = auth_state['access_token']
refresh_token = auth_state['refresh_token']
token_response = name]['token_response']
try:
access_token = self.user_dict[user.name]['access_token']
refresh_token = self.user_dict[user.name]['refresh_token']
token_response = self.user_dict[user.name]['token_response']
now = time.time()
expires = self.user_dict[user.name]['token_expires']
if now >= expires:
@ -45,7 +42,6 @@ hub:
print(f'Time is: {now}, token expires: {expires}')
return True
except KeyError:
print(f'No auth_state available for user: {user.name}')
return False
c.JupyterHub.authenticator_class = NextcloudOAuthenticator
@ -66,11 +62,6 @@ hub:
extraEnv:
NEXTCLOUD_HOST: sunet.drive.test.sunet.se
JUPYTER_HOST: jupyter.drive.test.sunet.se
JUPYTERHUB_CRYPT_KEY:
valueFrom:
secretKeyRef:
name: jupyterhub-secrets
key: crypt-key
NEXTCLOUD_CLIENT_ID:
valueFrom:
secretKeyRef: