JupyterHub generic.oauthenticator:Cookie中缺少500个内部服务器错误/ 400个OAuth状态

问题描述

我正在创建一个仪表板服务,多个用户可以通过JupyterHub.

访问多个笔记本服务器

用户使用单独的 Authentication 服务登录,并且一旦进入仪表板JupyterHub就会显示<iframe>内部。

我将JupyterHub托管在GCP的Kubernetes集群中。这些是我的config.yaml的相关部分:

...
 # Changes the Jupyter's notebook headers to allow it to be displayed
 # inside of an iframe object.
 c.JupyterHub.tornado_settings = {
        "headers": {
          "Content-Security-Policy": "default-src *  data: blob: filesystem: about: ws: wss: 'unsafe-inline' 'unsafe-eval' 'unsafe-dynamic'; script-src * data: blob: 'unsafe-inline' 'unsafe-eval'; connect-src * data: blob: 'unsafe-inline'; img-src * data: blob: 'unsafe-inline'; frame-src * data: blob: ; style-src * data: blob: 'unsafe-inline'; font-src * data: blob: 'unsafe-inline';",}
      }
...
auth:
  type: custom
  custom:
    className: oauthenticator.generic.GenericOAuthenticator
    config:
      login_service: "OpenID" 
      client_id: "<client_id>"
      client_secret: "<client_secret>"

但是,当我尝试仅通过JupyterHub端点登录时,会得到:

500内部服务器错误

日志:

IwN2YyNzVhNTk0MzM0ZTM5YmIyZTdmZDQzY2U2ZDI3YyIsICJuZXh0X3VybCI6IG51bGx9&session_state=641fb9aca6490d2c3332871d72ee0639b3ed46b8a9f02c363ee8f7bf46f1c989.74e37d534296
cad45421019d1d442153',version='HTTP/1.1',remote_ip='<>')

    Traceback (most recent call last):
      File "/usr/local/lib/python3.6/dist-packages/tornado/web.py",line 1703,in _execute
        result = await result
      File "/usr/local/lib/python3.6/dist-packages/oauthenticator/oauth2.py",line 213,in get
        user = await self.login_user()
      File "/usr/local/lib/python3.6/dist-packages/jupyterhub/handlers/base.py",line 699,in login_user
        authenticated = await self.authenticate(data)
      File "/usr/local/lib/python3.6/dist-packages/jupyterhub/auth.py",line 383,in get_authenticated_user
        authenticated = await maybe_future(self.authenticate(handler,data))
      File "/usr/local/lib/python3.6/dist-packages/oauthenticator/generic.py",line 136,in authenticate
        resp_json = json.loads(resp.body.decode('utf8','replace'))
      File "/usr/lib/python3.6/json/__init__.py",line 354,in loads
        return _default_decoder.decode(s)
      File "/usr/lib/python3.6/json/decoder.py",line 339,in decode
        obj,end = self.raw_decode(s,idx=_w(s,0).end())
      File "/usr/lib/python3.6/json/decoder.py",line 357,in raw_decode
        raise JSONDecodeError("Expecting value",s,err.value) from None
    json.decoder.JSONDecodeError: Expecting value: line 5 column 1 (char 4)

我知道它确实确实重定向到了 Authentication Server ,并且回调是正确的。即使在尝试通过仪表板进行访问时,即使在<iframe>内,我也会得到:

Cookie中缺少

400个OAuth状态

日志:

400 GET /hub/oauth_callback?code=d37de16a855a49dda94fb65c2c2c8ffa&state=eyJzdGF0ZV9pZCI6ICIwN2YyNzVhNTk0MzM0ZTM5Ym
IyZTdmZDQzY2U2ZDI3YyIsICJuZXh0X3VybCI6IG51bGx9&session_state=641fb9aca6490d2c3332871d72ee0639b3ed46b8a9f02c363ee8f7bf46f1c989.74e37d534296cad45421019d1d442153

OAuth state missing from cookies

对于上下文:我以前使用过Github OAuthenticator类,并在Github中注册了OAuth应用程序,并使JupyterHub运行正常。但是,Github不允许在<iframe>中使用他们的应用,因此我不得不走通用路线。

要点是,设置非常相似,并且至少JupyterHub仪表板之外工作,所以我真的很想知道我还可能缺少什么。任何帮助表示赞赏。

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)

相关问答

Selenium Web驱动程序和Java。元素在(x,y)点处不可单击。其...
Python-如何使用点“。” 访问字典成员?
Java 字符串是不可变的。到底是什么意思?
Java中的“ final”关键字如何工作?(我仍然可以修改对象。...
“loop:”在Java代码中。这是什么,为什么要编译?
java.lang.ClassNotFoundException:sun.jdbc.odbc.JdbcOdbc...