-
Notifications
You must be signed in to change notification settings - Fork 81
Description
Just had some weird issues when trying to log into my new Tuwunel installation with Element X. When authenticating via LDAP, the login flow incorrectly triggers admin room membership changes, revoking the user's admin status and removing them from the admin room.
Environment
- Tuwunel version: 1.4.7
- LDAP provider: Authentik LDAP outpost
- Clients tested: Element X (Android/iOS), Element Desktop
With a single admin user
Login fails entirely with the following error in logs:
2025-12-10T14:47:10.278949Z ERROR tuwunel_service::rooms::timeline::build: Last admin cannot leave the admins room.
at src/service/rooms/timeline/build.rs:218 on tuwunel:worker ThreadId(3)
in tuwunel_api::client::session::ldap::ldap with user_id=@dark:nether.im
in tuwunel_api::client::session::login with client=2605:a601:a6dd:c400:95c7:54f5:d4fb:10bf body.login_info=Password { identifier: Some(UserIdOrLocalpart("dark")), user: None, address: None, medium: None, .. }
The client receives "wrong username or password" despite credentials being correct.
With multiple admin users
Login succeeds, but the authenticating user is removed from the admin room with the message:
You were removed from nether.im Admin Room by @conduit:nether.im
Reason: Admin Revoked
The user must be manually re-added as admin via !admin users make_user_admin <username> after each LDAP login.
Element Desktop
Element Desktop does not exhibit this behavior - LDAP login works correctly without affecting admin status. This suggests Element X may be using a different authentication code path that triggers the bug.
Steps to reproduce
- Configure Tuwunel with LDAP authentication (Authentik LDAP outpost in my case)
- Have an admin user authenticate via LDAP
- Attempt to log in with Element X
Expected behavior
LDAP authentication should validate credentials and create a session without modifying admin room membership.
Actual behavior
The LDAP login code path at tuwunel_api::client::session::ldap::ldap calls into rooms/timeline/build which attempts to remove the user from the admin room.
Workaround
Create a second admin user before attempting LDAP login with Element X. After login, re-add the affected user as admin using:
!admin users make_user_admin <username>