Skip to content

Fix/improve avatar sync from LDAP (#34573) #34587

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

Merged
merged 1 commit into from
Jun 2, 2025

Conversation

GiteaBot
Copy link
Collaborator

@GiteaBot GiteaBot commented Jun 2, 2025

Backport #34573 by @raucao

This fixes 3 issues I encountered when debugging problems with our LDAP sync:

  1. The comparison of the hashed image data in IsUploadAvatarChanged is wrong. It seems to be from before avatar hashing was changed and unified in Unify hashing for avatar #22289. This results in the function always returning true for any avatars, even if they weren't changed.
  2. Even if there's no avatar to upload (i.e. no avatar available for the LDAP entry), the upload function would still be called for every single user, only to then fail, because the data isn't valid. This is unnecessary.
  3. Another small issue is that the comparison function (and thus hashing of data) is called for every user, even if there is no avatar attribute configured at all for the LDAP source. Thus, I switched the condition nesting, so that no cycles are wasted when avatar sync isn't configured in the first place.

I also added a trace log for when there is actually a new avatar being uploaded for an existing user, which is now only shown when that is actually the case.

This fixes 3 issues I encountered when debugging problems with our LDAP sync:

1. The comparison of the hashed image data in `IsUploadAvatarChanged` is
wrong. It seems to be from before avatar hashing was changed and unified
in go-gitea#22289. This results in the function always returning `true` for any
avatars, even if they weren't changed.
2. Even if there's no avatar to upload (i.e. no avatar available for the
LDAP entry), the upload function would still be called for every single
user, only to then fail, because the data isn't valid. This is
unnecessary.
3. Another small issue is that the comparison function (and thus hashing
of data) is called for every user, even if there is no avatar attribute
configured at all for the LDAP source. Thus, I switched the condition
nesting, so that no cycles are wasted when avatar sync isn't configured
in the first place.

I also added a trace log for when there is actually a new avatar being
uploaded for an existing user, which is now only shown when that is
actually the case.

---------

Co-authored-by: wxiaoguang <[email protected]>
@GiteaBot GiteaBot added modifies/go Pull requests that update Go code type/bug labels Jun 2, 2025
@GiteaBot GiteaBot requested a review from lunny June 2, 2025 17:33
@GiteaBot GiteaBot added this to the 1.24.0 milestone Jun 2, 2025
@GiteaBot GiteaBot requested a review from wxiaoguang June 2, 2025 17:33
@GiteaBot GiteaBot added the lgtm/need 2 This PR needs two approvals by maintainers to be considered for merging. label Jun 2, 2025
@GiteaBot GiteaBot added lgtm/need 1 This PR needs approval from one additional maintainer to be merged. and removed lgtm/need 2 This PR needs two approvals by maintainers to be considered for merging. labels Jun 2, 2025
@GiteaBot GiteaBot added lgtm/done This PR has enough approvals to get merged. There are no important open reservations anymore. and removed lgtm/need 1 This PR needs approval from one additional maintainer to be merged. labels Jun 2, 2025
@silverwind silverwind merged commit 5d6c5ce into go-gitea:release/v1.24 Jun 2, 2025
26 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
lgtm/done This PR has enough approvals to get merged. There are no important open reservations anymore. modifies/go Pull requests that update Go code type/bug
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants