fix(web/panettone): unbind LDAP connections after auth

unbind & close the stream of newly created LDAP connections after
auth, which might prevent some of the resource leaking we've got going
on

i did actually verify in sly that this still works. yay.

Change-Id: I92c8ca20de642585ae4c24aa455d051ee6e44a87
Reviewed-on: https://cl.tvl.fyi/c/depot/+/5193
Tested-by: BuildkiteCI
Reviewed-by: grfn <grfn@gws.fyi>
This commit is contained in:
Vincent Ambo 2022-02-02 20:55:39 +03:00 committed by tazjin
parent 0d0b43ed88
commit 67a31e7252

View file

@ -104,12 +104,12 @@ request against the ldap server at *ldap*. Returns the user if authentication is
successful, `nil' otherwise"
(when-let ((user (if (typep user-or-username 'user) user-or-username
(find-user user-or-username))))
(let ((dn (dn user)))
(let ((code-sym
(nth-value 1 (ldap:bind
(ldap:new-ldap :host (ldap:host *ldap*)
(let* ((dn (dn user))
(conn (ldap:new-ldap :host (ldap:host *ldap*)
:port (ldap:port *ldap*)
:user dn
:pass password)))))
:pass password))
(code-sym (nth-value 1 (unwind-protect (ldap:bind conn)
(ldap:unbind conn)))))
(when (equalp code-sym 'trivial-ldap:success)
user)))))
user))))