[go: nahoru, domu]

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

After update to 1.5.14 - oidc/allauth is broken #3032

Closed
tfmm opened this issue Mar 11, 2024 · 12 comments
Closed

After update to 1.5.14 - oidc/allauth is broken #3032

tfmm opened this issue Mar 11, 2024 · 12 comments

Comments

@tfmm
Copy link
tfmm commented Mar 11, 2024

Tandoor Version

1.5.14

Setup

Docker / Docker-Compose

Reverse Proxy

Others (please state below)

Other

NGINX

Bug description

I updated to 1.5.14, and now authentication is failing with a 500 error.

Relevant logs

ERROR:django.request:Internal Server Error: /accounts/login/
Traceback (most recent call last):
  File "/opt/recipes/venv/lib/python3.12/site-packages/django/core/handlers/exception.py", line 55, in inner
    response = get_response(request)
               ^^^^^^^^^^^^^^^^^^^^^
  File "/opt/recipes/venv/lib/python3.12/site-packages/django/core/handlers/base.py", line 220, in _get_response
    response = response.render()
               ^^^^^^^^^^^^^^^^^
  File "/opt/recipes/venv/lib/python3.12/site-packages/django/template/response.py", line 114, in render
    self.content = self.rendered_content
                   ^^^^^^^^^^^^^^^^^^^^^
  File "/opt/recipes/venv/lib/python3.12/site-packages/django/template/response.py", line 92, in rendered_content
    return template.render(context, self._request)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/recipes/venv/lib/python3.12/site-packages/django/template/backends/django.py", line 61, in render
    return self.template.render(context)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/recipes/venv/lib/python3.12/site-packages/django/template/base.py", line 175, in render
    return self._render(context)
           ^^^^^^^^^^^^^^^^^^^^^
  File "/opt/recipes/venv/lib/python3.12/site-packages/django/template/base.py", line 167, in _render
    return self.nodelist.render(context)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/recipes/venv/lib/python3.12/site-packages/django/template/base.py", line 1005, in render
    return SafeString("".join([node.render_annotated(context) for node in self]))
                               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/recipes/venv/lib/python3.12/site-packages/django/template/base.py", line 966, in render_annotated
    return self.render(context)
           ^^^^^^^^^^^^^^^^^^^^
  File "/opt/recipes/venv/lib/python3.12/site-packages/django/template/loader_tags.py", line 157, in render
    return compiled_parent._render(context)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/recipes/venv/lib/python3.12/site-packages/django/template/base.py", line 167, in _render
    return self.nodelist.render(context)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/recipes/venv/lib/python3.12/site-packages/django/template/base.py", line 1005, in render
    return SafeString("".join([node.render_annotated(context) for node in self]))
                               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/recipes/venv/lib/python3.12/site-packages/django/template/base.py", line 966, in render_annotated
    return self.render(context)
           ^^^^^^^^^^^^^^^^^^^^
  File "/opt/recipes/venv/lib/python3.12/site-packages/django/template/loader_tags.py", line 63, in render
    result = block.nodelist.render(context)
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/recipes/venv/lib/python3.12/site-packages/django/template/base.py", line 1005, in render
    return SafeString("".join([node.render_annotated(context) for node in self]))
                               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/recipes/venv/lib/python3.12/site-packages/django/template/base.py", line 966, in render_annotated
    return self.render(context)
           ^^^^^^^^^^^^^^^^^^^^
  File "/opt/recipes/venv/lib/python3.12/site-packages/django/template/defaulttags.py", line 321, in render
    return nodelist.render(context)
::ffff:172.27.0.4 - - [11/Mar/2024:12:40:55 -0400] "GET /accounts/login/?next=/search/ HTTP/1.0" 500 145 "-" "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/122.0.0.0 Safari/537.36"
           ^^^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/recipes/venv/lib/python3.12/site-packages/django/template/base.py", line 1005, in render
    return SafeString("".join([node.render_annotated(context) for node in self]))
                               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/recipes/venv/lib/python3.12/site-packages/django/template/base.py", line 966, in render_annotated
    return self.render(context)
           ^^^^^^^^^^^^^^^^^^^^
  File "/opt/recipes/venv/lib/python3.12/site-packages/django/template/loader_tags.py", line 208, in render
    return template.render(context)
           ^^^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/recipes/venv/lib/python3.12/site-packages/django/template/base.py", line 177, in render
    return self._render(context)
           ^^^^^^^^^^^^^^^^^^^^^
  File "/opt/recipes/venv/lib/python3.12/site-packages/django/template/base.py", line 167, in _render
    return self.nodelist.render(context)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/recipes/venv/lib/python3.12/site-packages/django/template/base.py", line 1005, in render
    return SafeString("".join([node.render_annotated(context) for node in self]))
                               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/recipes/venv/lib/python3.12/site-packages/django/template/base.py", line 966, in render_annotated
    return self.render(context)
           ^^^^^^^^^^^^^^^^^^^^
  File "/opt/recipes/venv/lib/python3.12/site-packages/django/template/defaulttags.py", line 238, in render
    nodelist.append(node.render_annotated(context))
                    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/recipes/venv/lib/python3.12/site-packages/django/template/base.py", line 966, in render_annotated
    return self.render(context)
           ^^^^^^^^^^^^^^^^^^^^
  File "/opt/recipes/venv/lib/python3.12/site-packages/django/template/defaulttags.py", line 321, in render
    return nodelist.render(context)
           ^^^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/recipes/venv/lib/python3.12/site-packages/django/template/base.py", line 1005, in render
    return SafeString("".join([node.render_annotated(context) for node in self]))
                               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/recipes/venv/lib/python3.12/site-packages/django/template/base.py", line 966, in render_annotated
    return self.render(context)
           ^^^^^^^^^^^^^^^^^^^^
  File "/opt/recipes/venv/lib/python3.12/site-packages/django/template/library.py", line 237, in render
    output = self.func(*resolved_args, **resolved_kwargs)
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/recipes/venv/lib/python3.12/site-packages/allauth/socialaccount/templatetags/socialaccount.py", line 20, in provider_login_url
    provider = adapter.get_provider(request, provider)
               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/recipes/venv/lib/python3.12/site-packages/allauth/socialaccount/adapter.py", line 216, in get_provider
    app = self.get_app(request, provider=provider)
          ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/recipes/venv/lib/python3.12/site-packages/allauth/socialaccount/adapter.py", line 301, in get_app
    raise MultipleObjectsReturned
django.core.exceptions.MultipleObjectsReturned
@smilerz
Copy link
Collaborator
smilerz commented Mar 11, 2024

please share your env and compose and the entire log as the issue template requested.

@tfmm
Copy link
Author
tfmm commented Mar 11, 2024

ENV:

DEBUG=0
SQL_DEBUG=0
DEBUG_TOOLBAR=0
ALLOWED_HOSTS=*
SECRET_KEY=REDACTED
TZ=America/Detroit
DB_ENGINE=django.db.backends.postgresql
POSTGRES_HOST=db_recipes
POSTGRES_PORT=5432
POSTGRES_USER=djangouser
POSTGRES_PASSWORD=REDACTED
POSTGRES_DB=djangodb
FRACTION_PREF_DEFAULT=1
COMMENT_PREF_DEFAULT=0
SHOPPING_MIN_AUTOSYNC_INTERVAL=5
GUNICORN_MEDIA=0
REMOTE_USER_AUTH=0
EMAIL_HOST=REDACTED
EMAIL_PORT=587
EMAIL_HOST_USER=REDACTED
EMAIL_HOST_PASSWORD=REDACTED
EMAIL_USE_TLS=1
ENABLE_PDF_EXPORT=1
SOCIALACCOUNT_PROVIDERS='{"openid_connect":{"SERVERS":[{"id":"REDACTED","name":"REDACTED","server_url":"REDACTED","token_auth_method":"client_secret_basic","APP":{"client_id":"REDACTED","secret":"REDACTED"}}]}}'
SOCIAL_PROVIDERS=allauth.socialaccount.providers.openid_connect
SOCIAL_DEFAULT_ACCESS=0
SOCIAL_DEFAULT_GROUP=guest
ENABLE_SIGNUP=0
DEFAULT_FROM_EMAIL=redacted

COMPOSE:

version: "3"
services:
  db_recipes:
    restart: always
    image: postgres:15-alpine
    volumes:
      - /containers/data/tandoor/pgsql:/var/lib/postgresql/data
    env_file:
      - ../stack.env

  web_recipes:
    restart: always
    image: vabene1111/recipes:latest
    env_file:
      - ../stack.env
    volumes:
      - staticfiles:/opt/recipes/staticfiles
      - nginx_config:/opt/recipes/nginx/conf.d
      - /containers/data/tandoor/mediafiles:/opt/recipes/mediafiles
    depends_on:
      - db_recipes

  nginx_recipes:
    image: nginx:mainline-alpine
    restart: always
    ports:
      - 60123:80
    env_file:
      - ../stack.env
    depends_on:
      - web_recipes
    volumes:
      - nginx_config:/etc/nginx/conf.d:ro
      - staticfiles:/static:ro
      - /containers/data/tandoor/mediafiles:/media:ro

volumes:
  nginx_config:
  staticfiles:

Log is attached.
log.txt

@tfmm
Copy link
Author
tfmm commented Mar 11, 2024

Also, the bug report template does not request this information, just fyi.

@smilerz
Copy link
Collaborator
smilerz commented Mar 11, 2024

the issue is in your openid configuration - either there is a duplicate user created in the db or some other error in the configuration.

@tfmm
Copy link
Author
tfmm commented Mar 11, 2024

My openid configuration has not changed. The django admin panel does not show any duplicate users.

Was the version of allauth updated with this latest release?

@smilerz
Copy link
Collaborator
smilerz commented Mar 11, 2024

last bump was on 1.5.13

@smilerz
Copy link
Collaborator
smilerz commented Mar 11, 2024

did you check for duplicates in socialaccounts?

@tfmm
Copy link
Author
tfmm commented Mar 11, 2024

Yes, I do not have duplicates. I have re-created my openid_connect config to mimic what is in the updated docs from allauth, running into a redirect url error now, working through that. If I get it working I will update here.

@smilerz
Copy link
Collaborator
smilerz commented Mar 11, 2024

sorry I couldn't be more help - allauth is mostly a blackbox from Tandoor's perspective.

@tfmm
Copy link
Author
tfmm commented Mar 11, 2024

So here's what I had to do:

  1. Remove SOCIALACCOUNT_PROVIDERS from env
  2. Configure the provider in the django panel like so:
Provider: OpenID Connect
Provider ID: id name of provider
Name: Readable provider name
Client id: ID from provider
Secret Key: Key from provider
Settings: {"server_url": "REDACTED", "token_auth_method": "client_secret_basic"}
Sites: Move my site to Chosen Sites
  1. Add the following redirect URIs to provider:
https://TANDOOR_URL/accounts/PROVIDER_ID/login/callback/
https://TANDOOR_URL/accounts/oidc/PROVIDER_ID/login/callback/
https://TANDOOR_URL/accounts/oidc/PROVIDER_ID/login/

@tfmm tfmm closed this as completed Mar 11, 2024
@smilerz
Copy link
Collaborator
smilerz commented Mar 11, 2024

thanks for sharing the details

@danieljkemp
Copy link

I ended up here after revisiting my issues here: #2893

The method @tfmm mentioned worked, except I had to re-link all users which was tricky

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants