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

[BUG] - Login via LDAP not possible #4445

Closed
5 of 6 tasks
psychofaktory opened this issue Oct 24, 2024 · 3 comments
Closed
5 of 6 tasks

[BUG] - Login via LDAP not possible #4445

psychofaktory opened this issue Oct 24, 2024 · 3 comments
Labels
bug Something isn't working triage

Comments

@psychofaktory
Copy link

First Check

  • This is not a feature request.
  • I added a very descriptive title to this issue (title field is above this).
  • I used the GitHub search to find a similar issue and didn't find it.
  • I searched the Mealie documentation, with the integrated search.
  • I already read the docs and didn't find an answer.
  • This issue can be replicated on the demo site (https://demo.mealie.io/).

What is the issue you are experiencing?

According to the documentation, a connection to an existing ( working) LDAP server (tested with OpenLDAP and LLDAP) was set up.

When trying to log in a new user from the LDAP directory, the error message “Something went wrong” appears.
I have attached the corresponding logs.

At the same time, the LDAP server log shows that no connection attempt was made by the Mealie instance. No attempt was made to query the user in LDAP.

The behavior also occurs if the user is previously created via the Mealie user administration and the authentication method is manually set to “LDAP”.

Steps to Reproduce

  1. Set up a connection to an LDAP server
  2. Try to log in to Mealie with an authorized user from the LDAP directory
  3. Notice that there is an error message

Please provide relevant logs

[INFO|httptools_impl|L468] 2024-10-24T20:23:32: 127.0.0.1:51388 - "GET /api/app/about HTTP/1.1" 200
[DEBUG|multipart|L627] 2024-10-24T20:23:52: Calling on_part_begin with no data
[DEBUG|multipart|L624] 2024-10-24T20:23:52: Calling on_header_field with data[59:78]
[DEBUG|multipart|L624] 2024-10-24T20:23:52: Calling on_header_value with data[80:106]
[DEBUG|multipart|L627] 2024-10-24T20:23:52: Calling on_header_end with no data
[DEBUG|multipart|L627] 2024-10-24T20:23:52: Calling on_headers_finished with no data
[DEBUG|multipart|L624] 2024-10-24T20:23:52: Calling on_part_data with data[110:125]
[DEBUG|multipart|L627] 2024-10-24T20:23:52: Calling on_part_end with no data
[DEBUG|multipart|L627] 2024-10-24T20:23:52: Calling on_part_begin with no data
[DEBUG|multipart|L624] 2024-10-24T20:23:52: Calling on_header_field with data[186:205]
[DEBUG|multipart|L624] 2024-10-24T20:23:52: Calling on_header_value with data[207:233]
[DEBUG|multipart|L627] 2024-10-24T20:23:52: Calling on_header_end with no data
[DEBUG|multipart|L627] 2024-10-24T20:23:52: Calling on_headers_finished with no data
[DEBUG|multipart|L624] 2024-10-24T20:23:52: Calling on_part_data with data[237:249]
[DEBUG|multipart|L627] 2024-10-24T20:23:52: Calling on_part_end with no data
[DEBUG|multipart|L627] 2024-10-24T20:23:52: Calling on_part_begin with no data
[DEBUG|multipart|L624] 2024-10-24T20:23:52: Calling on_header_field with data[310:329]
[DEBUG|multipart|L624] 2024-10-24T20:23:52: Calling on_header_value with data[331:360]
[DEBUG|multipart|L627] 2024-10-24T20:23:52: Calling on_header_end with no data
[DEBUG|multipart|L627] 2024-10-24T20:23:52: Calling on_headers_finished with no data
[DEBUG|multipart|L624] 2024-10-24T20:23:52: Calling on_part_data with data[364:369]
[DEBUG|multipart|L627] 2024-10-24T20:23:52: Calling on_part_end with no data
[DEBUG|multipart|L627] 2024-10-24T20:23:52: Calling on_end with no data
[INFO|httptools_impl|L468] 2024-10-24T20:23:52: 10.80.80.102:52138 - "POST /api/auth/token HTTP/1.1" 500
[ERROR|httptools_impl|L406] 2024-10-24T20:23:52: Exception in ASGI application
Traceback (most recent call last):
File "/opt/pysetup/.venv/lib/python3.10/site-packages/uvicorn/protocols/http/httptools_impl.py", line 401, in run_asgi
result = await app( # type: ignore[func-returns-value]
File "/opt/pysetup/.venv/lib/python3.10/site-packages/uvicorn/middleware/proxy_headers.py", line 60, in call
return await self.app(scope, receive, send)
File "/opt/pysetup/.venv/lib/python3.10/site-packages/fastapi/applications.py", line 1054, in call
await super().call(scope, receive, send)
File "/opt/pysetup/.venv/lib/python3.10/site-packages/starlette/applications.py", line 113, in call
await self.middleware_stack(scope, receive, send)
File "/opt/pysetup/.venv/lib/python3.10/site-packages/starlette/middleware/errors.py", line 187, in call
raise exc
File "/opt/pysetup/.venv/lib/python3.10/site-packages/starlette/middleware/errors.py", line 165, in call
await self.app(scope, receive, _send)
File "/opt/pysetup/.venv/lib/python3.10/site-packages/starlette/middleware/sessions.py", line 85, in call
await self.app(scope, receive, send_wrapper)
File "/opt/pysetup/.venv/lib/python3.10/site-packages/starlette/middleware/gzip.py", line 20, in call
await responder(scope, receive, send)
File "/opt/pysetup/.venv/lib/python3.10/site-packages/starlette/middleware/gzip.py", line 39, in call
await self.app(scope, receive, self.send_with_gzip)
File "/opt/pysetup/.venv/lib/python3.10/site-packages/starlette/middleware/exceptions.py", line 62, in call
await wrap_app_handling_exceptions(self.app, conn)(scope, receive, send)
File "/opt/pysetup/.venv/lib/python3.10/site-packages/starlette/_exception_handler.py", line 53, in wrapped_app
raise exc
File "/opt/pysetup/.venv/lib/python3.10/site-packages/starlette/_exception_handler.py", line 42, in wrapped_app
await app(scope, receive, sender)
File "/opt/pysetup/.venv/lib/python3.10/site-packages/starlette/routing.py", line 715, in call
await self.middleware_stack(scope, receive, send)
File "/opt/pysetup/.venv/lib/python3.10/site-packages/starlette/routing.py", line 735, in app
await route.handle(scope, receive, send)
File "/opt/pysetup/.venv/lib/python3.10/site-packages/starlette/routing.py", line 288, in handle
await self.app(scope, receive, send)
File "/opt/pysetup/.venv/lib/python3.10/site-packages/starlette/routing.py", line 76, in app
await wrap_app_handling_exceptions(app, request)(scope, receive, send)
File "/opt/pysetup/.venv/lib/python3.10/site-packages/starlette/_exception_handler.py", line 53, in wrapped_app
raise exc
File "/opt/pysetup/.venv/lib/python3.10/site-packages/starlette/_exception_handler.py", line 42, in wrapped_app
await app(scope, receive, sender)
File "/opt/pysetup/.venv/lib/python3.10/site-packages/starlette/routing.py", line 73, in app
response = await f(request)
File "/opt/pysetup/.venv/lib/python3.10/site-packages/fastapi/routing.py", line 301, in app
raw_response = await run_endpoint_function(
File "/opt/pysetup/.venv/lib/python3.10/site-packages/fastapi/routing.py", line 214, in run_endpoint_function
return await run_in_threadpool(dependant.call, **values)
File "/opt/pysetup/.venv/lib/python3.10/site-packages/starlette/concurrency.py", line 39, in run_in_threadpool
return await anyio.to_thread.run_sync(func, *args)
File "/opt/pysetup/.venv/lib/python3.10/site-packages/anyio/to_thread.py", line 33, in run_sync
return await get_asynclib().run_sync_in_worker_thread(
File "/opt/pysetup/.venv/lib/python3.10/site-packages/anyio/_backends/_asyncio.py", line 877, in run_sync_in_worker_thread
return await future
File "/opt/pysetup/.venv/lib/python3.10/site-packages/anyio/_backends/_asyncio.py", line 807, in run
result = context.run(func, *args)
File "/app/mealie/routes/auth/auth.py", line 69, in get_token
auth = auth_provider.authenticate()
File "/app/mealie/core/security/providers/ldap_provider.py", line 33, in authenticate
user = self.get_user()
File "/app/mealie/core/security/providers/ldap_provider.py", line 120, in get_user
conn.set_option(ldap.OPT_X_TLS_NEWCTX, 0)
File "/opt/pysetup/.venv/lib/python3.10/site-packages/ldap/ldapobject.py", line 698, in set_option
return self._ldap_call(self._l.set_option,option,invalue)
File "/opt/pysetup/.venv/lib/python3.10/site-packages/ldap/ldapobject.py", line 128, in _ldap_call
result = func(*args,**kwargs)
ValueError: option error

Mealie Version

Details
Version: nightly
Build: b5643a9
Anwendungsmodus: Produktivumgebung
Demostatus: Keine Demo
API-Port: 9000
API Dokumentation: Aktiviert
Datenbanktyp: postgres
Standardhaushalt: Family
Rezept Scraper Version: 15.2.1

Checks
Sichere Website: Nein
Serverseitige Basis-URL: Ja
LDAP bereit: Ja
OIDC bereit: Nein
OpenAI bereit: Nein
E-Mail konfiguriert: Ja

Deployment

Unraid

Additional Deployment Details

docker run
-d
--name='Mealie'
--net='br0'
--ip='10.10.10.47'
--pids-limit 2048
-e TZ="Europe/Berlin"
-e HOST_OS="Unraid"
-e HOST_HOSTNAME="HOSTNAME"
-e HOST_CONTAINERNAME="Mealie"
-e 'TCP_PORT_9000'='3000'
-e 'ALLOW_SIGNUP'='false'
-e 'DEFAULT_EMAIL'='mealie@example.com'
-e 'SMTP_FROM_EMAIL'='mail@example.com'
-e 'SMTP_HOST'='mail.example.com'
-e 'SMTP_USER'='mail@example.com'
-e 'SMTP_PASSWORD'='EMAILPASSWORD'
-e 'SMTP_PORT'='587'
-e 'BASE_URL'='https://mealie.example.com'
-e 'LDAP_AUTH_ENABLED'='true'
-e 'LDAP_SERVER_URL'='ldap://10.10.10.49:3890'
-e 'LDAP_TLS_INSECURE'='true'
-e 'LDAP_TLS_CACERTFILE'='none'
-e 'LDAP_ENABLE_STARTTLS'='false'
-e 'LDAP_BASE_DN'='ou=people,dc=example,dc=com'
-e 'LDAP_QUERY_BIND'='cn=mealie_bind_user,ou=people,dc=example,dc=com'
-e 'LDAP_QUERY_PASSWORD'='LDAPPASSWORD'
-e 'LDAP_USER_FILTER'='(memberof=cn=mealie_users,ou=groups,dc=example,dc=com)'
-e 'LDAP_ADMIN_FILTER'='(memberof=cn=mealie_admins,ou=groups,dc=example,dc=com)'
-e 'LDAP_ID_ATTRIBUTE'='uid'
-e 'LDAP_NAME_ATTRIBUTE'='displayName'
-e 'LDAP_MAIL_ATTRIBUTE'='mail'
-e 'DEFAULT_GROUP'='Home'
-e 'PUID'='99'
-e 'PGID'='100'
-e 'WEB_CONCURRENCY'='1'
-e 'MAX_WORKERS'='1'
-e 'DB_ENGINE'='postgres'
-e 'POSTGRES_USER'='mealie'
-e 'POSTGRES_PASSWORD'='POSTGRESPASSWORD'
-e 'POSTGRES_SERVER'='10.10.10.46'
-e 'POSTGRES_PORT'='5432'
-e 'POSTGRES_DB'='mealie'
-e 'SMTP_AUTH_STRATEGY'='TLS'
-l net.unraid.docker.managed=dockerman
-l net.unraid.docker.webui='http://[IP]:[PORT:9000]'
-l net.unraid.docker.icon='https://raw.githubusercontent.com/selfhosters/unRAID-CA-templates/master/templates/img/mealiev1.png'
-v '/mnt/user/appdata/mealie':'/app/data':'rw' 'ghcr.io/mealie-recipes/mealie:nightly'

@psychofaktory psychofaktory added bug Something isn't working triage labels Oct 24, 2024
@felixls
Copy link

felixls commented Oct 24, 2024

I got similar error using OIDC since the last update

@cmintey
Copy link
Contributor

cmintey commented Oct 25, 2024

Please omit the LDAP_TLS_CACERTFILE env option in your docker command. It's getting set to the literal value of "none"

@psychofaktory
Copy link
Author

Please omit the LDAP_TLS_CACERTFILE env option in your docker command. It's getting set to the literal value of "none"

Thank you!
That fixed the Problem!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working triage
Projects
None yet
Development

No branches or pull requests

3 participants