h44z / wg-portal

WireGuard Configuration Portal with LDAP connection
https://wgportal.org/
MIT License
880 stars 121 forks source link

failed to update ldap user (Duplicate entry in BD) #258

Open Alexander-Kazandzhiyan opened 2 months ago

Alexander-Kazandzhiyan commented 2 months ago

We have a problem portal v.1.0.18 LDAP - FreeIPA server

Variables: LDAP_BASEDN=cn=users,cn=accounts,dc=example,dc=com LDAP_SYNC_FILTER=(&(objectClass=organizationalPerson)(memberof=cn=vpnusers,cn=groups,cn=accounts,dc=example,dc=com)) LDAP_LOGIN_FILTER=(&(objectClass=organizationalPerson)(memberof=cn=vpnusers,cn=groups,cn=accounts,dc=example,dc=com)(!(nsaccountlock=TRUE))(uid={{login_identifier}})) LDAP_ATTR_GROUPS=memberOf LDAP_ADMIN_GROUP=cn=vpnadmins,cn=groups,cn=accounts,dc=example,dc=com

All working good. All users of group vpnusers is in portals user-list. But if on FreeIPA i remove user, for example, testvpn1 from group vpnusers it marks red in user-list in portal. Its ok. But When i add this user in vpnusers group back we have errors in docker logs of portal: if we use sqlite:

DEBU[2024-04-25 13:49:16] updating ldap user testvpn1@example.com
ERRO[2024-04-25 13:49:16] failed to update ldap user testvpn1@example.com in database: failed to update user testvpn1@example.com: UNIQUE constraint failed: users.email

if we use mysql:

DEBU[2024-04-25 13:53:56] updating ldap user testvpn1@example.com
ERRO[2024-04-25 13:53:56] failed to update ldap user testvpn1@example.com in database: failed to update user testvpn1@example.com: Error 1062 (23000): Duplicate entry 'testvpn1@example.com' for key 'users.PRIMARY'

and user testvpn1 still red in user-list.

Do you know this problem? What we must to do with this situation? PS Now We have around 8 users with this truble.

Alexander-Kazandzhiyan commented 2 months ago

if i select user record from DB i see that user mark deleted

mysql> select * from users where firstname = 'testvpn1';
+-----------------------+--------+----------+-----------+----------+-------+----------+-------------------------+-------------------------+-------------------------+
| email                 | source | is_admin | firstname | lastname | phone | password | created_at              | updated_at              | deleted_at              |
+-----------------------+--------+----------+-----------+----------+-------+----------+-------------------------+-------------------------+-------------------------+
| testvpn1@example.com | ldap   |        0 | testvpn1  | testvpn1 |       |          | 2023-10-12 09:56:41.886 | 2023-10-12 09:56:41.891 | 2024-04-25 13:47:52.948 |
+-----------------------+--------+----------+-----------+----------+-------+----------+-------------------------+-------------------------+-------------------------+
1 row in set (0.00 sec)