Clean up
This commit is contained in:
parent
025ba19299
commit
68bd353fe7
|
@ -18,9 +18,9 @@ hub:
|
||||||
from datetime import datetime
|
from datetime import datetime
|
||||||
from oauthenticator.generic import GenericOAuthenticator
|
from oauthenticator.generic import GenericOAuthenticator
|
||||||
token_url = 'https://' + os.environ['NEXTCLOUD_HOST'] + '/index.php/apps/oauth2/api/v1/token'
|
token_url = 'https://' + os.environ['NEXTCLOUD_HOST'] + '/index.php/apps/oauth2/api/v1/token'
|
||||||
|
debug = os.environ.get('NEXTCLOUD_DEBUG_OAUTH', 'false').lower() in ['true', '1', 'yes']
|
||||||
|
|
||||||
def get_nextcloud_access_token(refresh_token):
|
def get_nextcloud_access_token(refresh_token):
|
||||||
debug = 'NEXTCLOUD_DEBUG_OAUTH' in os.environ
|
|
||||||
client_id = os.environ['NEXTCLOUD_CLIENT_ID']
|
client_id = os.environ['NEXTCLOUD_CLIENT_ID']
|
||||||
client_secret = os.environ['NEXTCLOUD_CLIENT_SECRET']
|
client_secret = os.environ['NEXTCLOUD_CLIENT_SECRET']
|
||||||
|
|
||||||
|
@ -58,7 +58,6 @@ hub:
|
||||||
spawner.environment['NEXTCLOUD_ACCESS_TOKEN'] = access_token
|
spawner.environment['NEXTCLOUD_ACCESS_TOKEN'] = access_token
|
||||||
|
|
||||||
async def refresh_user(self, user, handler=None):
|
async def refresh_user(self, user, handler=None):
|
||||||
debug = 'NEXTCLOUD_DEBUG_OAUTH' in os.environ
|
|
||||||
auth_state = await user.get_auth_state()
|
auth_state = await user.get_auth_state()
|
||||||
if not auth_state:
|
if not auth_state:
|
||||||
if debug:
|
if debug:
|
||||||
|
@ -176,7 +175,9 @@ hub:
|
||||||
from tornado.ioloop import IOLoop
|
from tornado.ioloop import IOLoop
|
||||||
from tornado.web import Application, HTTPError, RequestHandler, authenticated
|
from tornado.web import Application, HTTPError, RequestHandler, authenticated
|
||||||
from urllib.parse import urlparse
|
from urllib.parse import urlparse
|
||||||
|
debug = os.environ.get('NEXTCLOUD_DEBUG_OAUTH', 'false').lower() in ['true', '1', 'yes']
|
||||||
def my_debug(s):
|
def my_debug(s):
|
||||||
|
if debug:
|
||||||
with open("/proc/1/fd/1", "a") as stdout:
|
with open("/proc/1/fd/1", "a") as stdout:
|
||||||
print(s, file=stdout)
|
print(s, file=stdout)
|
||||||
|
|
||||||
|
@ -232,11 +233,11 @@ hub:
|
||||||
# Fetch current auth state
|
# Fetch current auth state
|
||||||
user_data = self.api_request('GET', url_path_join('users', user_model['name']))
|
user_data = self.api_request('GET', url_path_join('users', user_model['name']))
|
||||||
auth_state = user_data['auth_state']
|
auth_state = user_data['auth_state']
|
||||||
my_debug(f"DEBUG: {auth_state}")
|
access_token = auth_state['access_token']
|
||||||
|
token_expires = auth_state['token_expires']
|
||||||
|
|
||||||
self.set_header('content-type', 'application/json')
|
self.set_header('content-type', 'application/json')
|
||||||
self.write(json.dumps(auth_state, indent=1, sort_keys=True))
|
self.write(json.dumps({'access_token': access_token, 'token_expires': token_expires}, indent=1, sort_keys=True))
|
||||||
|
|
||||||
class PingHandler(RequestHandler):
|
class PingHandler(RequestHandler):
|
||||||
|
|
||||||
|
@ -275,7 +276,7 @@ hub:
|
||||||
targetPort: 8082
|
targetPort: 8082
|
||||||
name: refresh-token
|
name: refresh-token
|
||||||
extraEnv:
|
extraEnv:
|
||||||
NEXTCLOUD_DEBUG_OAUTH: "yes"
|
NEXTCLOUD_DEBUG_OAUTH: "no"
|
||||||
NEXTCLOUD_HOST: sunet.drive.test.sunet.se
|
NEXTCLOUD_HOST: sunet.drive.test.sunet.se
|
||||||
JUPYTER_HOST: jupyter.drive.test.sunet.se
|
JUPYTER_HOST: jupyter.drive.test.sunet.se
|
||||||
JUPYTERHUB_API_KEY:
|
JUPYTERHUB_API_KEY:
|
||||||
|
|
Loading…
Reference in a new issue