Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

providing multiple openid_connect django.allauth socialproviders fails when loading login page #12167

Open
mwallschlaeger opened this issue Apr 17, 2024 · 1 comment · May be fixed by #12169
Assignees

Comments

@mwallschlaeger
Copy link
Member

Expected Behavior

When defining multiple openid_connect APPS within the SOCIALACCOUNT_PROVIDERS in settings.py like e.g. defined in the allauth docs:

SOCIALACCOUNT_PROVIDERS = {
    "openid_connect": {
        "APPS": [
            {
                "provider_id": "my-server",
                "name": "My Login Server",
                "client_id": "your.service.id",
                "secret": "your.service.secret",
                "settings": {
                    "server_url": "https://my.server.example.com",
                    # Optional token endpoint authentication method.
                    # May be one of "client_secret_basic", "client_secret_post"
                    # If omitted, a method from the the server's
                    # token auth methods list is used
                    "token_auth_method": "client_secret_basic",
                },
            },
            {
                "provider_id": "other-server",
                "name": "Other Login Server",
                "client_id": "your.other.service.id",
                "secret": "your.other.service.secret",
                "settings": {
                    "server_url": "https://other.server.example.com",
                },
            },
        ]
    }
}

I would expect that, after i configured the socialaccountapps inside the admin-interface that i would have multiple options as social providers.

Actual Behavior

Actually, after configuring the social providers, I run into the following exception when opening /login:

traceback
  File "/usr/src/geonode/./geonode/views.py", line 110, in handler500
    response = render(request, template_name)
  File "/usr/local/lib/python3.10/dist-packages/sentry_sdk/integrations/django/templates.py", line 102, in render
    return real_render(request, template_name, context, *args, **kwargs)
  File "/usr/local/lib/python3.10/dist-packages/django/shortcuts.py", line 19, in render
    content = loader.render_to_string(template_name, context, request, using=using)
  File "/usr/local/lib/python3.10/dist-packages/django/template/loader.py", line 62, in render_to_string
    return template.render(context, request)
  File "/usr/local/lib/python3.10/dist-packages/django/template/backends/django.py", line 61, in render
    return self.template.render(context)
  File "/usr/local/lib/python3.10/dist-packages/django/template/base.py", line 170, in render
    return self._render(context)
  File "/usr/local/lib/python3.10/dist-packages/django/template/base.py", line 162, in _render
    return self.nodelist.render(context)
  File "/usr/local/lib/python3.10/dist-packages/django/template/base.py", line 938, in render
    bit = node.render_annotated(context)
  File "/usr/local/lib/python3.10/dist-packages/django/template/base.py", line 905, in render_annotated
    return self.render(context)
  File "/usr/local/lib/python3.10/dist-packages/django/template/loader_tags.py", line 150, in render
    return compiled_parent._render(context)
  File "/usr/local/lib/python3.10/dist-packages/django/template/base.py", line 162, in _render
    return self.nodelist.render(context)
  File "/usr/local/lib/python3.10/dist-packages/django/template/base.py", line 938, in render
    bit = node.render_annotated(context)
  File "/usr/local/lib/python3.10/dist-packages/django/template/base.py", line 905, in render_annotated
    return self.render(context)
  File "/usr/local/lib/python3.10/dist-packages/django/template/loader_tags.py", line 150, in render
    return compiled_parent._render(context)
  File "/usr/local/lib/python3.10/dist-packages/django/template/base.py", line 162, in _render
    return self.nodelist.render(context)
  File "/usr/local/lib/python3.10/dist-packages/django/template/base.py", line 938, in render
    bit = node.render_annotated(context)
  File "/usr/local/lib/python3.10/dist-packages/django/template/base.py", line 905, in render_annotated
    return self.render(context)
  File "/usr/local/lib/python3.10/dist-packages/django/template/loader_tags.py", line 150, in render
    return compiled_parent._render(context)
  File "/usr/local/lib/python3.10/dist-packages/django/template/base.py", line 162, in _render
    return self.nodelist.render(context)
  File "/usr/local/lib/python3.10/dist-packages/django/template/base.py", line 938, in render
    bit = node.render_annotated(context)
  File "/usr/local/lib/python3.10/dist-packages/django/template/base.py", line 905, in render_annotated
    return self.render(context)
  File "/usr/local/lib/python3.10/dist-packages/django/template/defaulttags.py", line 315, in render
    return nodelist.render(context)
  File "/usr/local/lib/python3.10/dist-packages/django/template/base.py", line 938, in render
    bit = node.render_annotated(context)
  File "/usr/local/lib/python3.10/dist-packages/django/template/base.py", line 905, in render_annotated
    return self.render(context)
  File "/usr/local/lib/python3.10/dist-packages/django/template/defaulttags.py", line 315, in render
    return nodelist.render(context)
  File "/usr/local/lib/python3.10/dist-packages/django/template/base.py", line 938, in render
    bit = node.render_annotated(context)
  File "/usr/local/lib/python3.10/dist-packages/django/template/base.py", line 905, in render_annotated
    return self.render(context)
  File "/usr/local/lib/python3.10/dist-packages/django/template/loader_tags.py", line 195, in render
    return template.render(context)
  File "/usr/local/lib/python3.10/dist-packages/django/template/base.py", line 172, in render
    return self._render(context)
  File "/usr/local/lib/python3.10/dist-packages/django/template/base.py", line 162, in _render
    return self.nodelist.render(context)
  File "/usr/local/lib/python3.10/dist-packages/django/template/base.py", line 938, in render
    bit = node.render_annotated(context)
  File "/usr/local/lib/python3.10/dist-packages/django/template/base.py", line 905, in render_annotated
    return self.render(context)
  File "/usr/local/lib/python3.10/dist-packages/django/template/defaulttags.py", line 214, in render
    nodelist.append(node.render_annotated(context))
  File "/usr/local/lib/python3.10/dist-packages/django/template/base.py", line 905, in render_annotated
    return self.render(context)
  File "/usr/local/lib/python3.10/dist-packages/django/template/library.py", line 192, in render
    output = self.func(*resolved_args, **resolved_kwargs)
  File "/usr/local/lib/python3.10/dist-packages/allauth/socialaccount/templatetags/socialaccount.py", line 20, in provider_login_url
    provider = adapter.get_provider(request, provider)
  File "/usr/src/geonode/./geonode/people/adapters.py", line 270, in get_provider
    app = self.get_app(request, provider=provider)
  File "/usr/local/lib/python3.10/dist-packages/allauth/socialaccount/adapter.py", line 301, in get_app
    raise MultipleObjectsReturned
django.core.exceptions.MultipleObjectsReturned

django.allauth docs describe that for each APP allauth will "create an independent provider instances". Therefor the geonode adapter need to distinguish between the different APPS when passing them to the get_provider() function in

app = self.get_app(request, provider=provider)

This could be done by passing the optional parameter client_id=self.get_apps_list([0].client_id)

Specifications

  • GeoNode version: 4.2.3, latest
  • Installation type (vanilla, geonode-project): all
  • Installation method (manual, docker): all
  • Platform: linux
  • Additional details: using django.allauth 0.61.1
@afabiani
Copy link
Member

Uhm, I guess the adapter should be also improved in order to correctly fetch the additional properties from the selected provider. Currently it assumes having just one provider.

mwallschlaeger added a commit to mwallschlaeger/geonode that referenced this issue Apr 18, 2024
…h socialproviders fails when loading login page
mwallschlaeger added a commit to zalf-rdm/geonode that referenced this issue Apr 18, 2024
…h socialproviders fails when loading login page
mwallschlaeger added a commit to zalf-rdm/geonode that referenced this issue Apr 18, 2024
…o.allauth socialproviders fails when loading login page"

This reverts commit 3e9d489.
mwallschlaeger added a commit to zalf-rdm/geonode that referenced this issue Apr 18, 2024
…h socialproviders fails when loading login page
mwallschlaeger added a commit to zalf-rdm/geonode that referenced this issue Apr 18, 2024
…th socialproviders fails when loading login page
mwallschlaeger added a commit to mwallschlaeger/geonode that referenced this issue Apr 23, 2024
…h socialproviders fails when loading login page
mwallschlaeger added a commit to zalf-rdm/geonode that referenced this issue Apr 23, 2024
…h socialproviders fails when loading login page
mwallschlaeger added a commit to zalf-rdm/geonode that referenced this issue Apr 23, 2024
…le_openid_connect_django_allauth_socialproviders_fails_when_loading_login_page

[Fixes GeoNode#12167] providing multiple openid_connect django.allauth socialproviders fails when loading login page
mwallschlaeger added a commit to mwallschlaeger/geonode that referenced this issue Apr 24, 2024
…h socialproviders fails when loading login page
mwallschlaeger added a commit to zalf-rdm/geonode that referenced this issue Apr 24, 2024
…h socialproviders fails when loading login page
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
2 participants