Syntax error

This commit is contained in:
Micke Nordin 2024-01-15 16:06:46 +01:00
parent db6f3998ac
commit fc11225ffb
Signed by untrusted user: Micke
GPG key ID: F53C4CC83EDAB3BE

View file

@ -10,48 +10,50 @@ hub:
pvc: pvc:
storageClassName: csi-sc-cinderplugin storageClassName: csi-sc-cinderplugin
extraFiles: extraFiles:
refresh-token.py: | refresh-token.py:
"""A token refresh service authenticating with the Hub. mountPath: /usr/local/etc/jupyterhub/refresh-token.py
stringData: |
"""A token refresh service authenticating with the Hub.
This service serves `/services/refresh-token/`, This service serves `/services/refresh-token/`,
authenticated with the Hub, authenticated with the Hub,
showing the user their own info. showing the user their own info.
""" """
import json import json
import os import os
from urllib.parse import urlparse from urllib.parse import urlparse
from tornado.httpserver import HTTPServer from tornado.httpserver import HTTPServer
from tornado.ioloop import IOLoop from tornado.ioloop import IOLoop
from tornado.web import Application, RequestHandler, authenticated from tornado.web import Application, RequestHandler, authenticated
from jupyterhub.services.auth import HubAuthenticated from jupyterhub.services.auth import HubAuthenticated
class RefreshHandler(HubAuthenticated, RequestHandler): class RefreshHandler(HubAuthenticated, RequestHandler):
@authenticated @authenticated
def get(self): def get(self):
user_model = self.get_current_user() user_model = self.get_current_user()
self.set_header('content-type', 'application/json') self.set_header('content-type', 'application/json')
self.write(json.dumps(user_model, indent=1, sort_keys=True)) self.write(json.dumps(user_model, indent=1, sort_keys=True))
def main(): def main():
app = Application( app = Application(
[ [
(os.environ['JUPYTERHUB_SERVICE_PREFIX'] + '/?', RefreshHandler), (os.environ['JUPYTERHUB_SERVICE_PREFIX'] + '/?', RefreshHandler),
(r'.*', RefreshHandler), (r'.*', RefreshHandler),
] ]
) )
http_server = HTTPServer(app) http_server = HTTPServer(app)
url = urlparse(os.environ['JUPYTERHUB_SERVICE_URL']) url = urlparse(os.environ['JUPYTERHUB_SERVICE_URL'])
http_server.listen(url.port, url.hostname) http_server.listen(url.port, url.hostname)
IOLoop.current().start() IOLoop.current().start()
if __name__ == '__main__': if __name__ == '__main__':
main() main()
extraConfig: extraConfig:
oauthCode: | oauthCode: |
@ -167,7 +169,7 @@ hub:
c.JupyterHub.services = [ c.JupyterHub.services = [
{ {
'name': 'refresh-token', 'name': 'refresh-token',
'command': [sys.executable, './refresh_token.py'] 'command': [sys.executable, '/usr/local/etc/jupyterhub/refresh-token.py']
} }
] ]