robrotheram / taiga-contrib-openid-auth

Taiga plugin for openid authentication
45 stars 25 forks source link

500 internal server error when creating a new project (and other issues). #10

Closed ScionOfDesign closed 3 years ago

ScionOfDesign commented 3 years ago

Hey, I've been very interested in integrating Taiga with Keycloak. This plugin seems to work initially, but it runs into some issues as I try to use it. To preface, this is all set up following the instructions step-by-step, and these issues do not occur when using taigaio/taiga-back:latest and only when robrotheram/taiga-back-openid:latest is used.

Traceback (most recent call last):

File "/taiga-back/taiga/events/backends/rabbitmq.py", line 35, in _make_rabbitmq_connection

(authdata, host) = parse_result.netloc.split("@")

ValueError: not enough values to unpack (expected 2, got 1)

The above exception was the direct cause of the following exception:

Traceback (most recent call last):

File "/opt/venv/lib/python3.7/site-packages/django/core/handlers/exception.py", line 34, in inner

response = get_response(request)

File "/opt/venv/lib/python3.7/site-packages/django/core/handlers/base.py", line 115, in _get_response

response = self.process_exception_by_middleware(e, request)

File "/opt/venv/lib/python3.7/site-packages/django/core/handlers/base.py", line 113, in _get_response

response = wrapped_callback(request, *callback_args, **callback_kwargs)

File "/taiga-back/taiga/base/api/viewsets.py", line 104, in view

return self.dispatch(request, *args, **kwargs)

File "/opt/venv/lib/python3.7/site-packages/django/views/decorators/csrf.py", line 54, in wrapped_view

return view_func(*args, **kwargs)

File "/taiga-back/taiga/base/api/views.py", line 458, in dispatch

response = self.handle_exception(exc)

File "/taiga-back/taiga/base/api/views.py", line 456, in dispatch

response = handler(request, *args, **kwargs)

File "/taiga-back/taiga/base/api/mixins.py", line 98, in create

self.object = validator.save(force_insert=True)

File "/taiga-back/taiga/base/api/serializers.py", line 1113, in save

self.object = super().save(**kwargs)

File "/taiga-back/taiga/base/api/serializers.py", line 646, in save

self.save_object(self.object, **kwargs)

File "/taiga-back/taiga/base/api/serializers.py", line 1131, in save_object

obj.save(**kwargs)

File "/taiga-back/taiga/projects/models.py", line 336, in save

super().save(*args, **kwargs)

File "/opt/venv/lib/python3.7/site-packages/django/db/models/base.py", line 744, in save

force_update=force_update, update_fields=update_fields)

File "/opt/venv/lib/python3.7/site-packages/django/db/models/base.py", line 793, in save_base

update_fields=update_fields, raw=raw, using=using,

File "/opt/venv/lib/python3.7/site-packages/django/dispatch/dispatcher.py", line 175, in send

for receiver in self._live_receivers(sender)

File "/opt/venv/lib/python3.7/site-packages/django/dispatch/dispatcher.py", line 175, in

for receiver in self._live_receivers(sender)

File "/taiga-back/taiga/projects/signals.py", line 71, in project_post_save

template.apply_to_project(instance)

File "/taiga-back/taiga/projects/models.py", line 1283, in apply_to_project

project=project

File "/opt/venv/lib/python3.7/site-packages/django/db/models/manager.py", line 82, in manager_method

return getattr(self.get_queryset(), name)(*args, **kwargs)

File "/opt/venv/lib/python3.7/site-packages/django/db/models/query.py", line 422, in create

obj.save(force_insert=True, using=self.db)

File "/taiga-back/taiga/projects/models.py", line 642, in save

return super().save(*args, **kwargs)

File "/opt/venv/lib/python3.7/site-packages/django/db/models/base.py", line 744, in save

force_update=force_update, update_fields=update_fields)

File "/opt/venv/lib/python3.7/site-packages/django/db/models/base.py", line 793, in save_base

update_fields=update_fields, raw=raw, using=using,

File "/opt/venv/lib/python3.7/site-packages/django/dispatch/dispatcher.py", line 175, in send

for receiver in self._live_receivers(sender)

File "/opt/venv/lib/python3.7/site-packages/django/dispatch/dispatcher.py", line 175, in

for receiver in self._live_receivers(sender)

File "/taiga-back/taiga/events/signal_handlers.py", line 38, in on_save_any_model

events.emit_event_for_model(instance, sessionid=sesionid, type=type)

File "/taiga-back/taiga/events/events.py", line 89, in emit_event_for_model

data=data)

File "/taiga-back/taiga/events/events.py", line 48, in emit_event

connection.on_commit(backend_emit_event)

File "/opt/venv/lib/python3.7/site-packages/django/db/backends/base/base.py", line 628, in on_commit

func()

File "/taiga-back/taiga/events/events.py", line 45, in backend_emit_event

backend.emit_event(message=json.dumps(data), routing_key=routing_key, channel=channel)

File "/taiga-back/taiga/events/backends/rabbitmq.py", line 54, in emit_event

connection = _make_rabbitmq_connection(self.url)

File "/taiga-back/taiga/events/backends/rabbitmq.py", line 37, in _make_rabbitmq_connection

raise RuntimeError("Invalid url") from e

RuntimeError: Invalid URL

robrotheram commented 3 years ago

Hi sorry for the late reply, that error log looks like its got nothing to do with the plug-in, is complain about rabbit I seems that the Rabbit config is incorrect.

I am not sure what is causing the gateway error. It might be also related to Rabbitmq errors

However I will look at the :

The second issue is that an error is thrown if the 'Full Name' from Keycloak is null. I think instead it should use the 'preferred_username' falling back to the 'full_name', and finally falling to the 'username'.

mp-strachan commented 3 years ago

I too am seeing the exact same behaviour on a freshly deployed Taiga docker with this plugin. I found this, which seems to imply that it was a bug resolved by taiga on the 24th Feb: https://tree.taiga.io/project/taiga/issue/4336

niklashagman commented 3 years ago

Am having the same problem on a new installation of Taiga. Docker containers from taiga works. Docker containers from robrotheram do not.

robrotheram commented 3 years ago

This should now be fixed. The containers are now build to the latest taiga release and specific releases. Fallback for usernames has been implemented as well as some mapping customizations that can be applied.

I am closing this issue but if there are further issues then please open another issue

niklashagman commented 3 years ago

Yep, works great now. Thanks!