iFargle / headscale-webui

A simple Headscale web UI for small-scale deployments.
Other
647 stars 62 forks source link

OIDC server does not support profile #115

Open mjc0608 opened 1 year ago

mjc0608 commented 1 year ago

I got the following errors when configuring headscale-webui with OIDC

Traceback (most recent call last):
  File "/app/.venv/lib/python3.11/site-packages/flask/app.py", line 2190, in wsgi_app
    response = self.full_dispatch_request()
               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/app/.venv/lib/python3.11/site-packages/flask/app.py", line 1486, in full_dispatch_request
    rv = self.handle_user_exception(e)
         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/app/.venv/lib/python3.11/site-packages/flask/app.py", line 1484, in full_dispatch_request
    rv = self.dispatch_request()
         ^^^^^^^^^^^^^^^^^^^^^^^
  File "/app/.venv/lib/python3.11/site-packages/flask/app.py", line 1469, in dispatch_request
    return self.ensure_sync(self.view_functions[rule.endpoint])(**view_args)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/app/.venv/lib/python3.11/site-packages/flask_oidc/__init__.py", line 488, in decorated
    return view_func(*args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/app/server.py", line 261, in settings_page
    OIDC_NAV_DROPDOWN = renderer.oidc_nav_dropdown(user_name, email_address, name)
                        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/app/renderer.py", line 634, in oidc_nav_dropdown
    html_payload = """
                   ^^^
TypeError: can only concatenate str (not "NoneType") to str

I believe the root cause is that my OIDC server does not profile the "profile" scope, thus, the "name" field becomes a NoneType. I guess the easiest fix is to replace any NoneType with a "N/A" str here. I can submit a fix if you want.

Any idea on how to solve this issue in a more elegant way?